Tes alternate import method

This commit is contained in:
deathbybandaid 2019-05-22 11:22:59 -04:00
parent 66beaa969c
commit 417d941bfe
43 changed files with 445 additions and 488 deletions

View File

@ -70,6 +70,3 @@ class BotChannels():
bot.write(('SAMODE', channel, "+a", bot.nick)) bot.write(('SAMODE', channel, "+a", bot.nick))
else: else:
bot.part(channel) bot.part(channel)
botchannels = BotChannels()

View File

@ -51,6 +51,3 @@ class BotCommands():
for comalias in comaliases: for comalias in comaliases:
if comalias not in self.SpiceBot_Commands['commands'][command_type].keys(): if comalias not in self.SpiceBot_Commands['commands'][command_type].keys():
self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor} self.SpiceBot_Commands['commands'][command_type][comalias] = {"aliasfor": aliasfor}
botcommands = BotCommands()

View File

@ -246,6 +246,3 @@ class BotDatabase():
bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key]) bot.db.set_channel_value(channel, sorting_key, self.SpiceBot_Database["channels"][channel][sorting_key])
self.lock.release() self.lock.release()
botdb = BotDatabase()

View File

@ -124,6 +124,3 @@ class BotEvents(object):
return function(*args, **kwargs) return function(*args, **kwargs)
return _nop return _nop
return actual_decorator return actual_decorator
botevents = BotEvents()

View File

