SpiceBot Class Consistancy

This commit is contained in:
deathbybandaid 2019-05-22 13:01:00 -04:00
parent 78c3793fbc
commit d099e3fc2b
40 changed files with 468 additions and 468 deletions

View File

@ -24,15 +24,15 @@ class BotChannels():
def channel_list_recieve_input(self, trigger):
channel, _, topic = trigger.args[1:]
if channel.lower() not in self.SpiceBot_Channels['list'].keys():
self.SpiceBot_Channels['list'][channel.lower()] = dict()
self.SpiceBot_Channels['list'][channel.lower()]['name'] = channel
self.SpiceBot_Channels['list'][channel.lower()]['topic'] = self.topic_compile(topic)
if channel.lower() not in self.dict['list'].keys():
self.dict['list'][channel.lower()] = dict()
self.dict['list'][channel.lower()]['name'] = channel
self.dict['list'][channel.lower()]['topic'] = self.topic_compile(topic)
self.channel_lock = True
def channel_list_recieve_finish(self):
if not self.SpiceBot_Channels['InitialProcess']:
self.SpiceBot_Channels['InitialProcess'] = True
if not self.dict['InitialProcess']:
self.dict['InitialProcess'] = True
self.channel_lock = False
def topic_compile(self, topic):
@ -48,17 +48,17 @@ class BotChannels():
for channel in bot.channels.keys():
if len(bot.channels[channel].privileges.keys()) == 1 and channel not in ignorepartlist and channel.startswith("#"):
bot.part(channel, "Leaving Empty Channel")
if channel.lower() in self.SpiceBot_Channels['list']:
del self.SpiceBot_Channels['list'][channel.lower()]
if channel.lower() in self.dict['list']:
del self.dict['list'][channel.lower()]
def join_all_channels(self, bot):
if bot.config.SpiceBot_Channels.joinall:
for channel in self.SpiceBot_Channels['list'].keys():
for channel in self.dict['list'].keys():
if channel.startswith("#"):
if channel not in bot.channels.keys() and channel not in bot.config.SpiceBot_Channels.chanignore:
bot.write(('JOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name']))
bot.write(('JOIN', bot.nick, self.dict['list'][channel]['name']))
if channel not in bot.channels.keys() and bot.config.SpiceBot_Channels.operadmin:
bot.write(('SAJOIN', bot.nick, self.SpiceBot_Channels['list'][channel]['name']))
bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name']))
def chanadmin_all_channels(self, bot):
# Chan ADMIN +a
@ -72,4 +72,4 @@ class BotChannels():
bot.part(channel)
botchannels = BotChannels()
channels = BotChannels()

View File

@ -27,9 +27,9 @@ class BotCommands():
if not isinstance(validcoms, list):
validcoms = [validcoms]
if command_type not in self.SpiceBot_Commands['commands'].keys():
self.SpiceBot_Commands['commands'][command_type] = dict()
self.SpiceBot_Commands['counts'] += 1
if command_type not in self.dict['commands'].keys():
self.dict['commands'][command_type] = dict()
self.dict['counts'] += 1
dict_from_file = dict()
@ -44,13 +44,13 @@ class BotCommands():
comaliases = spicemanip.main(dict_from_file["validcoms"], '2+', 'list')
else:
comaliases = []
self.SpiceBot_Commands['commands'][command_type][maincom] = dict_from_file
self.dict['commands'][command_type][maincom] = dict_from_file
else:
comaliases = validcoms
for comalias in comaliases:
if comalias not in self.SpiceBot_Commands['commands'][command_type].keys():
self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor}
if comalias not in self.dict['commands'][command_type].keys():
self.dict['commands'][command_type][comalias] = {"aliasfor": aliasfor}
botcommands = BotCommands()
commands = BotCommands()

View File

