Added the option to !opt-in/opt-out [onlinebot only]

Fixed command & event threading
Events are now threaded by event_type (i.e. all buddy_logon events get ran in the same one)
Added default preferences
Fixed recipe loading for multiple installs (i.e. on different machines)
This commit is contained in:
2021-08-27 13:58:47 +02:00
parent d0c8c1744c
commit c04f76c0db
24 changed files with 258 additions and 122 deletions
@@ -25,7 +25,7 @@ class RandomController:
self.command_alias_service.add_alias("verify", "roll verify")
self.command_alias_service.add_alias("lootorder", "random")
@command(command="random", params=[Any("items")], access_level="all",
@command(command="random", params=[Any("items")], access_level="member",
description="Randomly order a list of elements",
extended_description="Enter a space-delimited list of items to randomize.")
def random_command(self, _, items):
@@ -33,19 +33,19 @@ class RandomController:
random.shuffle(items)
return " ".join(items)
@command(command="roll", params=[Const("verify"), Int("roll_id")], access_level="all",
@command(command="roll", params=[Const("verify"), Int("roll_id")], access_level="member",
description="Verify a roll that happened")
def roll_verify_command(self, _, _1, roll_id):
row = self.db.query_single("SELECT * FROM roll WHERE id = ?", [roll_id])
if not row:
return "Could not find roll with id <highlight>%d</highlight>." % roll_id
return f"Could not find roll with id <highlight>{roll_id:d}</highlight>."
else:
time_string = self.util.time_to_readable(int(time.time()) - row.created_at)
name = self.character_service.resolve_char_to_name(row.char_id)
return "<highlight>%s</highlight> rolled by <highlight>%s</highlight> %s ago. Possible options: %s." % (
row.result, name, time_string, row.options)
return f"<highlight>{row.result}</highlight> rolled by <highlight>{name}</highlight> " \
f"{time_string} ago. Possible options: {row.options}."
@command(command="roll", params=[Int("start_value", is_optional=True), Int("end_value")], access_level="all",
@command(command="roll", params=[Int("start_value", is_optional=True), Int("end_value")], access_level="member",
description="Roll a number between 1 and a number",
extended_description="The given numbers are included in the roll.")
def roll_number_command(self, request, start_value, end_value):
@@ -64,7 +64,7 @@ class RandomController:
f"To verify do /tell <myname> verify {self.db.last_insert_id():d}"
# Keep this method at the bottom of file otherwise it will precede over all other commands
@command(command="roll", params=[Any("items")], access_level="all",
@command(command="roll", params=[Any("items")], access_level="member",
description="Roll a random value",
extended_description="Enter a space-delimited list of values to roll")
def roll_text_variables_command(self, request, items):
@@ -17,7 +17,7 @@ class WhompahController:
self.db.create_view("whompah_cities")
self.db.create_view("whompah_cities_rel")
@command(command="whompah", params=[], access_level="all",
@command(command="whompah", params=[], access_level="member",
description="Show list of whompah cities")
def whompah_list_cmd(self, request):
cities = self.db.query("SELECT id, city_name, zone, faction, short_name FROM whompah_cities ORDER BY city_name")
@@ -29,7 +29,7 @@ class WhompahController:
return ChatBlob("Whompah Cities", blob)
@command(command="whompah", params=[Any("city1"), Any("city2")], access_level="all",
@command(command="whompah", params=[Any("city1"), Any("city2")], access_level="member",
description="Show whompah route between two cities")
def whompah_travel_cmd(self, request, city_name1, city_name2):
city1 = self.get_whompah_city(city_name1)
@@ -53,7 +53,7 @@ class WhompahController:
path = self.format_path(self.find_path(cities, city1.id, city2.id))
return " -> ".join(path)
@command(command="whompah", params=[Any("city")], access_level="all",
@command(command="whompah", params=[Any("city")], access_level="member",
description="Show whompah destinations for a city")
def whompah_city_cmd(self, request, city_name):
city = self.get_whompah_city(city_name)