From 0418e3e24cbaf849f9192de573091d5377566f0c Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 14:33:46 -0400 Subject: [PATCH 01/12] remove todo code --- sopel_modules/SpiceBot/Users.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index fb915b3..21100ae 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -236,13 +236,6 @@ class BotUsers(): def mode(self, bot, trigger): return - def targetcheck(self, target): - return True - - # idk whois - if not botdb.check_nick_id(target): - return - def nick_actual(self, nick, altlist=None): nick_id = self.whois_ident(nick) nick_actual = self.ID(nick_id) From a375c6238dc74b3685c25e0b2145227abc6d525d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 14:36:31 -0400 Subject: [PATCH 02/12] patches --- sopel_modules/SpiceBot_Core_Commands/AI.py | 2 +- sopel_modules/SpiceBot_Core_Commands/DictComs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 3881d14..5a27f6d 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -209,7 +209,7 @@ def bot_command_rule_ai(bot, trigger): # elif fulltrigger.lower().startswith(tuple(["have you seen"])): # posstarget = spicemanip.main(trigger_args, 4) or 0 - # message = seen_search(bot, botcom, posstarget) + # message = seen_search(bot, trigger, posstarget) # bot.osd(message) # return # TODO diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 0516897..836a068 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -145,7 +145,7 @@ def bot_dictcom_process(bot, trigger): if trigger.sb["dict"][trigger.sb["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]: return bot_dictcom_responses(bot, trigger) else: - command_function_run = str('bot_dictcom_' + trigger.sb["dict"][trigger.sb["responsekey"]]["type"] + '(bot, botcom)') + command_function_run = str('bot_dictcom_' + trigger.sb["dict"][trigger.sb["responsekey"]]["type"] + '(bot, trigger)') eval(command_function_run) @@ -404,5 +404,5 @@ def bot_dictcom_feeds(bot, trigger): """ -def bot_dictcom_search(bot, botcom): +def bot_dictcom_search(bot, trigger): bot.say("testing done") From 1ebf73f155e5d43e8e49100b04157a3c02bd6a9b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 14:59:58 -0400 Subject: [PATCH 03/12] pass botcom --- sopel_modules/SpiceBot/Prerun.py | 10 ++++-- sopel_modules/SpiceBot/Tools.py | 35 +++++++++++++++++++ sopel_modules/SpiceBot_Core_Commands/AI.py | 2 +- .../SpiceBot_Core_Commands/BotPrivs.py | 4 +-- .../SpiceBot_Core_Commands/Channels.py | 2 +- .../SpiceBot_Core_Commands/Commands.py | 2 +- .../SpiceBot_Core_Commands/CommandsQuery.py | 6 ++-- .../SpiceBot_Core_Commands/DictComs.py | 2 +- sopel_modules/SpiceBot_Core_Commands/Gif.py | 4 +-- sopel_modules/SpiceBot_Core_Commands/Logs.py | 2 +- .../SpiceBot_Core_Commands/Messaging.py | 6 ++-- .../Runtime_Controls.py | 4 +-- .../SpiceBot_Core_Commands/Search.py | 8 ++--- .../SpiceBot_Core_Commands/Sherlock.py | 2 +- .../SpiceBot_Core_Commands/Uptime.py | 2 +- 15 files changed, 65 insertions(+), 26 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index e95a41f..7cf0c4f 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -12,7 +12,7 @@ import datetime import spicemanip -from .Tools import command_permissions_check +from .Tools import command_permissions_check, class_create from .Commands import commands as botcommands from .Database import db as botdb from .Channels import channels as botchannels @@ -27,6 +27,8 @@ def prerun(t_command_type='module', t_command_subtype=None): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): + botcom = class_create('botcom') + if t_command_type == "nickname": check_nick = spicemanip.main(trigger.args[1], 1).lower() if check_nick != str(bot.nick).lower(): @@ -91,7 +93,7 @@ def prerun(t_command_type='module', t_command_subtype=None): if not trigger.sb["hyphen_arg"]: # check if anything prohibits the nick from running the command if trigger_runstatus(bot, trigger): - function(bot, trigger, *args, **kwargs) + function(bot, trigger, botcom, *args, **kwargs) else: trigger_hyphen_arg_handler(bot, trigger) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) @@ -107,6 +109,8 @@ def prerun_query(t_command_type='module', t_command_subtype=None): @functools.wraps(function) def internal_prerun(bot, trigger, *args, **kwargs): + botcom = class_create('botcom') + if t_command_type == "nickname": check_nick = spicemanip.main(trigger.args[1], 1).lower() if check_nick != str(bot.nick).lower(): @@ -155,7 +159,7 @@ def prerun_query(t_command_type='module', t_command_subtype=None): # check if anything prohibits the nick from running the command if trigger_runstatus_query(bot, trigger): - function(bot, trigger, *args, **kwargs) + function(bot, trigger, botcom, *args, **kwargs) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) return internal_prerun diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 79b24c0..8e989a4 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -86,6 +86,41 @@ def command_permissions_check(bot, trigger, privslist): return True +""" +Classes +""" + + +def class_create(classname): + compiletext = """ + def __init__(self): + self.default = str(self.__class__.__name__) + def __repr__(self): + return repr(self.default) + def __str__(self): + return str(self.default) + def __iter__(self): + return str(self.default) + pass + """ + exec(compile("class class_" + str(classname) + ": " + compiletext, "", "exec")) + newclass = eval('class_'+classname+"()") + return newclass + + +def class_directory(inputclass): + + # make sure input is a class + # if not isinstance(inputclass, class): + # return [] + + classdirlistfull, classdirlistclean = dir(inputclass), [] + for classdiritem in classdirlistfull: + if not classdiritem.startswith("_"): + classdirlistclean.append(classdiritem) + return classdirlistclean + + """ Time """ diff --git a/sopel_modules/SpiceBot_Core_Commands/AI.py b/sopel_modules/SpiceBot_Core_Commands/AI.py index 5a27f6d..98b6fce 100644 --- a/sopel_modules/SpiceBot_Core_Commands/AI.py +++ b/sopel_modules/SpiceBot_Core_Commands/AI.py @@ -11,7 +11,7 @@ import spicemanip @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('ai') -def ai_trigger(bot, trigger): +def ai_trigger(bot, trigger, botcom): availablecomsnum = SpiceBot.botai.dict['patterncounts'] availablecomsfiles = SpiceBot.botai.dict['filecounts'] displayval = "There are " + str(availablecomsnum) + " AI pattern matches available in " + str(availablecomsfiles) + " files." diff --git a/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py b/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py index 84d98c8..be1b25f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py +++ b/sopel_modules/SpiceBot_Core_Commands/BotPrivs.py @@ -11,13 +11,13 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('owners', 'owner') -def bot_command_owners(bot, trigger): +def bot_command_owners(bot, trigger, botcom): bot_command_process(bot, trigger) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('admins', 'admin') -def bot_command_admins(bot, trigger): +def bot_command_admins(bot, trigger, botcom): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Core_Commands/Channels.py b/sopel_modules/SpiceBot_Core_Commands/Channels.py index d213971..cc6e015 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Channels.py +++ b/sopel_modules/SpiceBot_Core_Commands/Channels.py @@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('channels', 'channel') -def nickname_comand_channels(bot, trigger): +def nickname_comand_channels(bot, trigger, botcom): if not len(trigger.sb['args']): commandused = 'list' diff --git a/sopel_modules/SpiceBot_Core_Commands/Commands.py b/sopel_modules/SpiceBot_Core_Commands/Commands.py index 42b7fa6..ce7c5f9 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Commands.py +++ b/sopel_modules/SpiceBot_Core_Commands/Commands.py @@ -17,7 +17,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('commands', 'command') -def nickname_comand_commands(bot, trigger): +def nickname_comand_commands(bot, trigger, botcom): if not len(trigger.sb['args']): commandused = 'list' diff --git a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py index 6820f03..2732765 100644 --- a/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py +++ b/sopel_modules/SpiceBot_Core_Commands/CommandsQuery.py @@ -14,14 +14,14 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('query') -def query_trigger(bot, trigger): +def query_trigger(bot, trigger, botcom): bot.osd("I have been programmed to help find new commands by using `?`.") @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun_query('nickname', 'nickname') @sopel.module.nickname_commands('(.*)') -def query_detection_nick(bot, trigger): +def query_detection_nick(bot, trigger, botcom): # command issued, check if valid if not trigger.sb['com'] or not len(trigger.sb['com']): @@ -87,7 +87,7 @@ def query_detection_nick(bot, trigger): @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.prerun_query('module', 'module') @sopel.module.rule('^\?(.*)') -def query_detection(bot, trigger): +def query_detection(bot, trigger, botcom): # command issued, check if valid if not trigger.sb['com'] or not len(trigger.sb['com']): diff --git a/sopel_modules/SpiceBot_Core_Commands/DictComs.py b/sopel_modules/SpiceBot_Core_Commands/DictComs.py index 836a068..507e379 100644 --- a/sopel_modules/SpiceBot_Core_Commands/DictComs.py +++ b/sopel_modules/SpiceBot_Core_Commands/DictComs.py @@ -17,7 +17,7 @@ from random import randint @SpiceBot.prerun('module', 'dictcom') @sopel.module.commands('(.*)') -def command_dictcom(bot, trigger): +def command_dictcom(bot, trigger, botcom): if trigger.sb['com'] not in list(SpiceBot.commands.dict['commands']["dictcom"].keys()): return diff --git a/sopel_modules/SpiceBot_Core_Commands/Gif.py b/sopel_modules/SpiceBot_Core_Commands/Gif.py index 5ab145a..de886f2 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Gif.py +++ b/sopel_modules/SpiceBot_Core_Commands/Gif.py @@ -13,7 +13,7 @@ import spicemanip @SpiceBot.prerun('module') @sopel.module.commands('gif') -def gif_trigger(bot, trigger): +def gif_trigger(bot, trigger, botcom): if not len(trigger.sb['args']): return bot.osd("Please present a query to search.") @@ -32,7 +32,7 @@ def gif_trigger(bot, trigger): @SpiceBot.prerun('module', "gif_prefix") @sopel.module.commands('(.*)') -def gifapi_triggers(bot, trigger): +def gifapi_triggers(bot, trigger, botcom): if trigger.sb['com'] not in list(SpiceBot.gif.valid_api.keys()): return diff --git a/sopel_modules/SpiceBot_Core_Commands/Logs.py b/sopel_modules/SpiceBot_Core_Commands/Logs.py index e66b69b..1009fc6 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Logs.py +++ b/sopel_modules/SpiceBot_Core_Commands/Logs.py @@ -15,7 +15,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('logs', 'debug') -def bot_command_logs(bot, trigger): +def bot_command_logs(bot, trigger, botcom): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.osd("I was unable to process this Bot Nick command due to privilege issues.") diff --git a/sopel_modules/SpiceBot_Core_Commands/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py index 9083841..0d8d1a1 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Messaging.py +++ b/sopel_modules/SpiceBot_Core_Commands/Messaging.py @@ -11,19 +11,19 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('action') -def bot_command_action(bot, trigger): +def bot_command_action(bot, trigger, botcom): bot_command_process(bot, trigger) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('notice') -def bot_command_notice(bot, trigger): +def bot_command_notice(bot, trigger, botcom): bot_command_process(bot, trigger) @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('privmsg', 'say', 'msg') -def bot_command_privmsg(bot, trigger): +def bot_command_privmsg(bot, trigger, botcom): bot_command_process(bot, trigger) diff --git a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index fa36758..50fc99c 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -11,7 +11,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('update') -def nickname_comand_update(bot, trigger): +def nickname_comand_update(bot, trigger, botcom): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): bot.osd("I was unable to process this Bot Nick command due to privilege issues.") @@ -42,7 +42,7 @@ def nickname_comand_update(bot, trigger): @sopel.module.nickname_commands('restart') -def nickname_comand_restart(bot, trigger): +def nickname_comand_restart(bot, trigger, botcom): if not trigger.admin: bot.osd("You are not authorized to perform this function.") diff --git a/sopel_modules/SpiceBot_Core_Commands/Search.py b/sopel_modules/SpiceBot_Core_Commands/Search.py index d33b673..1ae974f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Search.py +++ b/sopel_modules/SpiceBot_Core_Commands/Search.py @@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('module') @sopel.module.commands('search', 'find', 'google', 'lookup') -def search_main(bot, trigger): +def search_main(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: @@ -28,7 +28,7 @@ def search_main(bot, trigger): @SpiceBot.prerun('module') @sopel.module.commands("where", "whereis") -def search_where(bot, trigger): +def search_where(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: @@ -44,7 +44,7 @@ def search_where(bot, trigger): @SpiceBot.prerun('module') @sopel.module.commands("what", "whatis") -def search_what(bot, trigger): +def search_what(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: @@ -60,7 +60,7 @@ def search_what(bot, trigger): @SpiceBot.prerun('module') @sopel.module.commands("youtube", "video") -def search_video(bot, trigger): +def search_video(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: diff --git a/sopel_modules/SpiceBot_Core_Commands/Sherlock.py b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py index d4a19cb..49b22de 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Sherlock.py +++ b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py @@ -11,7 +11,7 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('module') @sopel.module.commands('sherlock', 'username') -def bot_command_sherlock(bot, trigger): +def bot_command_sherlock(bot, trigger, botcom): netlist = list(SpiceBot.sherlock.dict.keys()) diff --git a/sopel_modules/SpiceBot_Core_Commands/Uptime.py b/sopel_modules/SpiceBot_Core_Commands/Uptime.py index ecf823a..a644e37 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Uptime.py +++ b/sopel_modules/SpiceBot_Core_Commands/Uptime.py @@ -11,6 +11,6 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('uptime') -def bot_command_uptime(bot, trigger): +def bot_command_uptime(bot, trigger, botcom): timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago." bot.osd("I have been running since " + timesince) From cbe961048b68062ecf2be5ce342dc2669cf23937 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 15:22:29 -0400 Subject: [PATCH 04/12] messagelog errors --- sopel_modules/SpiceBot/MessageLog.py | 3 ++- sopel_modules/SpiceBot/Prerun.py | 4 ++-- sopel_modules/SpiceBot_Core_Commands/Channels.py | 16 ++++++++-------- sopel_modules/SpiceBot_Core_Commands/Gif.py | 8 ++++---- sopel_modules/SpiceBot_Core_Commands/Logs.py | 8 ++++---- .../SpiceBot_Core_Commands/Messaging.py | 8 ++++---- .../SpiceBot_Core_Commands/Runtime_Controls.py | 6 +++--- sopel_modules/SpiceBot_Core_Commands/Search.py | 16 ++++++++-------- 8 files changed, 35 insertions(+), 34 deletions(-) diff --git a/sopel_modules/SpiceBot/MessageLog.py b/sopel_modules/SpiceBot/MessageLog.py index ae2917f..1947bc7 100644 --- a/sopel_modules/SpiceBot/MessageLog.py +++ b/sopel_modules/SpiceBot/MessageLog.py @@ -39,7 +39,7 @@ class MessageLog(): self.error_message_dict[unique_id] = errormsg return unique_id - def messagelog_start(self, bot, trigger, log_id): + def messagelog_start(self, bot, trigger, log_id, commandname): if not trigger.is_privmsg: channelname = trigger.sender @@ -55,6 +55,7 @@ class MessageLog(): "nick": bot.nick }, "messages": [], + "commandname": commandname, } def messagelog_error(self, log_id, error_id): diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 7cf0c4f..0ec9e17 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -81,7 +81,7 @@ def prerun(t_command_type='module', t_command_subtype=None): argsdict_list = trigger_argsdict_list(argsdict_default, and_split) # Run the function for all splits - botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"]) + botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"], argsdict_default["realcomtext"]) runcount = 0 for argsdict in argsdict_list: runcount += 1 @@ -151,7 +151,7 @@ def prerun_query(t_command_type='module', t_command_subtype=None): argsdict = trigger_argsdict_single(argsdict_default, trigger_args) # Run the function for all splits - botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"]) + botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"], argsdict_default["realcomtext"]) trigger.sb = copy.deepcopy(argsdict) diff --git a/sopel_modules/SpiceBot_Core_Commands/Channels.py b/sopel_modules/SpiceBot_Core_Commands/Channels.py index cc6e015..8f88427 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Channels.py +++ b/sopel_modules/SpiceBot_Core_Commands/Channels.py @@ -49,7 +49,7 @@ def nickname_comand_channels(bot, trigger, botcom): elif commandused == 'update': if not trigger.admin: - bot.osd("You do not have permission to update the channel listing.") + SpiceBot.messagelog.messagelog_error("You do not have permission to update the channel listing.") return SpiceBot.channels.bot_part_empty(bot) SpiceBot.channels.channel_list_request(bot) @@ -64,11 +64,11 @@ def nickname_comand_channels(bot, trigger, botcom): elif commandused == 'topic': if not len(trigger.sb['args']): - bot.osd("Channel name input missing.") + SpiceBot.messagelog.messagelog_error("Channel name input missing.") return channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): - bot.osd("Channel name {} not valid.".format(channel)) + SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel)) return topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] channel = SpiceBot.channels.dict['list'][channel.lower()]['name'] @@ -78,17 +78,17 @@ def nickname_comand_channels(bot, trigger, botcom): if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: if not len(trigger.sb['args']): if trigger.is_privmsg: - bot.osd("Channel name required.") + SpiceBot.messagelog.messagelog_error("Channel name required.") return else: channel = trigger.sender else: channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): - bot.osd("Channel name {} not valid.".format(channel)) + SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): - bot.osd("I need to be in {} to see nick privileges.".format(channel)) + SpiceBot.messagelog.messagelog_error("I need to be in {} to see nick privileges.".format(channel)) return privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) @@ -105,10 +105,10 @@ def nickname_comand_channels(bot, trigger, botcom): if commandused == 'users': channel = spicemanip.main(trigger.sb['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): - bot.osd("Channel name {} not valid.".format(channel)) + SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): - bot.osd("I need to be in {} to see user list.".format(channel)) + SpiceBot.messagelog.messagelog_error("I need to be in {} to see user list.".format(channel)) return dispmsg = [] if not len(list(bot.channels[channel].privileges.keys())): diff --git a/sopel_modules/SpiceBot_Core_Commands/Gif.py b/sopel_modules/SpiceBot_Core_Commands/Gif.py index de886f2..09ee2c4 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Gif.py +++ b/sopel_modules/SpiceBot_Core_Commands/Gif.py @@ -16,7 +16,7 @@ import spicemanip def gif_trigger(bot, trigger, botcom): if not len(trigger.sb['args']): - return bot.osd("Please present a query to search.") + return SpiceBot.messagelog.messagelog_error("Please present a query to search.") query = spicemanip.main(trigger.sb['args'], 0) searchapis = list(SpiceBot.gif.valid_api.keys()) @@ -25,7 +25,7 @@ def gif_trigger(bot, trigger, botcom): gifdict = SpiceBot.gif.get_gif(searchdict) if gifdict["error"]: - bot.osd(gifdict["error"]) + SpiceBot.messagelog.messagelog_error(gifdict["error"]) else: bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) @@ -38,7 +38,7 @@ def gifapi_triggers(bot, trigger, botcom): return if not len(trigger.sb['args']): - return bot.osd("Please present a query to search.") + return SpiceBot.messagelog.messagelog_error("Please present a query to search.") query = spicemanip.main(trigger.sb['args'], 0) searchdict = {"query": query, "gifsearch": trigger.sb['com']} @@ -46,6 +46,6 @@ def gifapi_triggers(bot, trigger, botcom): gifdict = SpiceBot.gif.get_gif(searchdict) if gifdict["error"]: - bot.osd(gifdict["error"]) + SpiceBot.messagelog.messagelog_error(gifdict["error"]) else: bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) diff --git a/sopel_modules/SpiceBot_Core_Commands/Logs.py b/sopel_modules/SpiceBot_Core_Commands/Logs.py index 1009fc6..a65f6ba 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Logs.py +++ b/sopel_modules/SpiceBot_Core_Commands/Logs.py @@ -18,7 +18,7 @@ import sopel_modules.SpiceBot as SpiceBot def bot_command_logs(bot, trigger, botcom): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.osd("I was unable to process this Bot Nick command due to privilege issues.") + SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.") return logtype = spicemanip.main(trigger.sb['args'], 1) or None @@ -29,9 +29,9 @@ def bot_command_logs(bot, trigger, botcom): if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())): closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse') if not len(closestmatches): - bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') + SpiceBot.messagelog.messagelog_error("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') else: - bot.osd("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') + SpiceBot.messagelog.messagelog_error("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return @@ -40,7 +40,7 @@ def bot_command_logs(bot, trigger, botcom): logindex = SpiceBot.logs.get_logs(logtype) if not len(logindex): - bot.osd("No logs found for " + str(logtype) + ".") + SpiceBot.messagelog.messagelog_error("No logs found for " + str(logtype) + ".") return bot.osd("Is Examining " + str(logtype) + " log(s).") diff --git a/sopel_modules/SpiceBot_Core_Commands/Messaging.py b/sopel_modules/SpiceBot_Core_Commands/Messaging.py index 0d8d1a1..f342a83 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Messaging.py +++ b/sopel_modules/SpiceBot_Core_Commands/Messaging.py @@ -30,21 +30,21 @@ def bot_command_privmsg(bot, trigger, botcom): def bot_command_process(bot, trigger): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']): - bot.osd("I was unable to process this Bot Nick command due to privilege issues.") + SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.") return if trigger.sb['com'] in ['say', 'msg']: trigger.sb['com'] = 'privmsg' if not len(trigger.sb['args']): - bot.osd("You must specify a channel or nick.") + SpiceBot.messagelog.messagelog_error("You must specify a channel or nick.") return target = spicemanip.main(trigger.sb['args'], 1) if (target not in ['allchans', 'allnicks'] and not SpiceBot.inlist(target.lower(), list(SpiceBot.channels.dict['list'].keys())) and not SpiceBot.inlist(target.lower(), bot.users)): - bot.osd("Channel/nick name {} not valid.".format(target)) + SpiceBot.messagelog.messagelog_error("Channel/nick name {} not valid.".format(target)) return trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') @@ -58,7 +58,7 @@ def bot_command_process(bot, trigger): botmessage = spicemanip.main(trigger.sb['args'], 0) if not botmessage: - bot.osd("You must specify a message to send.") + SpiceBot.messagelog.messagelog_error("You must specify a message to send.") return bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper()) diff --git a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py index 50fc99c..0bd832f 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py +++ b/sopel_modules/SpiceBot_Core_Commands/Runtime_Controls.py @@ -14,7 +14,7 @@ import sopel_modules.SpiceBot as SpiceBot def nickname_comand_update(bot, trigger, botcom): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): - bot.osd("I was unable to process this Bot Nick command due to privilege issues.") + SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.") return if not len(trigger.sb['args']): @@ -23,7 +23,7 @@ def nickname_comand_update(bot, trigger, botcom): commandused = spicemanip.main(trigger.sb['args'], 1).lower() if commandused not in ['deps', 'nodeps']: - bot.osd("Please specify deps or nodeps") + SpiceBot.messagelog.messagelog_error("Please specify deps or nodeps") return trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') @@ -45,7 +45,7 @@ def nickname_comand_update(bot, trigger, botcom): def nickname_comand_restart(bot, trigger, botcom): if not trigger.admin: - bot.osd("You are not authorized to perform this function.") + SpiceBot.messagelog.messagelog_error("You are not authorized to perform this function.") quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" SpiceBot.logs.log('SpiceBot_Restart', quitmessage) diff --git a/sopel_modules/SpiceBot_Core_Commands/Search.py b/sopel_modules/SpiceBot_Core_Commands/Search.py index 1ae974f..b958167 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Search.py +++ b/sopel_modules/SpiceBot_Core_Commands/Search.py @@ -16,12 +16,12 @@ def search_main(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: - bot.osd("Not sure what you want me to look for.") + SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.") return searchreturn = SpiceBot.google.search(searchterm) if not searchreturn: - bot.osd('I cannot find anything about that') + SpiceBot.messagelog.messagelog_error('I cannot find anything about that') else: bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) @@ -32,12 +32,12 @@ def search_where(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: - bot.osd("Not sure what you want me to look for.") + SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.") return searchreturn = SpiceBot.google.search(searchterm, 'maps') if not searchreturn: - bot.osd('I cannot find anything about that') + SpiceBot.messagelog.messagelog_error('I cannot find anything about that') else: bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)]) @@ -48,12 +48,12 @@ def search_what(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: - bot.osd("Not sure what you want me to look for.") + SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.") return searchreturn = SpiceBot.google.search(searchterm) if not searchreturn: - bot.osd('I cannot find anything about that') + SpiceBot.messagelog.messagelog_error('I cannot find anything about that') else: bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) @@ -64,11 +64,11 @@ def search_video(bot, trigger, botcom): searchterm = spicemanip.main(trigger.sb['args'], 0) or None if not searchterm: - bot.osd("Not sure what you want me to look for.") + SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.") return searchreturn = SpiceBot.google.search(searchterm, 'youtube') if not searchreturn: - bot.osd('I cannot find anything about that') + SpiceBot.messagelog.messagelog_error('I cannot find anything about that') else: bot.osd(["[Youtube search for '" + str(searchterm) + "']", str(searchreturn)]) From a39e257c396c1fbc6f62ccb71cca885018b4958d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 15:39:41 -0400 Subject: [PATCH 05/12] better command disabling --- sopel_modules/SpiceBot/Commands.py | 51 ++++++++++++++---------------- sopel_modules/SpiceBot/Prerun.py | 2 +- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 15ee7f3..155109b 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -99,22 +99,17 @@ class BotCommands(): "channels": {} } if botdb.check_nick_id(target): - if not len(list(self.dict['disabled'][disabletype]["users"])): - self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} - return self.dict['disabled'][disabletype]["users"] + if target not in list(self.dict['disabled'][disabletype]["users"].keys()): + self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + return self.dict['disabled'][disabletype]["users"][target] elif botchannels.check_channel_bot(target, True): - if not len(list(self.dict['disabled'][disabletype]["channels"])): - self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - return self.dict['disabled'][disabletype]["channels"] + if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): + self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + return self.dict['disabled'][disabletype]["channels"][target] else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") 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()): return True else: @@ -127,15 +122,15 @@ class BotCommands(): "channels": {} } if botdb.check_nick_id(target): - if not len(list(self.dict['disabled'][disabletype]["users"])): - self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} - self.dict['disabled'][disabletype]["users"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"]) + if target not in list(self.dict['disabled'][disabletype]["users"].keys()): + self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + 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"][target]) elif botchannels.check_channel_bot(target, True): - if not len(list(self.dict['disabled'][disabletype]["channels"])): - self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - self.dict['disabled'][disabletype]["channels"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"]) + if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): + self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + 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"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") @@ -146,17 +141,17 @@ class BotCommands(): "channels": {} } if botdb.check_nick_id(target): - if not len(list(self.dict['disabled'][disabletype]["users"])): - self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + if target not in list(self.dict['disabled'][disabletype]["users"].keys()): + 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()): - del self.dict['disabled'][disabletype]["users"][command] - botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"]) + del self.dict['disabled'][disabletype]["users"][target][command] + botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"][target]) elif botchannels.check_channel_bot(target, True): - if not len(list(self.dict['disabled'][disabletype]["channels"])): - self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - if command in list(self.dict['disabled'][disabletype]["channels"].keys()): - del self.dict['disabled'][disabletype]["channels"][command] - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"]) + if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): + self.dict['disabled'][disabletype]["users"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + if command in list(self.dict['disabled'][disabletype]["channels"][target]): + del self.dict['disabled'][disabletype]["channels"][target][command] + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 0ec9e17..cf1606d 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -332,7 +332,7 @@ def trigger_runstatus(bot, trigger): return trigger_cant_run(bot, trigger, message) else: 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 From 13b8ca23459922b2f67ef784d33169ec52230a66 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 15:51:14 -0400 Subject: [PATCH 06/12] realcomref --- sopel_modules/SpiceBot/Prerun.py | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index cf1606d..17a55ad 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -18,6 +18,7 @@ from .Database import db as botdb from .Channels import channels as botchannels from .MessageLog import messagelog as botmessagelog from .Config import config as botconfig +from .Users import users as botusers def prerun(t_command_type='module', t_command_subtype=None): @@ -291,20 +292,20 @@ def trigger_runstatus(bot, trigger): # check channel multirun blocks if not trigger.is_privmsg: channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "multirun") - if trigger.sb["realcom"] in list(channel_disabled_list.keys()): - reason = channel_disabled_list[trigger.sb["realcom"]]["reason"] - timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"] - bywhom = channel_disabled_list[trigger.sb["realcom"]]["disabledby"] + if trigger.sb["realcomref"] in list(channel_disabled_list.keys()): + reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"] + bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"] message = "The " + str(trigger.sb["comtext"]) + " command multirun usage was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) # don't run commands that are disabled for specific users nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "multirun") - if trigger.sb["realcom"] in list(nick_disabled_list.keys()): - bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"] - if bywhom != trigger.nick: - reason = nick_disabled_list[trigger.sb["realcom"]]["reason"] - timestamp = nick_disabled_list[trigger.sb["realcom"]]["timestamp"] + if trigger.sb["realcomref"] in list(nick_disabled_list.keys()): + bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"] + if botusers.ID(bywhom) != botusers.ID(trigger.nick): + reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"] message = "The " + str(trigger.sb["comtext"]) + " command was multirun unsage disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) else: @@ -314,20 +315,20 @@ def trigger_runstatus(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") - if trigger.sb["realcom"] in list(channel_disabled_list.keys()): - reason = channel_disabled_list[trigger.sb["realcom"]]["reason"] - timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"] - bywhom = channel_disabled_list[trigger.sb["realcom"]]["disabledby"] + if trigger.sb["realcomref"] in list(channel_disabled_list.keys()): + reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"] + bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"] message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) # don't run commands that are disabled for specific users nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") - if trigger.sb["realcom"] in list(nick_disabled_list.keys()): - bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"] - if bywhom != trigger.nick: - reason = nick_disabled_list[trigger.sb["realcom"]]["reason"] - timestamp = nick_disabled_list[trigger.sb["realcom"]]["timestamp"] + if trigger.sb["realcomref"] in list(nick_disabled_list.keys()): + bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"] + if botusers.ID(bywhom) != botusers.ID(trigger.nick): + reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"] message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) else: From f654d38671cb61eb2c77d33de5cf46d7f340643b Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 15:54:24 -0400 Subject: [PATCH 07/12] args handle --- sopel_modules/SpiceBot/Prerun.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 17a55ad..2285d3e 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -399,6 +399,7 @@ def trigger_hyphen_arg_handler(bot, trigger): else: botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " usage for?") return + trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", "list") if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.") @@ -449,6 +450,7 @@ def trigger_hyphen_arg_handler(bot, trigger): else: botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " multirun usage for?") return + trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", "list") if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.") From 2614ee5b509fd17f542ad48d3ea5799d1874ffcd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 15:57:55 -0400 Subject: [PATCH 08/12] adjsut query prerun --- sopel_modules/SpiceBot/Prerun.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 2285d3e..54b81e1 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -248,25 +248,25 @@ def trigger_runstatus_query(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") - if "nickname_query" in list(channel_disabled_list.keys()): - reason = channel_disabled_list["nickname_query"]["reason"] - timestamp = channel_disabled_list["nickname_query"]["timestamp"] - bywhom = channel_disabled_list["nickname_query"]["disabledby"] + if trigger.sb["realcomref"] in list(channel_disabled_list.keys()): + reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"] + bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"] message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) # don't run commands that are disabled for specific users nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") - if "nickname_query" in list(nick_disabled_list.keys()): - bywhom = nick_disabled_list["nickname_query"]["disabledby"] - if bywhom != trigger.nick: - reason = nick_disabled_list["nickname_query"]["reason"] - timestamp = nick_disabled_list["nickname_query"]["timestamp"] + if trigger.sb["realcomref"] in list(nick_disabled_list.keys()): + bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"] + if botusers.ID(bywhom) != botusers.ID(trigger.nick): + reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"] + timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"] message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) else: 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 From 6cfec9d645c1f1da6382e5ce99c63214973270dd Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 16:17:43 -0400 Subject: [PATCH 09/12] test --- sopel_modules/SpiceBot/Commands.py | 92 ++++++++++++++++++------------ sopel_modules/SpiceBot/Prerun.py | 6 +- 2 files changed, 59 insertions(+), 39 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 155109b..ff56d4b 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -21,6 +21,7 @@ from .Config import config as botconfig from .Database import db as botdb from .Read import read as botread from .Channels import channels as botchannels +from .Users import users as botusers class SpiceBot_Commands_MainSection(StaticSection): @@ -91,21 +92,32 @@ class BotCommands(): return realcom + def chan_or_nick(self, target): + if botchannels.check_channel_bot(target, True): + return "channel" + elif botdb.check_nick_id(target): + return "nick" + else: + raise Exception(str(target.lower()) + " appears to not be a valid user/channel") + def get_commands_disabled(self, target, disabletype="fully"): disabletype = str(disabletype) + target_type = self.chan_or_nick(target) if disabletype not in list(self.dict['disabled'].keys()): self.dict['disabled'][disabletype] = { - "users": {}, - "channels": {} + "nick": {}, + "channel": {} } - if botdb.check_nick_id(target): - if target not in list(self.dict['disabled'][disabletype]["users"].keys()): - self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} - return self.dict['disabled'][disabletype]["users"][target] - elif botchannels.check_channel_bot(target, True): - if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): - self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - return self.dict['disabled'][disabletype]["channels"][target] + if target_type == "nick": + nick_id = botusers.ID(target) + if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()): + self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + return self.dict['disabled'][disabletype]["nick"][nick_id] + elif target_type == "channel": + target = str(target).lower() + if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): + self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + return self.dict['disabled'][disabletype]["channel"][target] else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") @@ -116,42 +128,50 @@ class BotCommands(): return False def set_command_disabled(self, command, target, timestamp, reason, bywhom, disabletype="fully"): + disabletype = str(disabletype) + target_type = self.chan_or_nick(target) if disabletype not in list(self.dict['disabled'].keys()): self.dict['disabled'][disabletype] = { - "users": {}, - "channels": {} + "nick": {}, + "channel": {} } - if botdb.check_nick_id(target): - if target not in list(self.dict['disabled'][disabletype]["users"].keys()): - self.dict['disabled'][disabletype]["users"][target] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} - 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"][target]) - elif botchannels.check_channel_bot(target, True): - if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): - self.dict['disabled'][disabletype]["channels"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - 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"][target]) + if target_type == "nick": + nick_id = botusers.ID(target) + if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()): + self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + self.dict['disabled'][disabletype]["nick"][nick_id][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} + botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][target]) + elif target_type == "channel": + target = str(target).lower() + if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): + self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + self.dict['disabled'][disabletype]["channel"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") def unset_command_disabled(self, command, target, disabletype="fully"): + disabletype = str(disabletype) + target_type = self.chan_or_nick(target) if disabletype not in list(self.dict['disabled'].keys()): self.dict['disabled'][disabletype] = { - "users": {}, - "channels": {} + "nick": {}, + "channel": {} } - if botdb.check_nick_id(target): - if target not in list(self.dict['disabled'][disabletype]["users"].keys()): - 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()): - del self.dict['disabled'][disabletype]["users"][target][command] - botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"][target]) - elif botchannels.check_channel_bot(target, True): - if target not in list(self.dict['disabled'][disabletype]["channels"].keys()): - self.dict['disabled'][disabletype]["users"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - if command in list(self.dict['disabled'][disabletype]["channels"][target]): - del self.dict['disabled'][disabletype]["channels"][target][command] - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"][target]) + if target_type == "nick": + nick_id = botusers.ID(target) + if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()): + self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} + if command in list(self.dict['disabled'][disabletype]["nick"].keys()): + del self.dict['disabled'][disabletype]["nick"][nick_id][command] + botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][target]) + elif target_type == "channel": + target = str(target).lower() + if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): + self.dict['disabled'][disabletype]["nick"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} + if command in list(self.dict['disabled'][disabletype]["channel"][target]): + del self.dict['disabled'][disabletype]["channel"][target][command] + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 54b81e1..7ce64f3 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -247,7 +247,7 @@ def trigger_runstatus_query(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: - channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") + channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender)) if trigger.sb["realcomref"] in list(channel_disabled_list.keys()): reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"] timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"] @@ -256,7 +256,7 @@ def trigger_runstatus_query(bot, trigger): return trigger_cant_run(bot, trigger, message) # don't run commands that are disabled for specific users - nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") + nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick)) if trigger.sb["realcomref"] in list(nick_disabled_list.keys()): bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"] if botusers.ID(bywhom) != botusers.ID(trigger.nick): @@ -265,7 +265,7 @@ def trigger_runstatus_query(bot, trigger): message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) else: - botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully") + botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick)) return True From 14cf08c32f9423cade952fb1b76c2c3a10a0c0a0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 16:19:49 -0400 Subject: [PATCH 10/12] test --- sopel_modules/SpiceBot/Commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index ff56d4b..ebf7964 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -146,7 +146,7 @@ class BotCommands(): if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} self.dict['disabled'][disabletype]["channel"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][nick_id]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") @@ -171,7 +171,7 @@ class BotCommands(): self.dict['disabled'][disabletype]["nick"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} if command in list(self.dict['disabled'][disabletype]["channel"][target]): del self.dict['disabled'][disabletype]["channel"][target][command] - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][nick_id]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") From b5fa4695988f8462c76eb5633dccaac7151f58a2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 16:20:58 -0400 Subject: [PATCH 11/12] test --- sopel_modules/SpiceBot/Commands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index ebf7964..58bae25 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -164,14 +164,14 @@ class BotCommands(): self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} if command in list(self.dict['disabled'][disabletype]["nick"].keys()): del self.dict['disabled'][disabletype]["nick"][nick_id][command] - botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][target]) + botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][nick_id]) elif target_type == "channel": target = str(target).lower() if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): self.dict['disabled'][disabletype]["nick"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} if command in list(self.dict['disabled'][disabletype]["channel"][target]): del self.dict['disabled'][disabletype]["channel"][target][command] - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][nick_id]) + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") From 2cf402224fc428dea60b25b7f618a0d46f5ee865 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Fri, 28 Jun 2019 16:51:29 -0400 Subject: [PATCH 12/12] test --- sopel_modules/SpiceBot/Commands.py | 11 +++++++---- sopel_modules/SpiceBot/Prerun.py | 18 +++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sopel_modules/SpiceBot/Commands.py b/sopel_modules/SpiceBot/Commands.py index 58bae25..002ac5a 100644 --- a/sopel_modules/SpiceBot/Commands.py +++ b/sopel_modules/SpiceBot/Commands.py @@ -122,12 +122,14 @@ class BotCommands(): raise Exception(str(target.lower()) + " appears to not be a valid user/channel") def check_commands_disabled(self, command, target, disabletype="fully"): + command = str(command).lower() if command in list(self.get_commands_disabled(target, disabletype).keys()): return True else: return False def set_command_disabled(self, command, target, timestamp, reason, bywhom, disabletype="fully"): + command = str(command).lower() disabletype = str(disabletype) target_type = self.chan_or_nick(target) if disabletype not in list(self.dict['disabled'].keys()): @@ -140,17 +142,18 @@ class BotCommands(): if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()): self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} self.dict['disabled'][disabletype]["nick"][nick_id][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][target]) + botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][nick_id]) elif target_type == "channel": target = str(target).lower() if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} self.dict['disabled'][disabletype]["channel"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} - botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][nick_id]) + botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) else: raise Exception(str(target.lower()) + " appears to not be a valid user/channel") def unset_command_disabled(self, command, target, disabletype="fully"): + command = str(command).lower() disabletype = str(disabletype) target_type = self.chan_or_nick(target) if disabletype not in list(self.dict['disabled'].keys()): @@ -162,14 +165,14 @@ class BotCommands(): nick_id = botusers.ID(target) if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()): self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} - if command in list(self.dict['disabled'][disabletype]["nick"].keys()): + if command in list(self.dict['disabled'][disabletype]["nick"][nick_id].keys()): del self.dict['disabled'][disabletype]["nick"][nick_id][command] botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][nick_id]) elif target_type == "channel": target = str(target).lower() if target not in list(self.dict['disabled'][disabletype]["channel"].keys()): self.dict['disabled'][disabletype]["nick"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} - if command in list(self.dict['disabled'][disabletype]["channel"][target]): + if command in list(self.dict['disabled'][disabletype]["channel"][target].keys()): del self.dict['disabled'][disabletype]["channel"][target][command] botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target]) else: diff --git a/sopel_modules/SpiceBot/Prerun.py b/sopel_modules/SpiceBot/Prerun.py index 7ce64f3..29f96a4 100644 --- a/sopel_modules/SpiceBot/Prerun.py +++ b/sopel_modules/SpiceBot/Prerun.py @@ -236,12 +236,12 @@ def trigger_runstatus_query(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: - channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") + channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender)) if "nickname_query" in list(channel_disabled_list.keys()): return False # don't run commands that are disabled for specific users - nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") + nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick)) if "nickname_query" in list(nick_disabled_list.keys()): return False @@ -314,7 +314,7 @@ def trigger_runstatus(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: - channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") + channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender)) if trigger.sb["realcomref"] in list(channel_disabled_list.keys()): reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"] timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"] @@ -323,7 +323,7 @@ def trigger_runstatus(bot, trigger): return trigger_cant_run(bot, trigger, message) # don't run commands that are disabled for specific users - nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") + nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick)) if trigger.sb["realcomref"] in list(nick_disabled_list.keys()): bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"] if botusers.ID(bywhom) != botusers.ID(trigger.nick): @@ -332,7 +332,7 @@ def trigger_runstatus(bot, trigger): message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) return trigger_cant_run(bot, trigger, message) else: - botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully") + botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick)) return True @@ -415,24 +415,24 @@ def trigger_hyphen_arg_handler(bot, trigger): if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]: - if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "fully"): + if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target): botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already enabled for " + str(target)) return - botcommands.unset_command_disabled(trigger.sb["realcomref"], target, "fully") + botcommands.unset_command_disabled(trigger.sb["realcomref"], target) botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(target)) return else: - if botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "fully"): + if botcommands.check_commands_disabled(trigger.sb["realcomref"], target): botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already disabled for " + str(target)) return trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." timestamp = str(datetime.datetime.utcnow()) - botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick, "fully") + botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick) botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now disabled for " + str(target)) return