@ -28,18 +28,18 @@ class BotDatabase():
nick = Identifier(nick)
nick_id = bot.db.get_nick_id(nick, create=True)
if nick_id not in self.SpiceBot_Database["nicks"].keys():
self.SpiceBot_Database["nicks"][nick_id] = {}
if nick_id not in self.dict["nicks"].keys():
self.dict["nicks"][nick_id] = {}
if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if sorting_key not in self.dict["nicks"][nick_id].keys():
self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
self.lock.release()
if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys():
if key not in self.dict["nicks"][nick_id][sorting_key].keys():
return None
else:
return self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]
return self.dict["nicks"][nick_id][sorting_key][key]
def set_nick_value(self, bot, nick, key, value, sorting_key='unsorted'):
@ -48,15 +48,15 @@ class BotDatabase():
nick = Identifier(nick)
nick_id = bot.db.get_nick_id(nick, create=True)
if nick_id not in self.SpiceBot_Database["nicks"].keys():
self.SpiceBot_Database["nicks"][nick_id] = {}
if nick_id not in self.dict["nicks"].keys():
self.dict["nicks"][nick_id] = {}
if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if sorting_key not in self.dict["nicks"][nick_id].keys():
self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value
self.dict["nicks"][nick_id][sorting_key][key] = value
bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key])
bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key])
self.lock.release()
@ -67,14 +67,14 @@ class BotDatabase():
nick = Identifier(nick)
nick_id = bot.db.get_nick_id(nick, create=True)
if nick_id not in self.SpiceBot_Database["nicks"].keys():
self.SpiceBot_Database["nicks"][nick_id] = {}
if nick_id not in self.dict["nicks"].keys():
self.dict["nicks"][nick_id] = {}
if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if sorting_key not in self.dict["nicks"][nick_id].keys():
self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
del self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]
bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key])
del self.dict["nicks"][nick_id][sorting_key][key]
bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key])
self.lock.release()
@ -85,22 +85,22 @@ class BotDatabase():
nick = Identifier(nick)
nick_id = bot.db.get_nick_id(nick, create=True)
if nick_id not in self.SpiceBot_Database["nicks"].keys():
self.SpiceBot_Database["nicks"][nick_id] = {}
if nick_id not in self.dict["nicks"].keys():
self.dict["nicks"][nick_id] = {}
if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if sorting_key not in self.dict["nicks"][nick_id].keys():
self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys():
if key not in self.dict["nicks"][nick_id][sorting_key].keys():
oldvalue = []
else:
oldvalue = self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]
oldvalue = self.dict["nicks"][nick_id][sorting_key][key]
if not oldvalue:
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = value
self.dict["nicks"][nick_id][sorting_key][key] = value
else:
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = oldvalue + value
bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key])
self.dict["nicks"][nick_id][sorting_key][key] = oldvalue + value
bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key])
self.lock.release()
@ -114,24 +114,24 @@ class BotDatabase():
nick = Identifier(nick)
nick_id = bot.db.get_nick_id(nick, create=True)
if nick_id not in self.SpiceBot_Database["nicks"].keys():
self.SpiceBot_Database["nicks"][nick_id] = {}
if nick_id not in self.dict["nicks"].keys():
self.dict["nicks"][nick_id] = {}
if sorting_key not in self.SpiceBot_Database["nicks"][nick_id].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if sorting_key not in self.dict["nicks"][nick_id].keys():
self.dict["nicks"][nick_id][sorting_key] = bot.db.get_nick_value(nick, sorting_key) or dict()
if key not in self.SpiceBot_Database["nicks"][nick_id][sorting_key].keys():
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key] = []
if key not in self.dict["nicks"][nick_id][sorting_key].keys():
self.dict["nicks"][nick_id][sorting_key][key] = []
if adjustmentdirection == 'add':
for entry in entries:
if entry not in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]:
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].append(entry)
if entry not in self.dict["nicks"][nick_id][sorting_key][key]:
self.dict["nicks"][nick_id][sorting_key][key].append(entry)
elif adjustmentdirection == 'del':
for entry in entries:
while entry in self.SpiceBot_Database["nicks"][nick_id][sorting_key][key]:
self.SpiceBot_Database["nicks"][nick_id][sorting_key][key].remove(entry)
bot.db.set_nick_value(nick, sorting_key, self.SpiceBot_Database["nicks"][nick_id][sorting_key])
while entry in self.dict["nicks"][nick_id][sorting_key][key]:
self.dict["nicks"][nick_id][sorting_key][key].remove(entry)
bot.db.set_nick_value(nick, sorting_key, self.dict["nicks"][nick_id][sorting_key])
self.lock.release()
@ -143,18 +143,18 @@ class BotDatabase():
channel = Identifier(channel)
if channel not in self.SpiceBot_Database["channels"].keys():
self.SpiceBot_Database["channels"][channel] = {}
if channel not in self.dict["channels"].keys():
self.dict["channels"][channel] = {}
if sorting_key not in self.SpiceBot_Database["channels"][channel].keys():
self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if sorting_key not in self.dict["channels"][channel].keys():
self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
self.lock.release()
if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys():
if key not in self.dict["channels"][channel][sorting_key].keys():
return None
else:
return self.SpiceBot_Database["channels"][channel][sorting_key][key]
return self.dict["channels"][channel][sorting_key][key]
def set_channel_value(self, bot, channel, key, value, sorting_key='unsorted'):
@ -162,14 +162,14 @@ class BotDatabase():
channel = Identifier(channel)
if channel not in self.SpiceBot_Database["channels"].keys():
self.SpiceBot_Database["channels"][channel] = {}
if channel not in self.dict["channels"].keys():
self.dict["channels"][channel] = {}
if sorting_key not in self.SpiceBot_Database["channels"][channel].keys():
self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if sorting_key not in self.dict["channels"][channel].keys():
self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
self.SpiceBot_Database["channels"][channel][sorting_key][key] = value
bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key])
self.dict["channels"][channel][sorting_key][key] = value
bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key])
self.lock.release()
@ -179,14 +179,14 @@ class BotDatabase():
channel = Identifier(channel)
if channel not in self.SpiceBot_Database["channels"].keys():
self.SpiceBot_Database["channels"][channel] = {}
if channel not in self.dict["channels"].keys():
self.dict["channels"][channel] = {}
if sorting_key not in self.SpiceBot_Database["channels"][channel].keys():
self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if sorting_key not in self.dict["channels"][channel].keys():
self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
del self.SpiceBot_Database["channels"][channel][sorting_key][key]
bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key])
del self.dict["channels"][channel][sorting_key][key]
bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key])
self.lock.release()
@ -196,22 +196,22 @@ class BotDatabase():
channel = Identifier(channel)
if channel not in self.SpiceBot_Database["channels"].keys():
self.SpiceBot_Database["channels"][channel] = {}
if channel not in self.dict["channels"].keys():
self.dict["channels"][channel] = {}
if sorting_key not in self.SpiceBot_Database["channels"][channel].keys():
self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if sorting_key not in self.dict["channels"][channel].keys():
self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys():
if key not in self.dict["channels"][channel][sorting_key].keys():
oldvalue = None
else:
oldvalue = self.SpiceBot_Database["channels"][channel][sorting_key][key]
oldvalue = self.dict["channels"][channel][sorting_key][key]
if not oldvalue:
self.SpiceBot_Database["channels"][channel][sorting_key][key] = value
self.dict["channels"][channel][sorting_key][key] = value
else:
self.SpiceBot_Database["channels"][channel][sorting_key][key] = oldvalue + value
bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key])
self.dict["channels"][channel][sorting_key][key] = oldvalue + value
bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key])
self.lock.release()
@ -224,26 +224,26 @@ class BotDatabase():
channel = Identifier(channel)
if channel not in self.SpiceBot_Database["channels"].keys():
self.SpiceBot_Database["channels"][channel] = {}
if channel not in self.dict["channels"].keys():
self.dict["channels"][channel] = {}
if sorting_key not in self.SpiceBot_Database["channels"][channel].keys():
self.SpiceBot_Database["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if sorting_key not in self.dict["channels"][channel].keys():
self.dict["channels"][channel][sorting_key] = bot.db.get_channel_value(channel, sorting_key) or dict()
if key not in self.SpiceBot_Database["channels"][channel][sorting_key].keys():
self.SpiceBot_Database["channels"][channel][sorting_key][key] = []
if key not in self.dict["channels"][channel][sorting_key].keys():
self.dict["channels"][channel][sorting_key][key] = []
if adjustmentdirection == 'add':
for entry in entries:
if entry not in self.SpiceBot_Database["channels"][channel][sorting_key][key]:
self.SpiceBot_Database["channels"][channel][sorting_key][key].append(entry)
if entry not in self.dict["channels"][channel][sorting_key][key]:
self.dict["channels"][channel][sorting_key][key].append(entry)
elif adjustmentdirection == 'del':
for entry in entries:
while entry in self.SpiceBot_Database["channels"][channel][sorting_key][key]:
self.SpiceBot_Database["channels"][channel][sorting_key][key].remove(entry)
bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key])
while entry in self.dict["channels"][channel][sorting_key][key]:
self.dict["channels"][channel][sorting_key][key].remove(entry)
bot.db.set_channel_value(channel, sorting_key, self.dict["channels"][channel][sorting_key])
self.lock.release()
botdb = BotDatabase()
db = BotDatabase()

