messagelog errors

This commit is contained in:
deathbybandaid 2019-06-28 15:22:29 -04:00
parent 1ebf73f155
commit cbe961048b
8 changed files with 35 additions and 34 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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())):

View File

@ -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"])))

View File

@ -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).")

View File

@ -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())

View File

@ -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)

View File

@ -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)])