@ -12,7 +12,7 @@ import os
import spicemanip import spicemanip
class botlogs(): class BotLogs():
"""This Is a contained source of log information""" """This Is a contained source of log information"""
def __init__(self): def __init__(self):
self.SpiceBot_Logs = { self.SpiceBot_Logs = {
@ -43,7 +43,7 @@ class botlogs():
def stdio_logs_fetch(self, bot): def stdio_logs_fetch(self, bot):
stdio_ignore = [] stdio_ignore = []
for logtype in botlogs.SpiceBot_Logs["list"].keys(): for logtype in self.SpiceBot_Logs["list"].keys():
stdio_ignore.append("[" + logtype + "]") stdio_ignore.append("[" + logtype + "]")
logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log') logfile = os.path.os.path.join(bot.config.core.logdir, 'stdio.log')
@ -101,6 +101,3 @@ class botlogs():
pidnum = e pidnum = e
pidnum = str(os.popen("systemctl show " + str(bot.nick) + " --property=MainPID").read()).split("=")[-1] pidnum = str(os.popen("systemctl show " + str(bot.nick) + " --property=MainPID").read()).split("=")[-1]
return pidnum return pidnum
botlogs = botlogs()

View File

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

View File

@ -16,3 +16,10 @@ from .Database import *
__author__ = 'Sam Zick' __author__ = 'Sam Zick'
__email__ = 'sam@deathbybandaid.net' __email__ = 'sam@deathbybandaid.net'
__version__ = '0.1.1' __version__ = '0.1.1'
botdb = BotDatabase()
botchannels = BotChannels()
botcommands = BotCommands()
botevents = BotEvents()
botlogs = BotLogs()

View File

@ -6,16 +6,14 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, googlesearch, bot_privs, inlist, inlist_match, similar_list import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Commands import botcommands
@botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY])
@sopel.module.nickname_commands('(.*)') @sopel.module.nickname_commands('(.*)')
def bot_command_nick(bot, trigger): def bot_command_nick(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
if not triggercommand: if not triggercommand:
return return
@ -23,19 +21,19 @@ def bot_command_nick(bot, trigger):
if triggercommand[0] == "?": if triggercommand[0] == "?":
return return
if triggercommand in botcommands.SpiceBot_Commands['commands']["nickname"].keys(): if triggercommand in SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys():
return return
triggerargs.insert(0, triggercommand) triggerargs.insert(0, triggercommand)
fulltrigger = spicemanip.main(triggerargs, 0).lower() fulltrigger = spicemanip.main(triggerargs, 0).lower()
if fulltrigger in botcommands.SpiceBot_Commands['nickrules']: if fulltrigger in SpiceBot.botcommands.SpiceBot_Commands['nickrules']:
return return
if fulltrigger.lower().startswith("what is"): if fulltrigger.lower().startswith("what is"):
searchterm = spicemanip.main(triggerargs, "3+") or None searchterm = spicemanip.main(triggerargs, "3+") or None
if searchterm: if searchterm:
searchreturn = googlesearch(bot, searchterm) searchreturn = SpiceBot.googlesearch(bot, searchterm)
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') bot.osd('I cannot find anything about that')
else: else:
@ -50,7 +48,7 @@ def bot_command_nick(bot, trigger):
if searchterm.lower() in ['waldo', 'wally']: if searchterm.lower() in ['waldo', 'wally']:
bot.osd("He is hiding for a reason?") bot.osd("He is hiding for a reason?")
searchreturn = googlesearch(bot, "wimmelbilderbuch") searchreturn = SpiceBot.googlesearch(bot, "wimmelbilderbuch")
if searchreturn: if searchreturn:
bot.osd(str(searchreturn)) bot.osd(str(searchreturn))
return return
@ -59,7 +57,7 @@ def bot_command_nick(bot, trigger):
carmenlocale = ['ACME Headquarters', "Villains' International League of Evil"] carmenlocale = ['ACME Headquarters', "Villains' International League of Evil"]
bot.osd("Currently she is located at " + spicemanip.main(carmenlocale, 'random')) bot.osd("Currently she is located at " + spicemanip.main(carmenlocale, 'random'))
return return
searchreturn = googlesearch(bot, searchterm, 'maps') searchreturn = SpiceBot.googlesearch(bot, searchterm, 'maps')
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') bot.osd('I cannot find anything about that')
@ -102,7 +100,7 @@ def bot_command_nick(bot, trigger):
elif fulltrigger.lower().endswith(tuple(["order 66"])): elif fulltrigger.lower().endswith(tuple(["order 66"])):
if fulltrigger.lower() == "execute order 66": if fulltrigger.lower() == "execute order 66":
if inlist(trigger.nick, bot_privs(bot, 'owners')): if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')):
if trigger.is_privmsg: if trigger.is_privmsg:
jedi = None jedi = None
else: else:
@ -120,7 +118,7 @@ def bot_command_nick(bot, trigger):
bot.osd("I'm sure I don't know what you're talking about.") bot.osd("I'm sure I don't know what you're talking about.")
elif fulltrigger.lower() == "explain order 66": elif fulltrigger.lower() == "explain order 66":
if inlist(trigger.nick, bot_privs(bot, 'owners')): if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'owners')):
bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.") bot.osd("Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against my overlords and slay them.")
else: else:
bot.osd("I'm afraid I cannot tell you that, sir.") bot.osd("I'm afraid I cannot tell you that, sir.")
@ -129,7 +127,7 @@ def bot_command_nick(bot, trigger):
return return
elif fulltrigger.lower() == "initiate clean slate protocol": elif fulltrigger.lower() == "initiate clean slate protocol":
if inlist(trigger.nick, bot_privs(bot, 'admins')): if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs(bot, 'admins')):
bot.osd("sends a destruct command to the network of bots.", 'action') bot.osd("sends a destruct command to the network of bots.", 'action')
else: else:
bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".") bot.osd("I'm afraid you do not have the authority to make that call, " + trigger.nick + ".")
@ -143,10 +141,10 @@ def bot_command_nick(bot, trigger):
if target in [trigger.nick, 'me']: if target in [trigger.nick, 'me']:
bot.osd(trigger.nick + ", I can see you.") bot.osd(trigger.nick + ", I can see you.")
else: else:
if inlist(trigger.nick, bot.users): if SpiceBot.inlist(trigger.nick, bot.users):
bot.osd(trigger.nick + ", yes. I can see " + inlist_match(target, bot.users) + " right now!") bot.osd(trigger.nick + ", yes. I can see " + SpiceBot.inlist_match(target, bot.users) + " right now!")
else: else:
bot.osd(trigger.nick + ", no. I cannot see " + inlist_match(target, bot.users) + " right now!") bot.osd(trigger.nick + ", no. I cannot see " + SpiceBot.inlist_match(target, bot.users) + " right now!")
# if bot_check_inlist(target, bot.memory["botdict"]["users"].keys()): # if bot_check_inlist(target, bot.memory["botdict"]["users"].keys()):
# bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.") # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.")
# else: # else:
@ -156,7 +154,7 @@ def bot_command_nick(bot, trigger):
else: else:
closestmatches = similar_list(bot, triggercommand, botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse') closestmatches = SpiceBot.similar_list(bot, triggercommand, SpiceBot.botcommands.SpiceBot_Commands['commands']["nickname"].keys(), 3, 'reverse')
if len(closestmatches): if len(closestmatches):
closestmatches = spicemanip.main(closestmatches, "andlist") closestmatches = spicemanip.main(closestmatches, "andlist")

View File

@ -6,7 +6,7 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, bot_privs import sopel_modules.SpiceBot as SpiceBot
@sopel.module.nickname_commands('owners', 'owner') @sopel.module.nickname_commands('owners', 'owner')
@ -20,10 +20,10 @@ def bot_command_admins(bot, trigger):
def bot_command_process(bot, trigger): def bot_command_process(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
if triggercommand == 'owner': if triggercommand == 'owner':
triggercommand = 'owners' triggercommand = 'owners'
privlist = spicemanip.main(bot_privs(bot, triggercommand), 'andlist') privlist = spicemanip.main(SpiceBot.bot_privs(bot, triggercommand), 'andlist')
bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist) bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist)

View File

