From ed8ba4aacc3cb24662471a1b0cfb0da0e31974cd Mon Sep 17 00:00:00 2001 From: n9k Date: Mon, 1 Aug 2022 00:57:23 +0000 Subject: [PATCH] Control socket: show emotes --- anonstream/control/spec/methods/emote.py | 12 +++++++++++- anonstream/control/spec/methods/help.py | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/anonstream/control/spec/methods/emote.py b/anonstream/control/spec/methods/emote.py index 8318ad4..1389d74 100644 --- a/anonstream/control/spec/methods/emote.py +++ b/anonstream/control/spec/methods/emote.py @@ -16,12 +16,21 @@ EMOTES = current_app.emotes async def cmd_emote_help(): normal = ['emote', 'help'] response = ( - 'Usage: emote reload\n' + 'Usage: emote [show | reload]\n' 'Commands:\n' + ' emote show........show all current emotes\n' ' emote reload......try to reload the emote schema (existing messages are not modified)\n' ) return normal, response +async def cmd_emote_show(): + emotes_for_json = [emote.copy() for emote in EMOTES] + for emote in emotes_for_json: + emote['regex'] = emote['regex'].pattern + normal = ['emote', 'show'] + response = json.dumps(emotes_for_json) + '\n' + return normal, response + async def cmd_emote_reload(): try: emotes = await load_emote_schema_async(CONFIG['EMOTE_SCHEMA']) @@ -46,6 +55,7 @@ async def cmd_emote_reload(): SPEC = Str({ None: End(cmd_emote_help), 'help': End(cmd_emote_help), + 'show': End(cmd_emote_show), 'reload': End(cmd_emote_reload), }) diff --git a/anonstream/control/spec/methods/help.py b/anonstream/control/spec/methods/help.py index 2cd7d2f..d38a322 100644 --- a/anonstream/control/spec/methods/help.py +++ b/anonstream/control/spec/methods/help.py @@ -24,6 +24,7 @@ async def cmd_help(): ' allowedness setdefault BOOLEAN.set the default allowedness\n' ' allowedness add SET STRING.....add to the blacklist/whitelist\n' ' allowedness remove SET STRING..remove from the blacklist/whitelist\n' + ' emote show.....................show all current emotes\n' ' emote reload...................try reloading the emote schema\n' ) return normal, response