mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 14:39:54 -05:00
channel and events
This commit is contained in:
parent
b9ba45122b
commit
e5bea4ea9c
@ -29,6 +29,9 @@ class BotCommands():
|
|||||||
},
|
},
|
||||||
'disabled': {}
|
'disabled': {}
|
||||||
}
|
}
|
||||||
|
self.module_files_parse()
|
||||||
|
for comtype in ['module', 'nickname', 'rule']:
|
||||||
|
logs.log('SpiceBot_Commands', "Found " + str(len(self.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
||||||
|
|
||||||
def find_command_type(self, command):
|
def find_command_type(self, command):
|
||||||
for commandstype in self.dict['commands'].keys():
|
for commandstype in self.dict['commands'].keys():
|
||||||
@ -129,7 +132,7 @@ class BotCommands():
|
|||||||
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:
|
||||||
logs.log('SpiceBot_CommandsQuery', "sopel_modules not loaded :" + str(e))
|
logs.log('SpiceBOT_COMMANDS', "sopel_modules not loaded :" + str(e))
|
||||||
|
|
||||||
# Extra directories
|
# Extra directories
|
||||||
for directory in botconfig.extra:
|
for directory in botconfig.extra:
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import spicemanip
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED, SpiceBot.events.BOT_COMMANDS])
|
||||||
@SpiceBot.prerun.prerun('nickname')
|
@SpiceBot.prerun.prerun('nickname')
|
||||||
@sopel.module.nickname_commands('(.*)')
|
@sopel.module.nickname_commands('(.*)')
|
||||||
def bot_command_nick(bot, trigger):
|
def bot_command_nick(bot, trigger):
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import spicemanip
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
||||||
@SpiceBot.prerun.prerun('nickname')
|
@SpiceBot.prerun.prerun('nickname')
|
||||||
@sopel.module.nickname_commands('(.*)')
|
@sopel.module.nickname_commands('(.*)')
|
||||||
def query_detection_nick(bot, trigger):
|
def query_detection_nick(bot, trigger):
|
||||||
@ -78,7 +78,7 @@ def query_detection_nick(bot, trigger):
|
|||||||
bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
bot.osd("The following " + bot.nick + " commands start with " + str(trigger.sb['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
|
||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDSQUERY])
|
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
|
||||||
@SpiceBot.prerun.prerun('query')
|
@SpiceBot.prerun.prerun('query')
|
||||||
@sopel.module.rule('^\?(.*)')
|
@sopel.module.rule('^\?(.*)')
|
||||||
def query_detection(bot, trigger):
|
def query_detection(bot, trigger):
|
||||||
|
|||||||
68
sopel_modules/SpiceBot_Core_Processing/Events.py
Normal file
68
sopel_modules/SpiceBot_Core_Processing/Events.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot Channels system.
|
||||||
|
"""
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_events_connected(bot, trigger):
|
||||||
|
"""For items tossed in a queue, this will trigger them accordingly"""
|
||||||
|
while True:
|
||||||
|
if len(SpiceBot.events.dict["trigger_queue"]):
|
||||||
|
pretriggerdict = SpiceBot.events.dict["trigger_queue"][0]
|
||||||
|
SpiceBot.events.dispatch(bot, pretriggerdict)
|
||||||
|
del SpiceBot.events.dict["trigger_queue"][0]
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_events_complete(bot, trigger):
|
||||||
|
"""This is here simply to log to stderr that this was recieved."""
|
||||||
|
SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True)
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC")
|
||||||
|
|
||||||
|
|
||||||
|
@SpiceBot.events.startup_check_ready()
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_READY)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
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")
|
||||||
@ -1,29 +1,21 @@
|
|||||||
# coding=utf-8
|
# coding=utf8
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot Channels system.
|
||||||
|
"""
|
||||||
import sopel
|
import sopel
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
SpiceBot.logs.log('SpiceBot_Commands', "Starting setup procedure")
|
|
||||||
SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDSQUERY])
|
|
||||||
|
|
||||||
SpiceBot.commands.module_files_parse()
|
|
||||||
|
|
||||||
for comtype in ['module', 'nickname', 'rule']:
|
|
||||||
SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
|
||||||
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDSQUERY, "SpiceBot_Commands")
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_events_complete(bot, trigger):
|
def bot_events_complete(bot, trigger):
|
||||||
|
|
||||||
|
SpiceBot.events.startup_add([SpiceBot.events.BOT_COMMANDS])
|
||||||
|
|
||||||
for comtype in SpiceBot.commands.dict['commands'].keys():
|
for comtype in SpiceBot.commands.dict['commands'].keys():
|
||||||
if comtype not in ['module', 'nickname', 'rule']:
|
if comtype not in ['module', 'nickname', 'rule']:
|
||||||
SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(len(SpiceBot.commands.dict['commands'][comtype].keys())) + " " + comtype + " commands.", True)
|
||||||
|
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_COMMANDS, "SpiceBot_Commands")
|
||||||
@ -7,6 +7,8 @@ This module contains references only for other modules to utilize.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from .Channels import *
|
from .Channels import *
|
||||||
|
from .Events import *
|
||||||
|
from .Modules import *
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@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
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CONNECTED, "Bot Connected to IRC")
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_welcome(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")
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@SpiceBot.events.startup_check_ready()
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_READY)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
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")
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_WELCOME, SpiceBot.events.BOT_READY, SpiceBot.events.BOT_CONNECTED, SpiceBot.events.BOT_LOADED)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_events_complete(bot, trigger):
|
|
||||||
"""This is here simply to log to stderr that this was recieved."""
|
|
||||||
SpiceBot.logs.log('SpiceBot_Events', trigger.args[1], True)
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_WELCOME)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_events_connected(bot, trigger):
|
|
||||||
"""For items tossed in a queue, this will trigger them accordingly"""
|
|
||||||
while True:
|
|
||||||
if len(SpiceBot.events.dict["trigger_queue"]):
|
|
||||||
pretriggerdict = SpiceBot.events.dict["trigger_queue"][0]
|
|
||||||
SpiceBot.events.dispatch(bot, pretriggerdict)
|
|
||||||
del SpiceBot.events.dict["trigger_queue"][0]
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@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")
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
|
|
||||||
@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")
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
# coding=utf8
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
from .Welcome import *
|
|
||||||
from .Ready import *
|
|
||||||
from .Connected import *
|
|
||||||
from .Loaded import *
|
|
||||||
from .Queue import *
|
|
||||||
from .Logging import *
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
|
||||||
__version__ = '0.1.1'
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
# coding=utf8
|
|
||||||
"""Parse module file information
|
|
||||||
"""
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
from .ModuleParsing import *
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
|
||||||
__email__ = 'sam@deathbybandaid.net'
|
|
||||||
__version__ = '0.1.1'
|
|
||||||
@ -7,7 +7,7 @@ import sopel.module
|
|||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_COMMANDSQUERY)
|
@sopel.module.event(SpiceBot.events.BOT_COMMANDS)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_startup_monologue_commands(bot, trigger):
|
def bot_startup_monologue_commands(bot, trigger):
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user