View File

@ -17,7 +17,7 @@ class BotEvents(object):
Events will be assigned a 4-digit number above 1000.
This allows you to do, ``@module.event(botevents.BOT_WELCOME)````
This allows you to do, ``@module.event(events.BOT_WELCOME)````
Triggers handled by this module will be processed immediately.
Others will be placed into a queue.
@ -43,8 +43,8 @@ class BotEvents(object):
def __getattr__(self, name):
''' will only get called for undefined attributes '''
eventnumber = max(list(self.SpiceBot_Events["assigned_IDs"].keys())) + 1
self.SpiceBot_Events["assigned_IDs"][eventnumber] = str(name)
eventnumber = max(list(self.dict["assigned_IDs"].keys())) + 1
self.dict["assigned_IDs"][eventnumber] = str(name)
setattr(self, name, str(eventnumber))
return str(eventnumber)
@ -53,7 +53,7 @@ class BotEvents(object):
if number in self.defaultevents:
self.dispatch(bot, pretriggerdict)
else:
self.SpiceBot_Events["trigger_queue"].append(pretriggerdict)
self.dict["trigger_queue"].append(pretriggerdict)
def dispatch(self, bot, pretriggerdict):
number = pretriggerdict["number"]
@ -72,37 +72,37 @@ class BotEvents(object):
else:
eventnumber = str(trigger.event)
message = trigger.args[1]
if eventnumber not in self.SpiceBot_Events["triggers_recieved"]:
self.SpiceBot_Events["triggers_recieved"][eventnumber] = []
self.SpiceBot_Events["triggers_recieved"][eventnumber].append(message)
if eventnumber not in self.dict["triggers_recieved"]:
self.dict["triggers_recieved"][eventnumber] = []
self.dict["triggers_recieved"][eventnumber].append(message)
def check(self, checklist):
if not isinstance(checklist, list):
checklist = [str(checklist)]
for number in checklist:
if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys():
if str(number) not in self.dict["triggers_recieved"].keys():
return False
return True
def startup_add(self, startlist):
if not isinstance(startlist, list):
startlist = [str(startlist)]
self.SpiceBot_Events["startup_required"].extend(startlist)
self.dict["startup_required"].extend(startlist)
def startup_check(self):
for number in self.SpiceBot_Events["startup_required"]:
if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys():
for number in self.dict["startup_required"]:
if str(number) not in self.dict["triggers_recieved"].keys():
return False
return True
def startup_debug(self):
not_done = []
for number in self.SpiceBot_Events["startup_required"]:
if str(number) not in self.SpiceBot_Events["triggers_recieved"].keys():
for number in self.dict["startup_required"]:
if str(number) not in self.dict["triggers_recieved"].keys():
not_done.append(int(number))
reference_not_done = []
for item in not_done:
reference_not_done.append(str(self.SpiceBot_Events["assigned_IDs"][item]))
reference_not_done.append(str(self.dict["assigned_IDs"][item]))
return reference_not_done
def check_ready(self, checklist):
@ -126,4 +126,4 @@ class BotEvents(object):
return actual_decorator
botevents = BotEvents()
events = BotEvents()

View File

@ -28,14 +28,14 @@ class BotLogs():
logmessage = logtitle + " " + logentry
if self.sopel_config["logging_channel"]:
self.SpiceBot_Logs["queue"].append(logmessage)
self.dict["queue"].append(logmessage)
if stdio:
sopel.tools.stderr(logmessage)
if logtype not in self.SpiceBot_Logs["list"].keys():
self.SpiceBot_Logs["list"][logtype] = []
self.SpiceBot_Logs["list"][logtype].append(logentry)
if logtype not in self.dict["list"].keys():
self.dict["list"][logtype] = []
self.dict["list"][logtype].append(logentry)
def get_logs(self):
return []
@ -43,7 +43,7 @@ class BotLogs():
def stdio_logs_fetch(self, bot):
stdio_ignore = []
for logtype in self.SpiceBot_Logs["list"].keys():
for logtype in self.dict["list"].keys():
stdio_ignore.append("[" + logtype + "]")
logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log')
@ -103,4 +103,4 @@ class BotLogs():
return pidnum
botlogs = BotLogs()
logs = BotLogs()

View File

