Add rejoin module
This commit is contained in:
parent
b4f4812c53
commit
3cd61f6ce1
31
pyircbot/modules/Rejoin.py
Normal file
31
pyircbot/modules/Rejoin.py
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
.. module:: PressF
|
||||
:synopsis: Press F to pay respects
|
||||
|
||||
.. moduleauthor:: Dave Pedu <dave@davepedu.com>
|
||||
|
||||
"""
|
||||
|
||||
from pyircbot.modulebase import ModuleBase, hook
|
||||
from time import sleep
|
||||
from threading import Thread
|
||||
|
||||
|
||||
class Rejoin(ModuleBase):
|
||||
def __init__(self, bot, moduleName):
|
||||
ModuleBase.__init__(self, bot, moduleName)
|
||||
try:
|
||||
self.services = self.bot.getmodulesbyservice("services").pop()
|
||||
except KeyError as ke:
|
||||
raise Exception("No services service provider found") from ke
|
||||
|
||||
@hook("KICK")
|
||||
def kicked(self, msg, cmd):
|
||||
channel, who = msg.args
|
||||
if who == self.services.nick():
|
||||
Thread(target=self.rejoin, args=(self.config.get("delay", 30), channel)).start()
|
||||
|
||||
def rejoin(self, delay, channel):
|
||||
sleep(delay)
|
||||
self.bot.act_JOIN(channel)
|
Loading…
Reference in New Issue
Block a user