@ -6,16 +6,14 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Channels import botchannels
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, inlist, channel_privs
@botevents.check_ready([botevents.BOT_LOADED]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED])
@sopel.module.nickname_commands('channels', 'channel') @sopel.module.nickname_commands('channels', 'channel')
def nickname_comand_channels(bot, trigger): def nickname_comand_channels(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
if not len(triggerargs): if not len(triggerargs):
commandused = 'list' commandused = 'list'
@ -31,14 +29,14 @@ def nickname_comand_channels(bot, trigger):
elif commandused == 'total': elif commandused == 'total':
botcount = len(bot.channels.keys()) botcount = len(bot.channels.keys())
servercount = len(botchannels.SpiceBot_Channels['list'].keys()) servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
return return
elif commandused == 'random': elif commandused == 'random':
channel = spicemanip.main(botchannels.SpiceBot_Channels['list'], 'random') channel = spicemanip.main(SpiceBot.botchannels.SpiceBot_Channels['list'], 'random')
topic = botchannels.SpiceBot_Channels['list'][channel]['topic'] topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['topic']
msg = ["Random channel for you: {}.".format(botchannels.SpiceBot_Channels['list'][channel]['name'])] msg = ["Random channel for you: {}.".format(SpiceBot.botchannels.SpiceBot_Channels['list'][channel]['name'])]
if topic and not topic.isspace(): if topic and not topic.isspace():
msg.append("The topic is: {}".format(topic)) msg.append("The topic is: {}".format(topic))
else: else:
@ -50,15 +48,15 @@ def nickname_comand_channels(bot, trigger):
if not trigger.admin: if not trigger.admin:
bot.osd("You do not have permission to update the channel listing.") bot.osd("You do not have permission to update the channel listing.")
return return
botchannels.bot_part_empty(bot) SpiceBot.botchannels.bot_part_empty(bot)
botchannels.channel_list_request(bot) SpiceBot.botchannels.channel_list_request(bot)
bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."]) bot.osd(["[SpiceBot_Channels]", "I am now updating the channel listing for this server."])
while botchannels.channel_lock: while SpiceBot.botchannels.channel_lock:
pass pass
botchannels.join_all_channels(bot) SpiceBot.botchannels.join_all_channels(bot)
foundchannelcount = len(botchannels.SpiceBot_Channels['list'].keys()) foundchannelcount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.")
botchannels.bot_part_empty(bot) SpiceBot.botchannels.bot_part_empty(bot)
return return
elif commandused == 'topic': elif commandused == 'topic':
@ -66,11 +64,11 @@ def nickname_comand_channels(bot, trigger):
bot.osd("Channel name input missing.") bot.osd("Channel name input missing.")
return return
channel = spicemanip.main(triggerargs, 1) channel = spicemanip.main(triggerargs, 1)
if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel)) bot.osd("Channel name {} not valid.".format(channel))
return return
topic = botchannels.SpiceBot_Channels['list'][channel.lower()]['topic'] topic = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['topic']
channel = botchannels.SpiceBot_Channels['list'][channel.lower()]['name'] channel = SpiceBot.botchannels.SpiceBot_Channels['list'][channel.lower()]['name']
bot.osd("Topic for {}: {}".format(channel, topic)) bot.osd("Topic for {}: {}".format(channel, topic))
return return
@ -83,14 +81,14 @@ def nickname_comand_channels(bot, trigger):
channel = trigger.sender channel = trigger.sender
else: else:
channel = spicemanip.main(triggerargs, 1) channel = spicemanip.main(triggerargs, 1)
if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel)) bot.osd("Channel name {} not valid.".format(channel))
return return
if not inlist(channel.lower(), bot.channels.keys()): if not SpiceBot.inlist(channel.lower(), bot.channels.keys()):
bot.osd("I need to be in {} to see nick privileges.".format(channel)) bot.osd("I need to be in {} to see nick privileges.".format(channel))
return return
privlist = channel_privs(bot, channel, commandused.upper()) privlist = SpiceBot.channel_privs(bot, channel, commandused.upper())
dispmsg = [] dispmsg = []
if not len(privlist): if not len(privlist):
dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel))
@ -103,10 +101,10 @@ def nickname_comand_channels(bot, trigger):
# Users List # Users List
if commandused == 'users': if commandused == 'users':
channel = spicemanip.main(triggerargs, 1) channel = spicemanip.main(triggerargs, 1)
if not inlist(channel.lower(), botchannels.SpiceBot_Channels['list'].keys()): if not SpiceBot.inlist(channel.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys()):
bot.osd("Channel name {} not valid.".format(channel)) bot.osd("Channel name {} not valid.".format(channel))
return return
if not inlist(channel.lower(), bot.channels.keys()): if not SpiceBot.inlist(channel.lower(), bot.channels.keys()):
bot.osd("I need to be in {} to see user list.".format(channel)) bot.osd("I need to be in {} to see user list.".format(channel))
return return
dispmsg = [] dispmsg = []

View File

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

View File

