test own event decorator

This commit is contained in:
deathbybandaid 2019-05-16 14:37:45 -04:00
parent 7dc5782969
commit 94dd65136f
3 changed files with 29 additions and 6 deletions

View File

@ -32,6 +32,17 @@ def configure(config):
config.SpiceBot_Channels.configure_setting('chanignore', 'SpiceBot_Channels Ignore JOIN for channels')
class BotChannels():
"""This Logs all channels known to the server"""
def __init__(self):
self.SpiceBot_Channels = {
"list": {}
}
botchannels = BotChannels()
def setup(bot):
bot_logging(bot, 'SpiceBot_Channels', "Starting setup procedure")
botevents.startup_add([botevents.BOT_CHANNELS])

View File

@ -11,7 +11,7 @@ from sopel_modules.SpiceBot_SBTools import bot_logging
import time
@sopel.module.event('001')
@botevents.event('001')
@sopel.module.rule('.*')
def bot_startup_connection(bot, trigger):
botevents.trigger(bot, botevents.BOT_WELCOME, "Welcome to the SpiceBot Events System")
@ -21,7 +21,7 @@ def bot_startup_connection(bot, trigger):
botevents.trigger(bot, botevents.BOT_CONNECTED, "Bot Connected to IRC")
@sopel.module.event(botevents.BOT_WELCOME)
@botevents.event(botevents.BOT_WELCOME)
@sopel.module.rule('.*')
def bot_events_start(bot, trigger):
bot_logging(bot, 'SpiceBot_Events', trigger.args[1], True)
@ -30,20 +30,20 @@ def bot_events_start(bot, trigger):
@botevents.startup_check_ready()
@sopel.module.event(botevents.BOT_READY)
@botevents.event(botevents.BOT_READY)
@sopel.module.rule('.*')
def bot_events_startup_complete(bot, trigger):
botevents.trigger(bot, botevents.BOT_LOADED, "All registered modules setup procedures have completed")
@sopel.module.event(botevents.BOT_READY)
@botevents.event(botevents.BOT_READY)
@sopel.module.rule('.*')
def bot_events_ready(bot, trigger):
bot_logging(bot, 'SpiceBot_Events', trigger.args[1], True)
botevents.recieved(trigger)
@sopel.module.event(botevents.BOT_CONNECTED)
@botevents.event(botevents.BOT_CONNECTED)
@sopel.module.rule('.*')
def bot_events_connected(bot, trigger):
bot_logging(bot, 'SpiceBot_Events', trigger.args[1], True)
@ -60,7 +60,7 @@ def bot_events_connected(bot, trigger):
del botevents.SpiceBot_Events["trigger_queue"][0]
@sopel.module.event(botevents.BOT_LOADED)
@botevents.event(botevents.BOT_LOADED)
@sopel.module.rule('.*')
def bot_events_complete(bot, trigger):
bot_logging(bot, 'SpiceBot_Events', trigger.args[1], True)

View File

@ -96,6 +96,18 @@ class BotEvents(object):
return _nop
return actual_decorator
def event(self, *event_list):
def actual_decorator(function):
@functools.wraps(function)
def add_attribute(function):
if not hasattr(function, "event"):
function.event = []
function.event.extend(event_list)
self.recieved(function)
return function
return add_attribute
return actual_decorator
botevents = BotEvents()