mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 22:49:53 -05:00
startup monologue
This commit is contained in:
parent
a12eea34b7
commit
ce45679fad
13
sopel_modules/SpiceBot/StartupMonologue.py
Normal file
13
sopel_modules/SpiceBot/StartupMonologue.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""StartupMonologue class"""
|
||||||
|
|
||||||
|
|
||||||
|
class BotMonologue():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
|
||||||
|
self.dict = {}
|
||||||
|
|
||||||
|
|
||||||
|
startupmonologue = BotMonologue()
|
||||||
@ -18,6 +18,7 @@ from .Prerun import *
|
|||||||
from .Logs import *
|
from .Logs import *
|
||||||
from .Commands import *
|
from .Commands import *
|
||||||
from .Events import *
|
from .Events import *
|
||||||
|
from .StartupMonologue import *
|
||||||
from .Channels import *
|
from .Channels import *
|
||||||
from .Database import *
|
from .Database import *
|
||||||
|
|
||||||
|
|||||||
80
sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py
Normal file
80
sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
"""
|
||||||
|
This is the SpiceBot StartupMonologue system.
|
||||||
|
"""
|
||||||
|
import sopel
|
||||||
|
|
||||||
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_CONNECTED)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_start(bot, trigger):
|
||||||
|
# Startup
|
||||||
|
SpiceBot.logs.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')
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_channels(bot, trigger):
|
||||||
|
botcount = len(bot.channels.keys())
|
||||||
|
servercount = len(SpiceBot.channels.dict['list'].keys())
|
||||||
|
displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server."
|
||||||
|
SpiceBot.startupmonologue.dict["channels"] = displayval
|
||||||
|
SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval)
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_COMMANDS)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_commands(bot, trigger):
|
||||||
|
availablecomsnum, availablecomsfiles = 0, 0
|
||||||
|
for commandstype in SpiceBot.commands.dict['commands'].keys():
|
||||||
|
availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys())
|
||||||
|
availablecomsfiles += SpiceBot.commands.dict['counts']
|
||||||
|
displayval = "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files."
|
||||||
|
SpiceBot.startupmonologue.dict["commands"] = displayval
|
||||||
|
SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval)
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue")
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_display(bot, trigger):
|
||||||
|
dispmsg = [" startup complete"]
|
||||||
|
for messagekey in SpiceBot.startupmonologue.dict.keys():
|
||||||
|
dispmsg.append(SpiceBot.startupmonologue.dict[messagekey])
|
||||||
|
if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1:
|
||||||
|
timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])
|
||||||
|
dispmsg.append("Startup took " + timesince)
|
||||||
|
# Announce to chan, then handle some closing stuff
|
||||||
|
SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete")
|
||||||
|
bot.osd(dispmsg, bot.channels.keys(), 'ACTION')
|
||||||
|
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue")
|
||||||
|
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True)
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.BOT_STARTUPMONOLOGUE)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_startup_monologue_errors(bot, trigger):
|
||||||
|
|
||||||
|
debuglines = SpiceBot.logs.stdio_logs_fetch()
|
||||||
|
|
||||||
|
searchphrasefound = []
|
||||||
|
for line in debuglines:
|
||||||
|
if str(line).endswith("failed to load") and not str(line).startswith("0"):
|
||||||
|
searchphrasefound.append(line)
|
||||||
|
|
||||||
|
if len(searchphrasefound):
|
||||||
|
for foundphase in searchphrasefound:
|
||||||
|
SpiceBot.logs.log('SpiceBot_Logs', str(foundphase))
|
||||||
|
searchphrasefound.insert(0, "Notice to Bot Admins: ")
|
||||||
|
searchphrasefound.append("Run the debug command for more information.")
|
||||||
|
bot.osd(searchphrasefound, bot.channels.keys())
|
||||||
|
else:
|
||||||
|
SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True)
|
||||||
@ -10,6 +10,7 @@ from .Channels import *
|
|||||||
from .Events import *
|
from .Events import *
|
||||||
from .Modules import *
|
from .Modules import *
|
||||||
from .osd import *
|
from .osd import *
|
||||||
|
from .StartupMonologue import *
|
||||||
|
|
||||||
|
|
||||||
__author__ = 'Sam Zick'
|
__author__ = 'Sam Zick'
|
||||||
|
|||||||
@ -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
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
|
||||||
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Starting setup procedure")
|
|
||||||
|
|
||||||
if 'SpiceBot_StartupMonologue' not in bot.memory:
|
|
||||||
bot.memory['SpiceBot_StartupMonologue'] = []
|
|
||||||
@ -1,19 +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_CHANNELS)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_monologue_channels(bot, trigger):
|
|
||||||
|
|
||||||
botcount = len(bot.channels.keys())
|
|
||||||
servercount = len(SpiceBot.channels.dict['list'].keys())
|
|
||||||
bot.memory['SpiceBot_StartupMonologue'].append("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
|
|
||||||
SpiceBot.logs.log('SpiceBot_StartupMonologue', "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.")
|
|
||||||
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CHANNELS, "SpiceBot_StartupMonologue")
|
|
||||||
@ -1,22 +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_COMMANDS)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_monologue_commands(bot, trigger):
|
|
||||||
|
|
||||||
availablecomsnum, availablecomsfiles = 0, 0
|
|
||||||
for commandstype in SpiceBot.commands.dict['commands'].keys():
|
|
||||||
availablecomsnum += len(SpiceBot.commands.dict['commands'][commandstype].keys())
|
|
||||||
availablecomsfiles += SpiceBot.commands.dict['counts']
|
|
||||||
|
|
||||||
bot.memory['SpiceBot_StartupMonologue'].append("There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
|
|
||||||
SpiceBot.logs.log('SpiceBot_StartupMonologue', "There are " + str(availablecomsnum) + " commands available in " + str(availablecomsfiles) + " files.")
|
|
||||||
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDSQUERY, "SpiceBot_StartupMonologue")
|
|
||||||
@ -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_CONNECTED)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_monologue_start(bot, trigger):
|
|
||||||
|
|
||||||
# Startup
|
|
||||||
SpiceBot.logs.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')
|
|
||||||
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_CONNECTED, "SpiceBot_StartupMonologue")
|
|
||||||
@ -1,27 +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_STARTUPMONOLOGUE)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_monologue_start(bot, trigger):
|
|
||||||
|
|
||||||
debuglines = SpiceBot.logs.stdio_logs_fetch()
|
|
||||||
|
|
||||||
searchphrasefound = []
|
|
||||||
for line in debuglines:
|
|
||||||
if str(line).endswith("failed to load") and not str(line).startswith("0"):
|
|
||||||
searchphrasefound.append(line)
|
|
||||||
|
|
||||||
if len(searchphrasefound):
|
|
||||||
for foundphase in searchphrasefound:
|
|
||||||
SpiceBot.logs.log('SpiceBot_Logs', str(foundphase))
|
|
||||||
searchphrasefound.insert(0, "Notice to Bot Admins: ")
|
|
||||||
searchphrasefound.append("Run the debug command for more information.")
|
|
||||||
bot.osd(searchphrasefound, bot.channels.keys())
|
|
||||||
else:
|
|
||||||
SpiceBot.logs.log('SpiceBot_Logs', "No issues found at bot startup!", True)
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
||||||
|
|
||||||
import sopel.module
|
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
@sopel.module.event(SpiceBot.events.BOT_LOADED)
|
|
||||||
@sopel.module.rule('.*')
|
|
||||||
def bot_startup_monologue_display(bot, trigger):
|
|
||||||
|
|
||||||
if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1:
|
|
||||||
timesince = SpiceBot.humanized_time(time.time() - bot.memory["SpiceBot_Uptime"])
|
|
||||||
SpiceBot.bot.memory['SpiceBot_StartupMonologue'].append("Startup took " + timesince)
|
|
||||||
|
|
||||||
# Announce to chan, then handle some closing stuff
|
|
||||||
SpiceBot.logs.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')
|
|
||||||
|
|
||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue")
|
|
||||||
SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True)
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
# coding=utf8
|
|
||||||
"""Sopel Startup Monologue
|
|
||||||
|
|
||||||
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_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'
|
|
||||||
__version__ = '0.1.1'
|
|
||||||
Loading…
Reference in New Issue
Block a user