mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
better command disabling
This commit is contained in:
parent
cbe961048b
commit
a39e257c39
@ -99,22 +99,17 @@ class BotCommands():
|
|||||||
"channels": {}
|
"channels": {}
|
||||||
}
|
}
|
||||||
if botdb.check_nick_id(target):
|
if botdb.check_nick_id(target):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["users"])):
|
if target not in list(self.dict['disabled'][disabletype]["users"].keys()):
|
||||||
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
return self.dict['disabled'][disabletype]["users"]
|
return self.dict['disabled'][disabletype]["users"][target]
|
||||||
elif botchannels.check_channel_bot(target, True):
|
elif botchannels.check_channel_bot(target, True):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["channels"])):
|
if target not in list(self.dict['disabled'][disabletype]["channels"].keys()):
|
||||||
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
return self.dict['disabled'][disabletype]["channels"]
|
return self.dict['disabled'][disabletype]["channels"][target]
|
||||||
else:
|
else:
|
||||||
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
||||||
|
|
||||||
def check_commands_disabled(self, command, target, disabletype="fully"):
|
def check_commands_disabled(self, command, target, disabletype="fully"):
|
||||||
if disabletype not in list(self.dict['disabled'].keys()):
|
|
||||||
self.dict['disabled'][disabletype] = {
|
|
||||||
"users": {},
|
|
||||||
"channels": {}
|
|
||||||
}
|
|
||||||
if command in list(self.get_commands_disabled(target, disabletype).keys()):
|
if command in list(self.get_commands_disabled(target, disabletype).keys()):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
@ -127,15 +122,15 @@ class BotCommands():
|
|||||||
"channels": {}
|
"channels": {}
|
||||||
}
|
}
|
||||||
if botdb.check_nick_id(target):
|
if botdb.check_nick_id(target):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["users"])):
|
if target not in list(self.dict['disabled'][disabletype]["users"].keys()):
|
||||||
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
self.dict['disabled'][disabletype]["users"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
|
self.dict['disabled'][disabletype]["users"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
|
||||||
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"])
|
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"][target])
|
||||||
elif botchannels.check_channel_bot(target, True):
|
elif botchannels.check_channel_bot(target, True):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["channels"])):
|
if target not in list(self.dict['disabled'][disabletype]["channels"].keys()):
|
||||||
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
self.dict['disabled'][disabletype]["channels"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
|
self.dict['disabled'][disabletype]["channels"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
|
||||||
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"])
|
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"][target])
|
||||||
else:
|
else:
|
||||||
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
||||||
|
|
||||||
@ -146,17 +141,17 @@ class BotCommands():
|
|||||||
"channels": {}
|
"channels": {}
|
||||||
}
|
}
|
||||||
if botdb.check_nick_id(target):
|
if botdb.check_nick_id(target):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["users"])):
|
if target not in list(self.dict['disabled'][disabletype]["users"].keys()):
|
||||||
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
if command in list(self.dict['disabled'][disabletype]["users"].keys()):
|
if command in list(self.dict['disabled'][disabletype]["users"].keys()):
|
||||||
del self.dict['disabled'][disabletype]["users"][command]
|
del self.dict['disabled'][disabletype]["users"][target][command]
|
||||||
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"])
|
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"][target])
|
||||||
elif botchannels.check_channel_bot(target, True):
|
elif botchannels.check_channel_bot(target, True):
|
||||||
if not len(list(self.dict['disabled'][disabletype]["channels"])):
|
if target not in list(self.dict['disabled'][disabletype]["channels"].keys()):
|
||||||
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
self.dict['disabled'][disabletype]["users"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
|
||||||
if command in list(self.dict['disabled'][disabletype]["channels"].keys()):
|
if command in list(self.dict['disabled'][disabletype]["channels"][target]):
|
||||||
del self.dict['disabled'][disabletype]["channels"][command]
|
del self.dict['disabled'][disabletype]["channels"][target][command]
|
||||||
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"])
|
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"][target])
|
||||||
else:
|
else:
|
||||||
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
|
||||||
|
|
||||||
|
|||||||
@ -332,7 +332,7 @@ def trigger_runstatus(bot, trigger):
|
|||||||
return trigger_cant_run(bot, trigger, message)
|
return trigger_cant_run(bot, trigger, message)
|
||||||
else:
|
else:
|
||||||
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully")
|
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully")
|
||||||
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
|
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user