@ -19,7 +19,7 @@ from pygit2 import clone_repository
import spicemanip
from .Logs import botlogs
from .Logs import logs
"""Variable References"""
@ -298,7 +298,7 @@ def spicebot_update(bot, deps=False):
if not os.path.exists(clonepath) or not os.path.isdir(clonepath):
os.system(clonepath)
botlogs.log('SpiceBot_Update', "Cloning to " + clonepath, True)
logs.log('SpiceBot_Update', "Cloning to " + clonepath, True)
clone_repository(str(bot.config.SpiceBot_Update.gitrepo + ".git"), clonepath, checkout_branch=bot.config.SpiceBot_Update.gitbranch)
@ -309,12 +309,12 @@ def spicebot_update(bot, deps=False):
# pipcommand += " git+" + str(bot.config.SpiceBot_Update.gitrepo) + "@" + str(bot.config.SpiceBot_Update.gitbranch)
pipcommand += " /tmp/SpiceBot/"
botlogs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True)
logs.log('SpiceBot_Update', "Running `" + pipcommand + "`", True)
# for line in os.popen(pipcommand).read().split('\n'):
# botlogs.log('SpiceBot_Update', " " + line)
# logs.log('SpiceBot_Update', " " + line)
os.system(pipcommand)
botlogs.log('SpiceBot_Update', "Deleting " + clonepath, True)
logs.log('SpiceBot_Update', "Deleting " + clonepath, True)
os.system("sudo rm -r /tmp/SpiceBot")
@ -330,10 +330,10 @@ def service_manip(bot, servicename, dowhat, log_from='service_manip'):
if str(dowhat) not in ["start", "stop", "restart"]:
return
try:
botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.")
logs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service.")
os.system("sudo service " + str(servicename) + " " + str(dowhat))
except Exception as e:
botlogs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e))
logs.log(log_from, str(dowhat).title() + "ing " + str(servicename) + ".service Failed: " + str(e))
"""Config Reading Functions"""
@ -365,7 +365,7 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File",
except Exception as e:
filereadgood = False
if bot:
botlogs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath))
logs.log(log_from, "Error loading %s: %s (%s)" % (configtypename, e, filepath))
dict_from_file = dict()
# Close File
inf.close()
@ -380,10 +380,10 @@ def read_directory_json_to_dict(bot, directories, configtypename="Config File",
if filecount:
if bot:
botlogs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename))
botlogs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True)
logs.log(log_from, 'Registered %d %s dict files,' % (filecount, configtypename))
logs.log(log_from, '%d %s dict files failed to load' % (fileopenfail, configtypename), True)
else:
if bot:
botlogs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename))
logs.log(log_from, "Warning: Couldn't load any %s dict files" % (configtypename))
return configs_dict

View File

@ -9,7 +9,7 @@ import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY])
@sopel.module.nickname_commands('(.*)')
def bot_command_nick(bot, trigger):
@ -21,13 +21,13 @@ def bot_command_nick(bot, trigger):
if triggercommand[0] == "?":
return
if triggercommand in SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys():
if triggercommand in SpiceBot.commands.dict['commands']["nickname"].keys():
return
triggerargs.insert(0, triggercommand)
fulltrigger = spicemanip.main(triggerargs, 0).lower()
if fulltrigger in SpiceBot.botcommands.SpiceBot_Commands['nickrules']:
if fulltrigger in SpiceBot.commands.dict['nickrules']:
return
if fulltrigger.lower().startswith("what is"):
@ -154,7 +154,7 @@ def bot_command_nick(bot, trigger):
else:
closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse')
closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.commands.dict['commands']["nickname"].keys(), 3, 'reverse')
if len(closestmatches):
closestmatches = spicemanip.main(closestmatches, "andlist")

View File