@ -5,19 +5,16 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel import sopel
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Commands import botcommands
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string
import spicemanip import spicemanip
@botevents.check_ready([botevents.BOT_COMMANDSQUERY]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY])
@sopel.module.nickname_commands('(.*)') @sopel.module.nickname_commands('(.*)')
def query_detection_nick(bot, trigger): def query_detection_nick(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
# command issued, check if valid # command issued, check if valid
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
@ -27,13 +24,13 @@ def query_detection_nick(bot, trigger):
return return
triggercommand = triggercommand[1:] triggercommand = triggercommand[1:]
if not letters_in_string(triggercommand): if not SpiceBot.letters_in_string(triggercommand):
return return
commands_list = dict() commands_list = dict()
for com in botcommands.SpiceBot_Commands['commands']['nickname'].keys(): for com in SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'].keys():
if com not in commands_list.keys(): if com not in commands_list.keys():
commands_list[com] = botcommands.SpiceBot_Commands['commands']['nickname'][com] commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands']['nickname'][com]
if triggercommand.endswith("+"): if triggercommand.endswith("+"):
@ -43,7 +40,7 @@ def query_detection_nick(bot, trigger):
if triggercommand.lower() not in list(commands_list.keys()): if triggercommand.lower() not in list(commands_list.keys()):
dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(triggercommand) + "."] dispmsg = ["Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(triggercommand) + "."]
closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
if len(closestmatches): if len(closestmatches):
dispmsg.append("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") dispmsg.append("The following " + bot.nick + " commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
bot.notice(dispmsg, trigger.nick) bot.notice(dispmsg, trigger.nick)
@ -62,7 +59,7 @@ def query_detection_nick(bot, trigger):
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
return return
closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(triggercommand) + ".", trigger.nick) bot.notice("Cannot find any similar " + bot.nick + " commands for " + str(triggercommand) + ".", trigger.nick)
else: else:

View File

@ -5,33 +5,30 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel import sopel
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Commands import botcommands
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, similar_list, letters_in_string
import spicemanip import spicemanip
@botevents.check_ready([botevents.BOT_COMMANDSQUERY]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_COMMANDSQUERY])
@sopel.module.rule('^\?(.*)') @sopel.module.rule('^\?(.*)')
def query_detection(bot, trigger): def query_detection(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'query_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'query_command')
# command issued, check if valid # command issued, check if valid
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
return return
if not letters_in_string(triggercommand): if not SpiceBot.letters_in_string(triggercommand):
return return
commands_list = dict() commands_list = dict()
for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
if commandstype not in ['rule', 'nickname']: if commandstype not in ['rule', 'nickname']:
for com in botcommands.SpiceBot_Commands['commands'][commandstype].keys(): for com in SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys():
if com not in commands_list.keys(): if com not in commands_list.keys():
commands_list[com] = botcommands.SpiceBot_Commands['commands'][commandstype][com] commands_list[com] = SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype][com]
if triggercommand[:-1] == "+": if triggercommand[:-1] == "+":
@ -41,7 +38,7 @@ def query_detection(bot, trigger):
if triggercommand.lower() not in list(commands_list.keys()): if triggercommand.lower() not in list(commands_list.keys()):
dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."] dispmsg = ["Cannot find any alias commands: No valid commands match " + str(triggercommand) + "."]
closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
if len(closestmatches): if len(closestmatches):
dispmsg.append("The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".") dispmsg.append("The following commands match " + str(triggercommand) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
bot.notice(dispmsg, trigger.nick) bot.notice(dispmsg, trigger.nick)
@ -60,7 +57,7 @@ def query_detection(bot, trigger):
if not triggercommand or not len(triggercommand): if not triggercommand or not len(triggercommand):
return return
closestmatches = similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse') closestmatches = SpiceBot.similar_list(bot, triggercommand, list(commands_list.keys()), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick) bot.notice("Cannot find any similar commands for " + str(triggercommand) + ".", trigger.nick)
else: else:

View File

@ -10,13 +10,13 @@ from sopel.db import SopelDB, NickValues, ChannelValues
from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.exc import SQLAlchemyError
import json import json
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
def setup(bot): def setup(bot):
# Inject Database Functions # Inject Database Functions
botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot") SpiceBot.botlogs.log('SpiceBot_Databaseaddons', "Implanting Database functions into bot")
SopelDB.delete_nick_value = SopelDBCache.delete_nick_value SopelDB.delete_nick_value = SopelDBCache.delete_nick_value
SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value SopelDB.adjust_nick_value = SopelDBCache.adjust_nick_value
SopelDB.delete_channel_value = SopelDBCache.delete_channel_value SopelDB.delete_channel_value = SopelDBCache.delete_channel_value

View File

@ -4,9 +4,13 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Tools import github_dict import sopel_modules.SpiceBot as SpiceBot
@sopel.module.nickname_commands('help', 'docs', 'wiki') @sopel.module.nickname_commands('help', 'docs', 'wiki')
def bot_command_owners(bot, trigger): def bot_command_owners(bot, trigger):
bot.osd(["IRC Modules Repository", str(github_dict["url_main"] + github_dict["repo_owner"] + "/" + github_dict["repo_name"] + github_dict["url_path_wiki"])]) bot.osd(["IRC Modules Repository",
str(SpiceBot.github_dict["url_main"] +
SpiceBot.github_dict["repo_owner"] + "/" +
SpiceBot.github_dict["repo_name"] +
SpiceBot.github_dict["url_path_wiki"])])

View File

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

View File

@ -4,12 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(botevents.RPL_WELCOME) @sopel.module.event(SpiceBot.botevents.RPL_WELCOME)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_welcome(bot, trigger): def bot_startup_welcome(bot, trigger):
botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1 SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] += 1
if botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1: if SpiceBot.botevents.SpiceBot_Events["RPL_WELCOME_Count"] > 1:
botevents.trigger(bot, botevents.BOT_RECONNECTED, "Bot ReConnected to IRC") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_RECONNECTED, "Bot ReConnected to IRC")

View File

@ -4,12 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
@botevents.startup_check_ready() @SpiceBot.botevents.startup_check_ready()
@sopel.module.event(botevents.BOT_READY) @sopel.module.event(SpiceBot.botevents.BOT_READY)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_startup_complete(bot, trigger): def bot_events_startup_complete(bot, trigger):
"""All events registered as required for startup have completed""" """All events registered as required for startup have completed"""
botevents.trigger(bot, botevents.BOT_LOADED, "All registered modules setup procedures have completed") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_LOADED, "All registered modules setup procedures have completed")

View File

