mirror of
https://github.com/Nick80835/microbot
synced 2025-08-31 14:38:04 +00:00
add userlocking
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user