mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
split core processing
This commit is contained in:
parent
faa1eeb864
commit
75674019c6
@ -103,88 +103,3 @@ class BotChannels():
|
||||
|
||||
|
||||
channels = BotChannels()
|
||||
|
||||
|
||||
@sopel.module.event(events.RPL_WELCOME)
|
||||
@sopel.module.rule('.*')
|
||||
def unkickable_bot(bot, trigger):
|
||||
if bot.config.SpiceBot_Channels.operadmin:
|
||||
bot.write(('SAMODE', bot.nick, '+q'))
|
||||
|
||||
|
||||
@sopel.module.event(events.RPL_WELCOME)
|
||||
@sopel.module.rule('.*')
|
||||
def request_channels_list_initial(bot, trigger):
|
||||
|
||||
channels.bot_part_empty(bot)
|
||||
|
||||
logs.log('SpiceBot_Channels', "Sending Request for all server channels")
|
||||
channels.channel_list_request(bot)
|
||||
|
||||
starttime = time.time()
|
||||
|
||||
# wait 60 seconds for initial population of information
|
||||
while not channels.dict['InitialProcess']:
|
||||
if time.time() - starttime >= 60:
|
||||
logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out")
|
||||
channels.dict['InitialProcess'] = True
|
||||
else:
|
||||
pass
|
||||
|
||||
foundchannelcount = len(channels.dict['list'].keys())
|
||||
logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
|
||||
|
||||
channels.join_all_channels(bot)
|
||||
channels.chanadmin_all_channels(bot)
|
||||
|
||||
if "*" in channels.dict['list'].keys():
|
||||
del channels.dict['list']["*"]
|
||||
|
||||
channels.bot_part_empty(bot)
|
||||
events.trigger(bot, events.BOT_CHANNELS, "SpiceBot_Channels")
|
||||
|
||||
|
||||
@sopel.module.event('321')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_start(bot, trigger):
|
||||
channels.channel_list_recieve_start()
|
||||
|
||||
|
||||
@sopel.module.event('322')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_populate(bot, trigger):
|
||||
channels.channel_list_recieve_input(trigger)
|
||||
|
||||
|
||||
@sopel.module.event('323')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_complete(bot, trigger):
|
||||
channels.channel_list_recieve_finish()
|
||||
|
||||
|
||||
@sopel.module.event(events.BOT_CHANNELS)
|
||||
@sopel.module.rule('.*')
|
||||
def trigger_channel_list_recurring(bot, trigger):
|
||||
while True:
|
||||
time.sleep(1800)
|
||||
channels.bot_part_empty(bot)
|
||||
|
||||
oldlist = list(channels.dict['list'].keys())
|
||||
channels.channel_list_request(bot)
|
||||
|
||||
while channels.channel_lock:
|
||||
pass
|
||||
|
||||
newlist = [item.lower() for item in oldlist if item.lower() not in list(channels.dict['list'].keys())]
|
||||
if "*" in newlist:
|
||||
newlist.remove("*")
|
||||
if len(newlist) and bot.config.SpiceBot_Channels.announcenew:
|
||||
bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys())
|
||||
|
||||
channels.join_all_channels(bot)
|
||||
|
||||
channels.chanadmin_all_channels(bot)
|
||||
|
||||
if "*" in channels.dict['list'].keys():
|
||||
del channels.dict['list']["*"]
|
||||
channels.bot_part_empty(bot)
|
||||
|
||||
97
sopel_modules/SpiceBot_Core_Processing/Channels.py
Normal file
97
sopel_modules/SpiceBot_Core_Processing/Channels.py
Normal file
@ -0,0 +1,97 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
"""
|
||||
This is the SpiceBot Channels system.
|
||||
"""
|
||||
import sopel
|
||||
|
||||
import time
|
||||
|
||||
import spicemanip
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
|
||||
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
|
||||
@sopel.module.rule('.*')
|
||||
def unkickable_bot(bot, trigger):
|
||||
if bot.config.SpiceBot_SpiceBot.channels.operadmin:
|
||||
bot.write(('SAMODE', bot.nick, '+q'))
|
||||
|
||||
|
||||
@sopel.module.event(SpiceBot.events.RPL_WELCOME)
|
||||
@sopel.module.rule('.*')
|
||||
def request_channels_list_initial(bot, trigger):
|
||||
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
|
||||
SpiceBot.logs.log('SpiceBot_Channels', "Sending Request for all server channels")
|
||||
SpiceBot.channels.channel_list_request(bot)
|
||||
|
||||
starttime = time.time()
|
||||
|
||||
# wait 60 seconds for initial population of information
|
||||
while not SpiceBot.channels.dict['InitialProcess']:
|
||||
if time.time() - starttime >= 60:
|
||||
SpiceBot.logs.log('SpiceBot_Channels', "Initial Channel list populating Timed Out")
|
||||
SpiceBot.channels.dict['InitialProcess'] = True
|
||||
else:
|
||||
pass
|
||||
|
||||
foundchannelcount = len(SpiceBot.channels.dict['list'].keys())
|
||||
SpiceBot.logs.log('SpiceBot_Channels', "Channel listing finished! " + str(foundchannelcount) + " channel(s) found.")
|
||||
|
||||
SpiceBot.channels.join_all_channels(bot)
|
||||
SpiceBot.channels.chanadmin_all_channels(bot)
|
||||
|
||||
if "*" in SpiceBot.channels.dict['list'].keys():
|
||||
del SpiceBot.channels.dict['list']["*"]
|
||||
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_CHANNELS, "SpiceBot_Channels")
|
||||
|
||||
|
||||
@sopel.module.event('321')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_start(bot, trigger):
|
||||
SpiceBot.channels.channel_list_recieve_start()
|
||||
|
||||
|
||||
@sopel.module.event('322')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_populate(bot, trigger):
|
||||
SpiceBot.channels.channel_list_recieve_input(trigger)
|
||||
|
||||
|
||||
@sopel.module.event('323')
|
||||
@sopel.module.rule('.*')
|
||||
def watch_chanlist_complete(bot, trigger):
|
||||
SpiceBot.channels.channel_list_recieve_finish()
|
||||
|
||||
|
||||
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
|
||||
@sopel.module.rule('.*')
|
||||
def trigger_channel_list_recurring(bot, trigger):
|
||||
while True:
|
||||
time.sleep(1800)
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
|
||||
oldlist = list(SpiceBot.channels.dict['list'].keys())
|
||||
SpiceBot.channels.channel_list_request(bot)
|
||||
|
||||
while SpiceBot.channels.channel_lock:
|
||||
pass
|
||||
|
||||
newlist = [item.lower() for item in oldlist if item.lower() not in list(SpiceBot.channels.dict['list'].keys())]
|
||||
if "*" in newlist:
|
||||
newlist.remove("*")
|
||||
if len(newlist) and bot.config.SpiceBot_SpiceBot.channels.announcenew:
|
||||
bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], bot.channels.keys())
|
||||
|
||||
SpiceBot.channels.join_all_channels(bot)
|
||||
|
||||
SpiceBot.channels.chanadmin_all_channels(bot)
|
||||
|
||||
if "*" in SpiceBot.channels.dict['list'].keys():
|
||||
del SpiceBot.channels.dict['list']["*"]
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
14
sopel_modules/SpiceBot_Core_Processing/__init__.py
Normal file
14
sopel_modules/SpiceBot_Core_Processing/__init__.py
Normal file
@ -0,0 +1,14 @@
|
||||
# coding=utf8
|
||||
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||
"""
|
||||
These are the core SpiceBot Classes
|
||||
|
||||
This module contains references only for other modules to utilize.
|
||||
"""
|
||||
|
||||
from .Channels import *
|
||||
|
||||
|
||||
__author__ = 'Sam Zick'
|
||||
__email__ = 'sam@deathbybandaid.net'
|
||||
__version__ = '0.1.1'
|
||||
Loading…
Reference in New Issue
Block a user