@ -9,7 +9,7 @@ import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED])
@sopel.module.nickname_commands('channels', 'channel')
def nickname_comand_channels(bot, trigger):
@ -29,14 +29,14 @@ def nickname_comand_channels(bot, trigger):
elif commandused == 'total':
botcount = len(bot.channels.keys())
servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
servercount = len(SpiceBot.channels.dict['list'].keys())
bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
return
elif commandused == 'random':
channel = spicemanip.main(SpiceBot.botchannels.SpiceBot_Channels['list'], 'random')
topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['topic']
msg = ["Random channel for you: {}.".format(SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['name'])]
channel = spicemanip.main(SpiceBot.channels.dict['list'], 'random')
topic = SpiceBot.channels.dict['list'][channel]['topic']
msg = ["Random channel for you: {}.".format(SpiceBot.channels.dict['list'][channel]['name'])]
if topic and not topic.isspace():
msg.append("The topic is: {}".format(topic))
else:
@ -48,15 +48,15 @@ def nickname_comand_channels(bot, trigger):
if not trigger.admin:
bot.osd("You do not have permission to update the channel listing.")
return
SpiceBot.botchannels.bot_part_empty(bot)
SpiceBot.botchannels.channel_list_request(bot)
SpiceBot.channels.bot_part_empty(bot)
SpiceBot.channels.channel_list_request(bot)
bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."])
while SpiceBot.botchannels.channel_lock:
while SpiceBot.channels.channel_lock:
pass
SpiceBot.botchannels.join_all_channels(bot)
foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
SpiceBot.channels.join_all_channels(bot)
foundchannelcount = len(SpiceBot.channels.dict['list'].keys())
bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
SpiceBot.botchannels.bot_part_empty(bot)
SpiceBot.channels.bot_part_empty(bot)
return
elif commandused == 'topic':
@ -64,11 +64,11 @@ def nickname_comand_channels(bot, trigger):
bot.osd("Channel name input missing.")
return
channel = spicemanip.main(triggerargs, 1)
if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel))
return
topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['topic']
channel = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['name']
topic = SpiceBot.channels.dict['list'][channel.lower()]['topic']
channel = SpiceBot.channels.dict['list'][channel.lower()]['name']
bot.osd("Topic for {}: {}".format(channel, topic))
return
@ -81,7 +81,7 @@ def nickname_comand_channels(bot, trigger):
channel = trigger.sender
else:
channel = spicemanip.main(triggerargs, 1)
if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel))
return
if not SpiceBot.inlist(channel.lower(), bot.channels.keys()):
@ -101,7 +101,7 @@ def nickname_comand_channels(bot, trigger):
# Users List
if commandused == 'users':
channel = spicemanip.main(triggerargs, 1)
if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
if not SpiceBot.inlist(channel.lower(), SpiceBot.channels.dict['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel))
return
if not SpiceBot.inlist(channel.lower(), bot.channels.keys()):

View File

@ -29,91 +29,91 @@ def configure(config):
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_Channels', "Starting setup procedure")
SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_CHANNELS])
SpiceBot.logs.log('SpiceBot_Channels', "Starting setup procedure")
SpiceBot.events.startup_add([SpiceBot.events.BOT_CHANNELS])
bot.config.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)
@sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def unkickable_bot(bot, trigger):
if bot.config.SpiceBot_Channels.operadmin:
bot.write(('SAMODE', bot.nick, '+q'))
@sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def request_channels_list_initial(bot, trigger):
SpiceBot.botchannels.bot_part_empty(bot)
SpiceBot.channels.bot_part_empty(bot)
SpiceBot.botlogs.log('SpiceBot_Channels', "Sending Request for all server channels")
SpiceBot.botchannels.channel_list_request(bot)
SpiceBot.logs.log('SpiceBot_Channels', "Sending Request for all server channels")
SpiceBot.channels.channel_list_request(bot)
starttime = time.time()
# wait 60 seconds for initial population of information
while not SpiceBot.botchannels.SpiceBot_Channels['InitialProcess']:
while not SpiceBot.channels.dict['InitialProcess']:
if time.time() - starttime >= 60:
SpiceBot.botlogs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out")
SpiceBot.botchannels.SpiceBot_Channels['InitialProcess'] = True
SpiceBot.logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out")
SpiceBot.channels.dict['InitialProcess'] = True
else:
pass
foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
SpiceBot.botlogs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
foundchannelcount = len(SpiceBot.channels.dict['list'].keys())
SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
SpiceBot.botchannels.join_all_channels(bot)
SpiceBot.botchannels.chanadmin_all_channels(bot)
SpiceBot.channels.join_all_channels(bot)
SpiceBot.channels.chanadmin_all_channels(bot)
if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys():
del SpiceBot.botchannels.SpiceBot_Channels['list']["*"]
if "*" in SpiceBot.channels.dict['list'].keys():
del SpiceBot.channels.dict['list']["*"]
SpiceBot.botchannels.bot_part_empty(bot)
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CHANNELS, "SpiceBot_Channels")
SpiceBot.channels.bot_part_empty(bot)
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CHANNELS, "SpiceBot_Channels")
@sopel.module.event('321')
@sopel.module.rule('.*')
def watch_chanlist_start(bot, trigger):
SpiceBot.botchannels.channel_list_recieve_start()
SpiceBot.channels.channel_list_recieve_start()
@sopel.module.event('322')
@sopel.module.rule('.*')
def watch_chanlist_populate(bot, trigger):
SpiceBot.botchannels.channel_list_recieve_input(trigger)
SpiceBot.channels.channel_list_recieve_input(trigger)
@sopel.module.event('323')
@sopel.module.rule('.*')
def watch_chanlist_complete(bot, trigger):
SpiceBot.botchannels.channel_list_recieve_finish()
SpiceBot.channels.channel_list_recieve_finish()
@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS)
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
@sopel.module.rule('.*')
def trigger_channel_list_recurring(bot, trigger):
while True:
time.sleep(1800)
SpiceBot.botchannels.bot_part_empty(bot)
SpiceBot.channels.bot_part_empty(bot)
oldlist = list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
SpiceBot.botchannels.channel_list_request(bot)
oldlist = list(SpiceBot.channels.dict['list'].keys())
SpiceBot.channels.channel_list_request(bot)
while SpiceBot.botchannels.channel_lock:
while SpiceBot.channels.channel_lock:
pass
newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())]
newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())]
if "*" in newlist:
newlist.remove("*")
if len(newlist) and bot.config.SpiceBot_Channels.announcenew:
bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys())
SpiceBot.botchannels.join_all_channels(bot)
SpiceBot.channels.join_all_channels(bot)
SpiceBot.botchannels.chanadmin_all_channels(bot)
SpiceBot.channels.chanadmin_all_channels(bot)
if "*" in SpiceBot.botchannels.SpiceBot_Channels['list'].keys():
del SpiceBot.botchannels.SpiceBot_Channels['list']["*"]
SpiceBot.botchannels.bot_part_empty(bot)
if "*" in SpiceBot.channels.dict['list'].keys():
del SpiceBot.channels.dict['list']["*"]
SpiceBot.channels.bot_part_empty(bot)

View File

@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot
import spicemanip
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
@sopel.module.nickname_commands('(.*)')
def query_detection_nick(bot, trigger):
@ -28,9 +28,9 @@ def query_detection_nick(bot, trigger):
return
commands_list = dict()
for com in SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'].keys():
for com in SpiceBot.commands.dict['commands']['nickname'].keys():
if com not in commands_list.keys():
commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'][com]
commands_list[com] = SpiceBot.commands.dict['commands']['nickname'][com]
if triggercommand.endswith("+"):

View File

@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot
import spicemanip
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
@sopel.module.rule('^\?(.*)')
def query_detection(bot, trigger):
@ -24,11 +24,11 @@ def query_detection(bot, trigger):
return
commands_list = dict()
for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
for commandstype in SpiceBot.commands.dict['commands'].keys():
if commandstype not in ['rule', 'nickname']:
for com in SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys():
for com in SpiceBot.commands.dict['commands'][commandstype].keys():
if com not in commands_list.keys():
commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype][com]
commands_list[com] = SpiceBot.commands.dict['commands'][commandstype][com]
if triggercommand[:-1] == "+":

