2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-31 14:38:04 +00:00

add userlocking

This commit is contained in:
Nick80835
2020-06-16 15:51:26 -04:00
parent 7370d50f91
commit 228e293cf5
2 changed files with 15 additions and 1 deletions

View File

@@ -61,10 +61,22 @@ class CommandHandler():
value["lockreason"] = f"In use by **{event.from_id}** (`{event.text}`)"
await value["function"](event)
value["lockreason"] = None
elif value["userlocking"]:
if event.from_id in value["lockedusers"]:
await event.reply(f"Please don't spam that command.")
continue
else:
value["lockedusers"].append(event.from_id)
await value["function"](event)
value["lockedusers"].remove(event.from_id)
else:
await value["function"](event)
except Exception as exception:
value["lockreason"] = None
if event.from_id in value["lockedusers"]:
value["lockedusers"].remove(event.from_id)
self.logger.warn(f"{value['function'].__name__} - {exception}")
await event.reply(f"`An error occurred in {value['function'].__name__}: {exception}`")
raise exception

View File

@@ -69,7 +69,9 @@ class Loader():
"admin": args.get('admin', False),
"owner": args.get('owner', False),
"locking": args.get('locking', False),
"lockreason": None
"lockreason": None,
"userlocking": args.get('userlocking', False),
"lockedusers": []
}
return func