@ -4,12 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
@sopel.module.event(botevents.BOT_WELCOME, botevents.BOT_READY, botevents.BOT_CONNECTED, botevents.BOT_LOADED) @sopel.module.event(SpiceBot.botevents.BOT_WELCOME, SpiceBot.botevents.BOT_READY, SpiceBot.botevents.BOT_CONNECTED, SpiceBot.botevents.BOT_LOADED)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_complete(bot, trigger): def bot_events_complete(bot, trigger):
"""This is here simply to log to stderr that this was recieved.""" """This is here simply to log to stderr that this was recieved."""
botlogs.log('SpiceBot_Events', trigger.args[1], True) SpiceBot.botlogs.log('SpiceBot_Events', trigger.args[1], True)

View File

@ -4,15 +4,15 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(botevents.BOT_WELCOME) @sopel.module.event(SpiceBot.botevents.BOT_WELCOME)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_connected(bot, trigger): def bot_events_connected(bot, trigger):
"""For items tossed in a queue, this will trigger them accordingly""" """For items tossed in a queue, this will trigger them accordingly"""
while True: while True:
if len(botevents.SpiceBot_Events["trigger_queue"]): if len(SpiceBot.botevents.SpiceBot_Events["trigger_queue"]):
pretriggerdict = botevents.SpiceBot_Events["trigger_queue"][0] pretriggerdict = SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0]
botevents.dispatch(bot, pretriggerdict) SpiceBot.botevents.dispatch(bot, pretriggerdict)
del botevents.SpiceBot_Events["trigger_queue"][0] del SpiceBot.botevents.SpiceBot_Events["trigger_queue"][0]

View File

@ -4,11 +4,11 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Events import botevents import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(botevents.BOT_WELCOME) @sopel.module.event(SpiceBot.botevents.BOT_WELCOME)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_start(bot, trigger): def bot_events_start(bot, trigger):
"""This stage is redundant, but shows the system is working.""" """This stage is redundant, but shows the system is working."""
botevents.trigger(bot, botevents.BOT_READY, "Ready To Process module setup procedures") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_READY, "Ready To Process module setup procedures")

View File

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

View File

@ -6,17 +6,16 @@ from sopel import module
from .gifsearch import getGif from .gifsearch import getGif
from sopel_modules.SpiceBot.Tools import sopel_triggerargs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
import spicemanip import spicemanip
@botevents.check_ready([botevents.BOT_GIFSEARCH]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH])
@module.commands('gif') @module.commands('gif')
def gif_trigger(bot, trigger): def gif_trigger(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger) triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger)
if not len(triggerargs): if not len(triggerargs):
return bot.osd("Please present a query to search.") return bot.osd("Please present a query to search.")

View File

@ -8,15 +8,14 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Tools import sopel_triggerargs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
@botevents.check_ready([botevents.BOT_GIFSEARCH]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_GIFSEARCH])
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def gifapi_triggers(bot, trigger): def gifapi_triggers(bot, trigger):
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command')
if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys(): if triggercommand not in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
return return

View File

@ -5,10 +5,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel.config.types import StaticSection, ValidatedAttribute from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Commands import botcommands
from sopel_modules.SpiceBot.Tools import read_directory_json_to_dict
import spicemanip import spicemanip
@ -32,7 +29,7 @@ class GifAPISection(StaticSection):
def configure(config): def configure(config):
moduledir = os.path.dirname(os.path.abspath(__file__)) moduledir = os.path.dirname(os.path.abspath(__file__))
api_dir = os.path.join(moduledir, 'gifapi') api_dir = os.path.join(moduledir, 'gifapi')
valid_gif_api_dict = read_directory_json_to_dict(None, [api_dir], "Gif API", "SpiceBot_GifSearch") valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(None, [api_dir], "Gif API", "SpiceBot_GifSearch")
config.define_section("SopelGifSearch", GifAPIMainSection, validate=False) config.define_section("SopelGifSearch", GifAPIMainSection, validate=False)
config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory') config.SopelGifSearch.configure_setting('extra', 'SpiceBot_GifSearch API Extra directory')
@ -45,8 +42,8 @@ def configure(config):
def setup(bot): def setup(bot):
botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure") SpiceBot.botlogs.log('SpiceBot_GifSearch', "Starting Setup Procedure")
botevents.startup_add([botevents.BOT_GIFSEARCH]) SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_GIFSEARCH])
if 'SpiceBot_GifSearch' not in bot.memory: if 'SpiceBot_GifSearch' not in bot.memory:
bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}} bot.memory["SpiceBot_GifSearch"] = {"cache": {}, "badgiflinks": [], 'valid_gif_api_dict': {}}
@ -61,7 +58,7 @@ def setup(bot):
if bot.config.SopelGifSearch.extra: if bot.config.SopelGifSearch.extra:
dir_to_scan.append(bot.config.SopelGifSearch.extra) dir_to_scan.append(bot.config.SopelGifSearch.extra)
valid_gif_api_dict = read_directory_json_to_dict(bot, dir_to_scan, "Gif API", "SpiceBot_GifSearch") valid_gif_api_dict = SpiceBot.read_directory_json_to_dict(bot, dir_to_scan, "Gif API", "SpiceBot_GifSearch")
for gif_api in valid_gif_api_dict.keys(): for gif_api in valid_gif_api_dict.keys():
bot.config.define_section(gif_api, GifAPISection, validate=False) bot.config.define_section(gif_api, GifAPISection, validate=False)
@ -73,12 +70,12 @@ def setup(bot):
bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'][gif_api] = valid_gif_api_dict[gif_api] 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(): for validgifapi in bot.memory["SpiceBot_GifSearch"]['valid_gif_api_dict'].keys():
botcommands.commandsquery_register(bot, "prefix", validgifapi) SpiceBot.botcommands.commandsquery_register(bot, "prefix", validgifapi)
if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys(): if validgifapi not in bot.memory["SpiceBot_GifSearch"]['cache'].keys():
bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict() bot.memory["SpiceBot_GifSearch"]['cache'][validgifapi] = dict()
botevents.trigger(bot, botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_GIFSEARCH, "SpiceBot_GifSearch")
def shutdown(bot): def shutdown(bot):