View File

@ -16,7 +16,7 @@ import sopel_modules.SpiceBot as SpiceBot
def setup(bot):
# Inject Database Functions
SpiceBot.botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot")
SpiceBot.logs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot")
SopelDB.delete_nick_value = SopelDBCache.delete_nick_value
SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value
SopelDB.delete_channel_value = SopelDBCache.delete_channel_value

View File

@ -7,10 +7,10 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_WELCOME)
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
@sopel.module.rule('.*')
def bot_events_Connected(bot, trigger):
"""Here, we wait until we are in at least one channel"""
while not len(bot.channels.keys()) > 0:
pass
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_CONNECTED, "Bot Connected to IRC")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC")

View File

@ -7,9 +7,9 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def bot_startup_welcome(bot, trigger):
SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1
if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1:
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_RECONNECTED, "Bot ReConnected to IRC")
SpiceBot.events.dict["RPL_WELCOME_Count"] += 1
if SpiceBot.events.dict["RPL_WELCOME_Count"] > 1:
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_RECONNECTED, "Bot ReConnected to IRC")

View File

@ -7,9 +7,9 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.botevents.startup_check_ready()
@sopel.module.event(SpiceBot.botevents.BOT_READY)
@SpiceBot.events.startup_check_ready()
@sopel.module.event(SpiceBot.events.BOT_READY)
@sopel.module.rule('.*')
def bot_events_startup_complete(bot, trigger):
"""All events registered as required for startup have completed"""
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOADED, "All registered modules setup procedures have completed")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed")

View File

@ -7,8 +7,8 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_WELCOME, SpiceBot.botevents.BOT_READY, SpiceBot.botevents.BOT_CONNECTED, SpiceBot.botevents.BOT_LOADED)
@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED)
@sopel.module.rule('.*')
def bot_events_complete(bot, trigger):
"""This is here simply to log to stderr that this was recieved."""
SpiceBot.botlogs.log('SpiceBot_Events', trigger.args[1], True)
SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True)

View File

@ -7,12 +7,12 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_WELCOME)
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
@sopel.module.rule('.*')
def bot_events_connected(bot, trigger):
"""For items tossed in a queue, this will trigger them accordingly"""
while True:
if len(SpiceBot.botevents.SpiceBot_Events["trigger_queue"]):
pretriggerdict = SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0]
SpiceBot.botevents.dispatch(bot, pretriggerdict)
del SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0]
if len(SpiceBot.events.dict["trigger_queue"]):
pretriggerdict = SpiceBot.events.dict["trigger_queue"][0]
SpiceBot.events.dispatch(bot, pretriggerdict)
del SpiceBot.events.dict["trigger_queue"][0]

View File

@ -7,8 +7,8 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_WELCOME)
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
@sopel.module.rule('.*')
def bot_events_start(bot, trigger):
"""This stage is redundant, but shows the system is working."""
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_READY, "Ready To Process module setup procedures")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures")

View File

@ -7,11 +7,11 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def bot_startup_welcome(bot, trigger):
"""The Bot events system does not start until RPL_WELCOME 001 is recieved
from the server"""
if SpiceBot.botevents.check(SpiceBot.botevents.BOT_WELCOME):
if SpiceBot.events.check(SpiceBot.events.BOT_WELCOME):
return
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System")

View File

@ -11,7 +11,7 @@ import sopel_modules.SpiceBot as SpiceBot
import spicemanip
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
@module.commands('gif')
def gif_trigger(bot, trigger):

View File

@ -11,7 +11,7 @@ import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_GIFSEARCH])
@sopel.module.commands('(.*)')
def gifapi_triggers(bot, trigger):

View File

@ -42,8 +42,8 @@ def configure(config):
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure")
SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_GIFSEARCH])
SpiceBot.logs.log('SpiceBot_GifSearch', "Starting Setup Procedure")
SpiceBot.events.startup_add([SpiceBot.events.BOT_GIFSEARCH])
if 'SpiceBot_GifSearch' not in bot.memory:
bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}}
@ -70,12 +70,12 @@ def setup(bot):
bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api]
for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
SpiceBot.botcommands.commandsquery_register(bot, "prefix", validgifapi)
SpiceBot.commands.commandsquery_register(bot, "prefix", validgifapi)
if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys():
bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict()
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_GIFSEARCH, "SpiceBot_GifSearch")
def shutdown(bot):

View File

@ -17,14 +17,14 @@ def shutdown(bot):
del bot.memory["SpiceBot_InvalidCommand"]
@sopel.module.event(SpiceBot.botevents.BOT_LOADED)
@sopel.module.event(SpiceBot.events.BOT_LOADED)
@sopel.module.rule('.*')
def bot_events_complete(bot, trigger):
for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())
for comtype in SpiceBot.commands.dict['commands'].keys():
bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.commands.dict['commands'][comtype].keys())
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY])
@sopel.module.commands('(.*)')
def InvalidCommand_triggers(bot, trigger):
return

View File

