diff --git a/main.py b/main.py index ca8787d..b38d7a1 100755 --- a/main.py +++ b/main.py @@ -133,4 +133,4 @@ if __name__ == "__main__": asyncio.run(main()) except Exception: logger.critical(traceback.format_exc()) - time.sleep(5) # don't exit, keep going + time.sleep(5) diff --git a/matrix_gpt/bot/chat_functions.py b/matrix_gpt/bot/chat_functions.py index edf2116..dac65a0 100644 --- a/matrix_gpt/bot/chat_functions.py +++ b/matrix_gpt/bot/chat_functions.py @@ -214,12 +214,27 @@ async def process_chat(client, room, event, command, store, openai, thread_root_ def check_authorized(string, to_check): - if to_check != 'all': - if '@' not in to_check and ':' not in to_check: - # Homeserver - if string.split(':')[-1] not in to_check: - return False - elif string not in to_check: - # By username - return False - return True + def check_str(s, c): + if c != 'all': + if '@' not in c and ':' not in c: + # Homeserver + if s.split(':')[-1] in c: + return True + elif s in c: + # By username + return True + elif c == 'all': + return True + return False + + if isinstance(to_check, str): + return check_str(string, to_check) + elif isinstance(to_check, list): + output = False + for item in to_check: + print(string, item, check_str(string, item)) + if check_str(string, item): + output = True + return output + else: + raise Exception