mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
Combine channel Parsing
This commit is contained in:
parent
26f39f8f11
commit
a943fed89f
@ -8,6 +8,9 @@ from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
|
||||
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
|
||||
import spicemanip
|
||||
|
||||
from .Config import config as botconfig
|
||||
from .Events import events
|
||||
@ -100,3 +103,88 @@ 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)
|
||||
|
||||
@ -1,97 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# coding=utf-8
|
||||
from __future__ import unicode_literals, absolute_import, print_function, division
|
||||
|
||||
# sopel imports
|
||||
import sopel.module
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
import spicemanip
|
||||
|
||||
import time
|
||||
|
||||
|
||||
@sopel.module.event(SpiceBot.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(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_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)
|
||||
@ -1,6 +0,0 @@
|
||||
# coding=utf-8
|
||||
"""Event Parsing from IRC
|
||||
"""
|
||||
from __future__ import unicode_literals, absolute_import, print_function, division
|
||||
|
||||
from .Channels_Parsing import *
|
||||
Loading…
Reference in New Issue
Block a user