@ -35,12 +35,12 @@ def configure(config):
def setup(bot):
# Inject KICK
SpiceBot.botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot")
SpiceBot.logs.log('SpiceBot_Kick', "Implanting Kick function into bot")
bot.kick = SopelKICK.kick
sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick
# verify config settings for server
SpiceBot.botlogs.log('SpiceBot_Kick', "Checking for config settings")
SpiceBot.logs.log('SpiceBot_Kick', "Checking for config settings")
bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOGS])
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS])
@sopel.module.nickname_commands('logs', 'debug')
def bot_command_logs(bot, trigger):
@ -20,11 +20,11 @@ def bot_command_logs(bot, trigger):
logtype = spicemanip.main(triggerargs, 1) or None
if not logtype:
bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action')
bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.logs.dict["list"].keys(), 'andlist'), trigger.sender, 'action')
return
if not SpiceBot.inlist(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()):
closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse')
if not SpiceBot.inlist(logtype, SpiceBot.logs.dict["list"].keys()):
closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.logs.dict["list"].keys(), 10, 'reverse')
if not len(closestmatches):
bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick)
else:
@ -32,14 +32,14 @@ def bot_command_logs(bot, trigger):
return
logtype = SpiceBot.inlist_match(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys())
logtype = SpiceBot.inlist_match(logtype, SpiceBot.logs.dict["list"].keys())
if logtype == "Sopel_systemd":
logindex = SpiceBot.botlogs.systemd_logs_fetch(bot)
logindex = SpiceBot.logs.systemd_logs_fetch(bot)
elif logtype == "Sopel_stdio":
logindex = SpiceBot.botlogs.stdio_logs_fetch(bot)
logindex = SpiceBot.logs.stdio_logs_fetch(bot)
else:
logindex = SpiceBot.botlogs.SpiceBot_Logs["list"][logtype]
logindex = SpiceBot.logs.dict["list"][logtype]
if not len(logindex):
bot.osd("No logs found for " + str(logtype) + ".")

View File

@ -9,12 +9,12 @@ import sopel_modules.SpiceBot as SpiceBot
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_Logs', "Starting Setup Procedure")
SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_LOGS])
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOGS, "SpiceBot_Logs")
SpiceBot.logs.log('SpiceBot_Logs', "Starting Setup Procedure")
SpiceBot.events.startup_add([SpiceBot.events.BOT_LOGS])
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOGS, "SpiceBot_Logs")
@sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def join_log_channel(bot, trigger):
@ -26,9 +26,9 @@ def join_log_channel(bot, trigger):
bot.write(('SAJOIN', bot.nick, channel))
while True:
if len(SpiceBot.botlogs.SpiceBot_Logs["queue"]):
bot.say(str(SpiceBot.botlogs.SpiceBot_Logs["queue"][0]), channel)
del SpiceBot.botlogs.SpiceBot_Logs["queue"][0]
if len(SpiceBot.logs.dict["queue"]):
bot.say(str(SpiceBot.logs.dict["queue"][0]), channel)
del SpiceBot.logs.dict["queue"][0]
else:
SpiceBot.botlogs.sopel_config["logging_channel"] = False
SpiceBot.botlogs.SpiceBot_Logs["queue"] = []
SpiceBot.logs.sopel_config["logging_channel"] = False
SpiceBot.logs.dict["queue"] = []

View File

@ -41,7 +41,7 @@ def bot_command_process(bot, trigger):
target = spicemanip.main(triggerargs, 1)
if (target not in ['allchans', 'allnicks']
and not SpiceBot.inlist(target.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
and not SpiceBot.inlist(target.lower(), SpiceBot.channels.dict['list'].keys())
and not SpiceBot.inlist(target.lower(), bot.users)):
bot.osd("Channel/nick name {} not valid.".format(target))
return

View File

@ -13,8 +13,8 @@ import spicemanip
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Starting setup procedure")
SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_COMMANDSQUERY])
SpiceBot.logs.log('SpiceBot_CommandsQuery', "Starting setup procedure")
SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY])
filepathlisting = []
@ -36,7 +36,7 @@ def setup(bot):
pypi_modules_dir = os.path.join(plugin_dir, pathname)
filepathlisting.append(pypi_modules_dir)
except Exception as e:
SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e))
SpiceBot.logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e))
# Extra directories
filepathlist = []
@ -120,7 +120,7 @@ def setup(bot):
currentsuccesslines += 1
if currentsuccesslines:
SpiceBot.botcommands.SpiceBot_Commands['counts'] += 1
SpiceBot.commands.dict['counts'] += 1
if len(filelinelist):
for atlinefound in filelinelist:
@ -140,27 +140,27 @@ def setup(bot):
else:
comaliases = []
SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][maincom] = dict_from_file
SpiceBot.commands.dict['commands'][comtype][maincom] = dict_from_file
for comalias in comaliases:
if comalias not in SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys():
SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype][comalias] = {"aliasfor": maincom}
if comalias not in SpiceBot.commands.dict['commands'][comtype].keys():
SpiceBot.commands.dict['commands'][comtype][comalias] = {"aliasfor": maincom}
for comtype in ['module', 'nickname', 'rule']:
SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True)
SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
for command in SpiceBot.botcommands.SpiceBot_Commands['commands']['rule'].keys():
for command in SpiceBot.commands.dict['commands']['rule'].keys():
if command.startswith("$nickname"):
command = command.split("$nickname")[-1]
if command not in SpiceBot.botcommands.SpiceBot_Commands['nickrules']:
SpiceBot.botcommands.SpiceBot_Commands['nickrules'].append(command)
if command not in SpiceBot.commands.dict['nickrules']:
SpiceBot.commands.dict['nickrules'].append(command)
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_CommandsQuery")
@sopel.module.event(SpiceBot.botevents.BOT_LOADED)
@sopel.module.event(SpiceBot.events.BOT_LOADED)
@sopel.module.rule('.*')
def bot_events_complete(bot, trigger):
for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
for comtype in SpiceBot.commands.dict['commands'].keys():
if comtype not in ['module', 'nickname', 'rule']:
SpiceBot.botlogs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())) + " " + comtype + " commands.", True)
SpiceBot.logs.log('SpiceBot_CommandsQuery', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)

View File

@ -15,7 +15,7 @@ def nickname_comand_restart(bot, trigger):
bot.say("You are not authorized to perform this function.")
quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!"
SpiceBot.botlogs.log('SpiceBot_Restart', quitmessage)
SpiceBot.logs.log('SpiceBot_Restart', quitmessage)
bot.osd(quitmessage, bot.channels.keys())
# service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart')

