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):