mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-11 06:00:59 -05:00
Events: Start Migration from bot.memory to Event Numbers
This commit is contained in:
parent
ce1c0df70e
commit
0df9847286
@ -1,75 +0,0 @@
|
||||
# coding=utf8
|
||||
"""Sopel_BotEvents
|
||||
|
||||
Sopel BotEvents is a poor mans way to create module load order dependencies
|
||||
"""
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.module
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging
|
||||
import threading
|
||||
|
||||
|
||||
def configure(config):
|
||||
pass
|
||||
|
||||
|
||||
def setup(bot):
|
||||
# TODO add custom pretrigger events
|
||||
bot_logging(bot, 'Sopel_BotEvents', "Starting Module Events Logging")
|
||||
|
||||
threading.Thread(target=setup_thread, args=(bot,)).start()
|
||||
|
||||
|
||||
def shutdown(bot):
|
||||
if "Sopel_BotEvents" in bot.memory:
|
||||
del bot.memory["Sopel_BotEvents"]
|
||||
|
||||
|
||||
def setup_thread(bot):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
|
||||
|
||||
def list_bot_events(bot, list_type):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
return bot.memory["Sopel_BotEvents"][list_type]
|
||||
|
||||
|
||||
def check_bot_events(bot, listreq):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(listreq, list):
|
||||
listreq = [str(listreq)]
|
||||
for requirement in listreq:
|
||||
if requirement not in bot.memory["Sopel_BotEvents"]["loaded"]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def set_bot_event(bot, addonreq):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(addonreq, list):
|
||||
addonreq = [str(addonreq)]
|
||||
|
||||
bot.memory["Sopel_BotEvents"]["loaded"].extend(addonreq)
|
||||
|
||||
|
||||
def startup_bot_event(bot, addonreq):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(addonreq, list):
|
||||
addonreq = [str(addonreq)]
|
||||
|
||||
bot.memory["Sopel_BotEvents"]["startup"].extend(addonreq)
|
||||
|
||||
|
||||
def check_bot_startup(bot):
|
||||
if "Sopel_BotEvents" not in bot.memory:
|
||||
bot.memory["Sopel_BotEvents"] = {"loaded": [], "startup": []}
|
||||
for startupitem in bot.memory["Sopel_BotEvents"]["startup"]:
|
||||
if startupitem not in bot.memory["Sopel_BotEvents"]["loaded"]:
|
||||
return False
|
||||
return True
|
||||
@ -6,7 +6,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
|
||||
import sopel.module
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
|
||||
|
||||
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, startup_bot_event
|
||||
from sopel_modules.SpiceBot_LoadOrder.LoadOrder import set_bot_event, startup_bot_event
|
||||
|
||||
import time
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ from operator import itemgetter
|
||||
import threading
|
||||
|
||||
|
||||
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events, bot_logging
|
||||
from sopel_modules.SpiceBot_LoadOrder.LoadOrder import set_bot_event, check_bot_events, bot_logging
|
||||
|
||||
import spicemanip
|
||||
|
||||
|
||||
@ -21,6 +21,6 @@ def bot_trigger_simulator(bot, trigger):
|
||||
def bot_event_trigger_create(bot, number, message):
|
||||
pretrigger = sopel.trigger.PreTrigger(
|
||||
bot.nick,
|
||||
":SpiceBot_Event " + str(number) + " " + str(bot.nick) + " :" + message
|
||||
":SpiceBot_Events " + str(number) + " " + str(bot.nick) + " :" + message
|
||||
)
|
||||
bot.dispatch(pretrigger)
|
||||
@ -1,7 +1,7 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .Pretrigger import *
|
||||
from .Events import *
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
@ -5,7 +5,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
import sopel.module
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
|
||||
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, startup_bot_event
|
||||
from sopel_modules.SpiceBot_LoadOrder.LoadOrder import set_bot_event, startup_bot_event
|
||||
|
||||
from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register, commandsquery_register_type
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.module
|
||||
from .BotEvents import check_bot_events, startup_bot_event, set_bot_event
|
||||
from .LoadOrder import check_bot_events, startup_bot_event, set_bot_event
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging
|
||||
|
||||
import time
|
||||
@ -22,4 +22,4 @@ def bot_startup_connection(bot, trigger):
|
||||
time.sleep(1)
|
||||
|
||||
set_bot_event(bot, "connected")
|
||||
bot_logging(bot, 'Sopel_BotEvents', "Connected to IRC")
|
||||
bot_logging(bot, 'Sopel_LoadOrder', "Connected to IRC")
|
||||
75
sopel_modules/SpiceBot_LoadOrder/LoadOrder.py
Normal file
75
sopel_modules/SpiceBot_LoadOrder/LoadOrder.py
Normal file
@ -0,0 +1,75 @@
|
||||
# coding=utf8
|
||||
"""Sopel_LoadOrder
|
||||
|
||||
Sopel LoadOrder is a poor mans way to create module load order dependencies
|
||||
"""
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
import sopel.module
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging
|
||||
import threading
|
||||
|
||||
|
||||
def configure(config):
|
||||
pass
|
||||
|
||||
|
||||
def setup(bot):
|
||||
# TODO add custom pretrigger events
|
||||
bot_logging(bot, 'Sopel_LoadOrder', "Starting Module Events Logging")
|
||||
|
||||
threading.Thread(target=setup_thread, args=(bot,)).start()
|
||||
|
||||
|
||||
def shutdown(bot):
|
||||
if "Sopel_LoadOrder" in bot.memory:
|
||||
del bot.memory["Sopel_LoadOrder"]
|
||||
|
||||
|
||||
def setup_thread(bot):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
|
||||
|
||||
def list_bot_events(bot, list_type):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
return bot.memory["Sopel_LoadOrder"][list_type]
|
||||
|
||||
|
||||
def check_bot_events(bot, listreq):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(listreq, list):
|
||||
listreq = [str(listreq)]
|
||||
for requirement in listreq:
|
||||
if requirement not in bot.memory["Sopel_LoadOrder"]["loaded"]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def set_bot_event(bot, addonreq):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(addonreq, list):
|
||||
addonreq = [str(addonreq)]
|
||||
|
||||
bot.memory["Sopel_LoadOrder"]["loaded"].extend(addonreq)
|
||||
|
||||
|
||||
def startup_bot_event(bot, addonreq):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
if not isinstance(addonreq, list):
|
||||
addonreq = [str(addonreq)]
|
||||
|
||||
bot.memory["Sopel_LoadOrder"]["startup"].extend(addonreq)
|
||||
|
||||
|
||||
def check_bot_startup(bot):
|
||||
if "Sopel_LoadOrder" not in bot.memory:
|
||||
bot.memory["Sopel_LoadOrder"] = {"loaded": [], "startup": []}
|
||||
for startupitem in bot.memory["Sopel_LoadOrder"]["startup"]:
|
||||
if startupitem not in bot.memory["Sopel_LoadOrder"]["loaded"]:
|
||||
return False
|
||||
return True
|
||||
@ -5,7 +5,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
import sopel.module
|
||||
from sopel_modules.SpiceBot_SBTools import bot_logging
|
||||
|
||||
from .BotEvents import set_bot_event, check_bot_startup
|
||||
from .LoadOrder import set_bot_event, check_bot_startup
|
||||
|
||||
|
||||
@sopel.module.event('001')
|
||||
@ -16,4 +16,4 @@ def bot_startup_complete(bot, trigger):
|
||||
pass
|
||||
|
||||
set_bot_event(bot, "startup_complete")
|
||||
bot_logging(bot, 'Sopel_BotEvents', "Module Events Logging Complete")
|
||||
bot_logging(bot, 'Sopel_LoadOrder', "Module Events Logging Complete")
|
||||
@ -1,11 +1,11 @@
|
||||
# coding=utf8
|
||||
"""Sopel_BotEvents
|
||||
"""Sopel_LoadOrder
|
||||
|
||||
Sopel BotEvents is a poor mans way to create module load order dependencies
|
||||
Sopel LoadOrder is a poor mans way to create module load order dependencies
|
||||
"""
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
|
||||
from .BotEvents import *
|
||||
from .LoadOrder import *
|
||||
from .Connected import *
|
||||
from .Startup_Complete import *
|
||||
|
||||
@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
|
||||
from sopel import module
|
||||
|
||||
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events
|
||||
from sopel_modules.SpiceBot_LoadOrder.LoadOrder import set_bot_event, check_bot_events
|
||||
|
||||
from sopel_modules.SpiceBot_SBTools import humanized_time, bot_logging
|
||||
import time
|
||||
|
||||
Loading…
Reference in New Issue
Block a user