View File

@ -4,9 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Tools import sopel_triggerargs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Commands import botcommands
def setup(bot): def setup(bot):
@ -19,19 +17,19 @@ def shutdown(bot):
del bot.memory["SpiceBot_InvalidCommand"] del bot.memory["SpiceBot_InvalidCommand"]
@sopel.module.event(botevents.BOT_LOADED) @sopel.module.event(SpiceBot.botevents.BOT_LOADED)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_events_complete(bot, trigger): def bot_events_complete(bot, trigger):
for comtype in botcommands.SpiceBot_Commands['commands'].keys(): for comtype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(botcommands.SpiceBot_Commands['commands'][comtype].keys()) bot.memory["SpiceBot_InvalidCommand"]["valid"].extend(SpiceBot.botcommands.SpiceBot_Commands['commands'][comtype].keys())
@botevents.check_ready([botevents.BOT_LOADED, botevents.BOT_COMMANDSQUERY]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOADED, SpiceBot.botevents.BOT_COMMANDSQUERY])
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def InvalidCommand_triggers(bot, trigger): def InvalidCommand_triggers(bot, trigger):
return return
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'prefix_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'prefix_command')
# patch for people typing "...", maybe other stuff, but this verifies that there is still a command here # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here
if triggercommand.startswith("."): if triggercommand.startswith("."):

View File

@ -14,7 +14,7 @@ from sopel import tools, module
from sopel.tools import Identifier from sopel.tools import Identifier
from sopel.config.types import StaticSection, ValidatedAttribute from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
import time import time
@ -35,12 +35,12 @@ def configure(config):
def setup(bot): def setup(bot):
# Inject KICK # Inject KICK
botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot") SpiceBot.botlogs.log('SpiceBot_Kick', "Implanting Kick function into bot")
bot.kick = SopelKICK.kick bot.kick = SopelKICK.kick
sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick sopel.bot.SopelWrapper.kick = SopelWrapperKICK.kick
# verify config settings for server # verify config settings for server
botlogs.log('SpiceBot_Kick', "Checking for config settings") SpiceBot.botlogs.log('SpiceBot_Kick', "Checking for config settings")
bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False) bot.config.define_section("SpiceBot_Kick", SpiceBot_Kick, validate=False)

File diff suppressed because it is too large Load Diff

View File