View File

@ -11,9 +11,9 @@ import sopel_modules.SpiceBot as SpiceBot
def setup(bot):
SpiceBot.botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks")
SpiceBot.logs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks")
if 'url_callbacks' not in bot.memory:
bot.memory['url_callbacks'] = sopel.tools.SopelMemory()
SpiceBot.botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.")
SpiceBot.logs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.")
SpiceBot.stock_modules_begone(bot)

View File

@ -8,8 +8,8 @@ import sopel_modules.SpiceBot as SpiceBot
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure")
SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED])
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure")
SpiceBot.events.startup_add([SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED])
if 'SpiceBot_StartupMonologue' not in bot.memory:
bot.memory['SpiceBot_StartupMonologue'] = []

View File

@ -7,13 +7,13 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_CHANNELS)
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
@sopel.module.rule('.*')
def bot_startup_monologue_channels(bot, trigger):
botcount = len(bot.channels.keys())
servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
servercount = len(SpiceBot.channels.dict['list'].keys())
bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
SpiceBot.logs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue")

View File

@ -7,16 +7,16 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_COMMANDSQUERY)
@sopel.module.event(SpiceBot.events.BOT_COMMANDSQUERY)
@sopel.module.rule('.*')
def bot_startup_monologue_commands(bot, trigger):
availablecomsnum, availablecomsfiles = 0, 0
for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
availablecomsnum += len(SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys())
availablecomsfiles += SpiceBot.botcommands.SpiceBot_Commands['counts']
for commandstype in SpiceBot.commands.dict['commands'].keys():
availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys())
availablecomsfiles += SpiceBot.commands.dict['counts']
bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
SpiceBot.logs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue")

View File

@ -7,12 +7,12 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_CONNECTED)
@sopel.module.event(SpiceBot.events.BOT_CONNECTED)
@sopel.module.rule('.*')
def bot_startup_monologue_start(bot, trigger):
# Startup
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration")
SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration")
bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION')
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")

View File

@ -6,11 +6,11 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.botevents.BOT_STARTUPMONOLOGUE)
@sopel.module.event(SpiceBot.events.BOT_STARTUPMONOLOGUE)
@sopel.module.rule('.*')
def bot_startup_monologue_start(bot, trigger):
debuglines = SpiceBot.botlogs.stdio_logs_fetch(bot)
debuglines = SpiceBot.logs.stdio_logs_fetch(bot)
searchphrasefound = []
for line in debuglines:
@ -19,9 +19,9 @@ def bot_startup_monologue_start(bot, trigger):
if len(searchphrasefound):
for foundphase in searchphrasefound:
SpiceBot.botlogs.log('SpiceBot_Logs', str(foundphase))
SpiceBot.logs.log('SpiceBot_Logs', str(foundphase))
searchphrasefound.insert(0, "Notice to Bot Admins: ")
searchphrasefound.append("Run the debug command for more information.")
bot.osd(searchphrasefound, bot.channels.keys())
else:
SpiceBot.botlogs.log('SpiceBot_Logs', "No issues found at bot startup!", True)
SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True)

View File

@ -9,19 +9,19 @@ import sopel_modules.SpiceBot as SpiceBot
import time
@sopel.module.event(SpiceBot.botevents.BOT_LOADED)
@sopel.module.event(SpiceBot.events.BOT_LOADED)
@sopel.module.rule('.*')
def bot_startup_monologue_display(bot, trigger):
if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] == 1:
if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1:
timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])
SpiceBot.bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince)
# Announce to chan, then handle some closing stuff
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete")
SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete")
bot.memory['SpiceBot_StartupMonologue'].insert(0, " startup complete")
bot.osd(bot.memory['SpiceBot_StartupMonologue'], bot.channels.keys(), 'ACTION')
SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue")
SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True)
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue")
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True)

View File

@ -23,7 +23,7 @@ def configure(config):
def setup(bot):
SpiceBot.botlogs.log('SpiceBot_Update', "Initial Setup processing")
SpiceBot.logs.log('SpiceBot_Update', "Initial Setup processing")
bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
@ -48,7 +48,7 @@ def nickname_comand_update(bot, trigger):
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
SpiceBot.botlogs.log('SpiceBot_Update', quitmessage)
SpiceBot.logs.log('SpiceBot_Update', quitmessage)
bot.osd(quitmessage, bot.channels.keys())
if commandused == 'nodeps':

View File

@ -12,7 +12,7 @@ import sopel_modules.SpiceBot as SpiceBot
def setup(bot):
if 'SpiceBot_Uptime' not in bot.memory:
now = time.time()
SpiceBot.botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time()))
SpiceBot.logs.log('SpiceBot_Uptime', "Start time set to " + str(time.time()))
bot.memory["SpiceBot_Uptime"] = now

View File

@ -40,7 +40,7 @@ def configure(config):
def setup(bot):
# Inject OSD
SpiceBot.botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot")
SpiceBot.logs.log('SpiceBot_OSD', "Implanting OSD function into bot")
bot.osd = SopelOSD.osd
sopel.bot.SopelWrapper.osd = SopelWrapperOSD.osd
tools.get_available_message_bytes = ToolsOSD.get_available_message_bytes
@ -48,7 +48,7 @@ def setup(bot):
tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups
# overwrite default bot messaging
SpiceBot.botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands")
SpiceBot.logs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands")
bot.osd = SopelOSD.osd
bot.say = SopelOSD.say
bot.action = SopelOSD.action
@ -61,7 +61,7 @@ def setup(bot):
sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply
# verify config settings for server
SpiceBot.botlogs.log('SpiceBot_OSD', "Checking for config settings")
SpiceBot.logs.log('SpiceBot_OSD', "Checking for config settings")
bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)