mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
add threads
This commit is contained in:
parent
fb15169c56
commit
823937ca8c
@ -6,6 +6,7 @@ This is the SpiceBot Channels system.
|
||||
import sopel
|
||||
|
||||
import time
|
||||
from threading import Thread
|
||||
|
||||
from sopel_modules.spicemanip import spicemanip
|
||||
|
||||
@ -68,6 +69,10 @@ def watch_chanlist_complete(bot, trigger):
|
||||
@sopel.module.event(SpiceBot.events.BOT_CHANNELS)
|
||||
@sopel.module.rule('.*')
|
||||
def trigger_channel_list_recurring(bot, trigger):
|
||||
Thread(target=channels_thread, args=(bot,)).start()
|
||||
|
||||
|
||||
def channels_thread(bot):
|
||||
while True:
|
||||
time.sleep(1800)
|
||||
SpiceBot.channels.bot_part_empty(bot)
|
||||
|
||||
@ -4,6 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
This is the SpiceBot Events system.
|
||||
"""
|
||||
import sopel
|
||||
from threading import Thread
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
@ -27,6 +28,10 @@ def bot_events_connected(bot, trigger):
|
||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_WELCOME, "Welcome to the SpiceBot Events System")
|
||||
|
||||
"""For items tossed in a queue, this will trigger them accordingly"""
|
||||
Thread(target=events_thread, args=(bot,)).start()
|
||||
|
||||
|
||||
def events_thread(bot):
|
||||
while True:
|
||||
if len(SpiceBot.events.dict["trigger_queue"]):
|
||||
pretriggerdict = SpiceBot.events.dict["trigger_queue"][0]
|
||||
|
||||
@ -4,6 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
|
||||
This is the SpiceBot Logs system.
|
||||
"""
|
||||
import sopel
|
||||
from threading import Thread
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
@ -18,10 +19,13 @@ def join_log_channel(bot, trigger):
|
||||
bot.write(('JOIN', bot.nick, channel))
|
||||
if channel not in list(bot.channels.keys()) and bot.config.SpiceBot_Channels.operadmin:
|
||||
bot.write(('SAJOIN', bot.nick, channel))
|
||||
|
||||
while True:
|
||||
if len(SpiceBot.logs.dict["queue"]):
|
||||
bot.osd(str(SpiceBot.logs.dict["queue"][0]), channel)
|
||||
del SpiceBot.logs.dict["queue"][0]
|
||||
Thread(target=logs_thread, args=(bot, channel,)).start()
|
||||
else:
|
||||
SpiceBot.logs.dict["queue"] = []
|
||||
|
||||
|
||||
def logs_thread(bot, channel):
|
||||
while True:
|
||||
if len(SpiceBot.logs.dict["queue"]):
|
||||
bot.osd(str(SpiceBot.logs.dict["queue"][0]), channel)
|
||||
del SpiceBot.logs.dict["queue"][0]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user