diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display.py deleted file mode 100644 index 1756770..0000000 --- a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display.py +++ /dev/null @@ -1,67 +0,0 @@ -# coding=utf-8 - -from __future__ import unicode_literals, absolute_import, division, print_function - -import sopel.module - -from sopel_modules.SpiceBot.Logs import botlogs -from sopel_modules.SpiceBot.Events import botevents -from sopel_modules.SpiceBot.Channels import botchannels -from sopel_modules.SpiceBot_SBTools import humanized_time - -import time - - -@sopel.module.event(botevents.BOT_CONNECTED) -@sopel.module.rule('.*') -def bot_startup_monologue_start(bot, trigger): - - # Startup - 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') - - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") - - -@sopel.module.event(botevents.BOT_COMMANDSQUERY) -@sopel.module.rule('.*') -def bot_startup_monologue_commands(bot, trigger): - - availablecomsnum, availablecomsfiles = 0, 0 - for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): - availablecomsnum += len(bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys()) - availablecomsfiles += bot.memory['SpiceBot_CommandsQuery']['counts'] - - 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.") - - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") - - -@sopel.module.event(botevents.BOT_CHANNELS) -@sopel.module.rule('.*') -def bot_startup_monologue_channels(bot, trigger): - - botcount = len(bot.channels.keys()) - servercount = len(botchannels.SpiceBot_Channels['list'].keys()) - 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.") - - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") - - -@sopel.module.event(botevents.BOT_LOADED) -@sopel.module.rule('.*') -def bot_startup_monologue_display(bot, trigger): - - timesince = humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) - bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) - - # Announce to chan, then handle some closing stuff - botlogs.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') - - botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") - botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py new file mode 100644 index 0000000..b8254be --- /dev/null +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Channels.py @@ -0,0 +1,21 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Channels import botchannels + + +@sopel.module.event(botevents.BOT_CHANNELS) +@sopel.module.rule('.*') +def bot_startup_monologue_channels(bot, trigger): + + botcount = len(bot.channels.keys()) + servercount = len(botchannels.SpiceBot_Channels['list'].keys()) + 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.") + + botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py new file mode 100644 index 0000000..3cae22e --- /dev/null +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Commands.py @@ -0,0 +1,23 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents + + +@sopel.module.event(botevents.BOT_COMMANDSQUERY) +@sopel.module.rule('.*') +def bot_startup_monologue_commands(bot, trigger): + + availablecomsnum, availablecomsfiles = 0, 0 + for commandstype in bot.memory['SpiceBot_CommandsQuery']['commands'].keys(): + availablecomsnum += len(bot.memory['SpiceBot_CommandsQuery']['commands'][commandstype].keys()) + availablecomsfiles += bot.memory['SpiceBot_CommandsQuery']['counts'] + + 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.") + + botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py new file mode 100644 index 0000000..e829d82 --- /dev/null +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Connected.py @@ -0,0 +1,19 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents + + +@sopel.module.event(botevents.BOT_CONNECTED) +@sopel.module.rule('.*') +def bot_startup_monologue_start(bot, trigger): + + # Startup + 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') + + botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue") diff --git a/sopel_modules/SpiceBot_StartupMonologue/ErrorDisplay.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py similarity index 100% rename from sopel_modules/SpiceBot_StartupMonologue/ErrorDisplay.py rename to sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Errors.py diff --git a/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py new file mode 100644 index 0000000..cdf704f --- /dev/null +++ b/sopel_modules/SpiceBot_StartupMonologue/StartupMonologue_Display_Loaded.py @@ -0,0 +1,29 @@ +# coding=utf-8 + +from __future__ import unicode_literals, absolute_import, division, print_function + +import sopel.module + +from sopel_modules.SpiceBot.Logs import botlogs +from sopel_modules.SpiceBot.Events import botevents +from sopel_modules.SpiceBot.Channels import botchannels +from sopel_modules.SpiceBot_SBTools import humanized_time + +import time + + +@sopel.module.event(botevents.BOT_LOADED) +@sopel.module.rule('.*') +def bot_startup_monologue_display(bot, trigger): + + timesince = humanized_time(time.time() - bot.memory["SpiceBot_Uptime"]) + bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince) + + # Announce to chan, then handle some closing stuff + botlogs.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') + + botevents.trigger(bot, botevents.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") + botlogs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True) diff --git a/sopel_modules/SpiceBot_StartupMonologue/__init__.py b/sopel_modules/SpiceBot_StartupMonologue/__init__.py index c656a51..8ab7cf1 100644 --- a/sopel_modules/SpiceBot_StartupMonologue/__init__.py +++ b/sopel_modules/SpiceBot_StartupMonologue/__init__.py @@ -6,8 +6,11 @@ Sopel Startup Monologue displays to all channels that the bot is online from __future__ import unicode_literals, absolute_import, division, print_function from .StartupMonologue import * -from .StartupMonologue_Display import * -from .ErrorDisplay import * +from .StartupMonologue_Display_Channels import * +from .StartupMonologue_Display_Commands import * +from .StartupMonologue_Display_Connected import * +from .StartupMonologue_Display_Loaded import * +from .StartupMonologue_Display_Errors import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net'