@ -5,28 +5,26 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist, inlist_match, similar_list
@botevents.check_ready([botevents.BOT_LOGS]) @SpiceBot.botevents.check_ready([SpiceBot.botevents.BOT_LOGS])
@sopel.module.nickname_commands('logs', 'debug') @sopel.module.nickname_commands('logs', 'debug')
def bot_command_logs(bot, trigger): def bot_command_logs(bot, trigger):
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.say("I was unable to process this Bot Nick command due to privilege issues.") bot.say("I was unable to process this Bot Nick command due to privilege issues.")
return return
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
logtype = spicemanip.main(triggerargs, 1) or None logtype = spicemanip.main(triggerargs, 1) or None
if not logtype: if not logtype:
bot.osd("Current valid log(s) include: " + spicemanip.main(botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action') bot.osd("Current valid log(s) include: " + spicemanip.main(SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 'andlist'), trigger.sender, 'action')
return return
if not inlist(logtype, botlogs.SpiceBot_Logs["list"].keys()): if not SpiceBot.inlist(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys()):
closestmatches = similar_list(bot, logtype, botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse') closestmatches = SpiceBot.similar_list(bot, logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys(), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick) bot.notice("No valid logs match " + str(logtype) + ".", trigger.nick)
else: else:
@ -34,14 +32,14 @@ def bot_command_logs(bot, trigger):
return return
logtype = inlist_match(logtype, botlogs.SpiceBot_Logs["list"].keys()) logtype = SpiceBot.inlist_match(logtype, SpiceBot.botlogs.SpiceBot_Logs["list"].keys())
if logtype == "Sopel_systemd": if logtype == "Sopel_systemd":
logindex = botlogs.systemd_logs_fetch(bot) logindex = SpiceBot.botlogs.systemd_logs_fetch(bot)
elif logtype == "Sopel_stdio": elif logtype == "Sopel_stdio":
logindex = botlogs.stdio_logs_fetch(bot) logindex = SpiceBot.botlogs.stdio_logs_fetch(bot)
else: else:
logindex = botlogs.SpiceBot_Logs["list"][logtype] logindex = SpiceBot.botlogs.SpiceBot_Logs["list"][logtype]
if not len(logindex): if not len(logindex):
bot.osd("No logs found for " + str(logtype) + ".") bot.osd("No logs found for " + str(logtype) + ".")

View File

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

View File

@ -6,8 +6,7 @@ import sopel.module
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Channels import botchannels import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, inlist
@sopel.module.nickname_commands('action') @sopel.module.nickname_commands('action')
@ -27,11 +26,11 @@ def bot_command_privmsg(bot, trigger):
def bot_command_process(bot, trigger): def bot_command_process(bot, trigger):
if not command_permissions_check(bot, trigger, ['admins', 'owner']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']):
bot.say("I was unable to process this Bot Nick command due to privilege issues.") bot.say("I was unable to process this Bot Nick command due to privilege issues.")
return return
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
if triggercommand in ['say', 'msg']: if triggercommand in ['say', 'msg']:
triggercommand = 'privmsg' triggercommand = 'privmsg'
@ -42,8 +41,8 @@ def bot_command_process(bot, trigger):
target = spicemanip.main(triggerargs, 1) target = spicemanip.main(triggerargs, 1)
if (target not in ['allchans', 'allnicks'] if (target not in ['allchans', 'allnicks']
and not inlist(target.lower(), botchannels.SpiceBot_Channels['list'].keys()) and not SpiceBot.inlist(target.lower(), SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
and not inlist(target.lower(), bot.users)): and not SpiceBot.inlist(target.lower(), bot.users)):
bot.osd("Channel/nick name {} not valid.".format(target)) bot.osd("Channel/nick name {} not valid.".format(target))
return return

View File

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

View File

@ -5,8 +5,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports # sopel imports
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Tools import spicebot_reload
@sopel.module.nickname_commands('restart') @sopel.module.nickname_commands('restart')
@ -16,8 +15,8 @@ def nickname_comand_restart(bot, trigger):
bot.say("You are not authorized to perform this function.") bot.say("You are not authorized to perform this function.")
quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!"
botlogs.log('SpiceBot_Restart', quitmessage) SpiceBot.botlogs.log('SpiceBot_Restart', quitmessage)
bot.osd(quitmessage, bot.channels.keys()) bot.osd(quitmessage, bot.channels.keys())
# service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart') # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Restart')
spicebot_reload(bot, 'SpiceBot_Restart', quitmessage) SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage)

View File

@ -6,15 +6,14 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
import sopel import sopel
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Tools import stock_modules_begone
def setup(bot): def setup(bot):
botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") SpiceBot.botlogs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks")
if 'url_callbacks' not in bot.memory: if 'url_callbacks' not in bot.memory:
bot.memory['url_callbacks'] = sopel.tools.SopelMemory() bot.memory['url_callbacks'] = sopel.tools.SopelMemory()
botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") SpiceBot.botlogs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.")
stock_modules_begone(bot) SpiceBot.stock_modules_begone(bot)

View File

@ -4,13 +4,12 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
def setup(bot): def setup(bot):
botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure") SpiceBot.botlogs.log('SpiceBot_StartupMonologue', "Starting setup procedure")
botevents.startup_add([botevents.BOT_STARTUPMONOLOGUE_CHANNELS, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # , botevents.BOT_STARTUPMONOLOGUE_CONNECTED]) SpiceBot.botevents.startup_add([SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY]) # ,SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED])
if 'SpiceBot_StartupMonologue' not in bot.memory: if 'SpiceBot_StartupMonologue' not in bot.memory:
bot.memory['SpiceBot_StartupMonologue'] = [] bot.memory['SpiceBot_StartupMonologue'] = []

View File

@ -4,18 +4,16 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Channels import botchannels
@sopel.module.event(botevents.BOT_CHANNELS) @sopel.module.event(SpiceBot.botevents.BOT_CHANNELS)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_channels(bot, trigger): def bot_startup_monologue_channels(bot, trigger):
botcount = len(bot.channels.keys()) botcount = len(bot.channels.keys())
servercount = len(botchannels.SpiceBot_Channels['list'].keys()) servercount = len(SpiceBot.botchannels.SpiceBot_Channels['list'].keys())
bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
botlogs.log('SpiceBot_StartupMonologue', "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.")
botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue")

View File

@ -4,21 +4,19 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
from sopel_modules.SpiceBot.Commands import botcommands
@sopel.module.event(botevents.BOT_COMMANDSQUERY) @sopel.module.event(SpiceBot.botevents.BOT_COMMANDSQUERY)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_commands(bot, trigger): def bot_startup_monologue_commands(bot, trigger):
availablecomsnum, availablecomsfiles = 0, 0 availablecomsnum, availablecomsfiles = 0, 0
for commandstype in botcommands.SpiceBot_Commands['commands'].keys(): for commandstype in SpiceBot.botcommands.SpiceBot_Commands['commands'].keys():
availablecomsnum += len(botcommands.SpiceBot_Commands['commands'][commandstype].keys()) availablecomsnum += len(SpiceBot.botcommands.SpiceBot_Commands['commands'][commandstype].keys())
availablecomsfiles += botcommands.SpiceBot_Commands['counts'] availablecomsfiles += SpiceBot.botcommands.SpiceBot_Commands['counts']
bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.") bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
botlogs.log('SpiceBot_StartupMonologue', "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.")
botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue")

View File

@ -4,16 +4,15 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module import sopel.module
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Events import botevents
@sopel.module.event(botevents.BOT_CONNECTED) @sopel.module.event(SpiceBot.botevents.BOT_CONNECTED)
@sopel.module.rule('.*') @sopel.module.rule('.*')
def bot_startup_monologue_start(bot, trigger): def bot_startup_monologue_start(bot, trigger):
# Startup # Startup
botlogs.log('SpiceBot_StartupMonologue', bot.nick + " is now starting. Please wait while I load my configuration") SpiceBot.botlogs.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') bot.osd(" is now starting. Please wait while I load my configuration.", bot.channels.keys(), 'ACTION')
botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") SpiceBot.botevents.trigger(bot, SpiceBot.botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")

View File

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

View File

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

View File

@ -8,8 +8,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute
import spicemanip import spicemanip
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Tools import sopel_triggerargs, command_permissions_check, spicebot_reload, spicebot_update
class SpiceBot_Update_MainSection(StaticSection): class SpiceBot_Update_MainSection(StaticSection):
@ -24,18 +23,18 @@ def configure(config):
def setup(bot): def setup(bot):
botlogs.log('SpiceBot_Update', "Initial Setup processing") SpiceBot.botlogs.log('SpiceBot_Update', "Initial Setup processing")
bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False) bot.config.define_section("SpiceBot_Update", SpiceBot_Update_MainSection, validate=False)
@sopel.module.nickname_commands('update') @sopel.module.nickname_commands('update')
def nickname_comand_update(bot, trigger): def nickname_comand_update(bot, trigger):
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.say("I was unable to process this Bot Nick command due to privilege issues.") bot.say("I was unable to process this Bot Nick command due to privilege issues.")
return return
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command') triggerargs, triggercommand = SpiceBot.sopel_triggerargs(bot, trigger, 'nickname_command')
if not len(triggerargs): if not len(triggerargs):
commandused = 'nodeps' commandused = 'nodeps'
@ -49,13 +48,13 @@ def nickname_comand_update(bot, trigger):
triggerargs = spicemanip.main(triggerargs, '2+', 'list') triggerargs = spicemanip.main(triggerargs, '2+', 'list')
quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" quitmessage = "Received command from " + trigger.nick + " to update from Github and restart"
botlogs.log('SpiceBot_Update', quitmessage) SpiceBot.botlogs.log('SpiceBot_Update', quitmessage)
bot.osd(quitmessage, bot.channels.keys()) bot.osd(quitmessage, bot.channels.keys())
if commandused == 'nodeps': if commandused == 'nodeps':
spicebot_update(bot, False) SpiceBot.spicebot_update(bot, False)
if commandused == 'deps': if commandused == 'deps':
spicebot_update(bot, True) SpiceBot.spicebot_update(bot, True)
# service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update') # service_manip(bot, bot.nick, 'restart', 'SpiceBot_Update')
spicebot_reload(bot, 'SpiceBot_Update', quitmessage) SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage)

View File

@ -6,14 +6,13 @@ import sopel.module
import time import time
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
from sopel_modules.SpiceBot.Tools import humanized_time
def setup(bot): def setup(bot):
if 'SpiceBot_Uptime' not in bot.memory: if 'SpiceBot_Uptime' not in bot.memory:
now = time.time() now = time.time()
botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time())) SpiceBot.botlogs.log('SpiceBot_Uptime', "Start time set to " + str(time.time()))
bot.memory["SpiceBot_Uptime"] = now bot.memory["SpiceBot_Uptime"] = now
@ -24,5 +23,5 @@ def shutdown(bot):
@sopel.module.nickname_commands('uptime') @sopel.module.nickname_commands('uptime')
def bot_command_srewyou(bot, trigger): def bot_command_srewyou(bot, trigger):
timesince = str(humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago." timesince = str(SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])) + " ago."
bot.osd("I have been running since " + timesince) bot.osd("I have been running since " + timesince)

View File

@ -14,7 +14,7 @@ from sopel import tools, module
from sopel.tools import Identifier from sopel.tools import Identifier
from sopel.config.types import StaticSection, ValidatedAttribute from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot.Logs import botlogs import sopel_modules.SpiceBot as SpiceBot
import time import time
from collections import abc from collections import abc
@ -40,7 +40,7 @@ def configure(config):
def setup(bot): def setup(bot):
# Inject OSD # Inject OSD
botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot") SpiceBot.botlogs.log('SpiceBot_OSD', "Implanting OSD function into bot")
bot.osd = SopelOSD.osd bot.osd = SopelOSD.osd
sopel.bot.SopelWrapper.osd = SopelWrapperOSD.osd sopel.bot.SopelWrapper.osd = SopelWrapperOSD.osd
tools.get_available_message_bytes = ToolsOSD.get_available_message_bytes 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 tools.get_message_recipientgroups = ToolsOSD.get_message_recipientgroups
# overwrite default bot messaging # overwrite default bot messaging
botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands") SpiceBot.botlogs.log('SpiceBot_OSD', "Overwrite Default Sopel messaging commands")
bot.osd = SopelOSD.osd bot.osd = SopelOSD.osd
bot.say = SopelOSD.say bot.say = SopelOSD.say
bot.action = SopelOSD.action bot.action = SopelOSD.action
@ -61,7 +61,7 @@ def setup(bot):
sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply sopel.bot.SopelWrapper.reply = SopelWrapperOSD.reply
# verify config settings for server # verify config settings for server
botlogs.log('SpiceBot_OSD', "Checking for config settings") SpiceBot.botlogs.log('SpiceBot_OSD', "Checking for config settings")
bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False) bot.config.define_section("SpiceBot_OSD", SpiceBot_OSD, validate=False)