fix permissions logic
This commit is contained in:
parent
a71baefdbc
commit
c91b0ac944
2
main.py
2
main.py
|
@ -133,4 +133,4 @@ if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.critical(traceback.format_exc())
|
logger.critical(traceback.format_exc())
|
||||||
time.sleep(5) # don't exit, keep going
|
time.sleep(5)
|
||||||
|
|
|
@ -214,12 +214,27 @@ async def process_chat(client, room, event, command, store, openai, thread_root_
|
||||||
|
|
||||||
|
|
||||||
def check_authorized(string, to_check):
|
def check_authorized(string, to_check):
|
||||||
if to_check != 'all':
|
def check_str(s, c):
|
||||||
if '@' not in to_check and ':' not in to_check:
|
if c != 'all':
|
||||||
# Homeserver
|
if '@' not in c and ':' not in c:
|
||||||
if string.split(':')[-1] not in to_check:
|
# Homeserver
|
||||||
return False
|
if s.split(':')[-1] in c:
|
||||||
elif string not in to_check:
|
return True
|
||||||
# By username
|
elif s in c:
|
||||||
return False
|
# By username
|
||||||
return True
|
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
|
||||||
|
|
Loading…
Reference in New Issue