This commit is contained in:
deathbybandaid 2019-05-31 13:19:56 -04:00
parent 73101943d2
commit 4642d784e4

View File

@ -8,9 +8,17 @@ import sopel
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def bot_events_connected(bot, trigger):
# Handling for connection count
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")
else:
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System")
"""For items tossed in a queue, this will trigger them accordingly"""
while True:
if len(SpiceBot.events.dict["trigger_queue"]):
@ -19,26 +27,12 @@ def bot_events_connected(bot, trigger):
del SpiceBot.events.dict["trigger_queue"][0]
@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.events.check(SpiceBot.events.BOT_WELCOME):
return
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System")
@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.events.trigger(bot, SpiceBot.events.BOT_READY, "Ready To Process module setup procedures")
@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
@ -51,11 +45,3 @@ def bot_events_Connected(bot, trigger):
def bot_events_startup_complete(bot, trigger):
"""All events registered as required for startup have completed"""
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_LOADED, "All registered modules setup procedures have completed")
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
@sopel.module.rule('.*')
def bot_startup_reconnect(bot, trigger):
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")