Awesome IRC bot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

#!/usr/bin/env python
.. module::Triggered
:synopsis: Scream when tirggered
.. moduleauthor::Dave Pedu <>
from threading import Thread
from time import sleep, time
from pyircbot.modulebase import ModuleBase, hook
from random import randrange, choice
class Triggered(ModuleBase):
def __init__(self, bot, moduleName):
ModuleBase.__init__(self, bot, moduleName)
self.quietuntil = time()
def check(self, msg, cmd):
if time() < self.quietuntil:
if not msg.args[0].lower() in self.config["channels"]:
message = msg.trailing.lower()
triggered = False
for word in self.config["words"]:
if word.lower() in message:
triggered = True
if not triggered:
msg = Thread(target=self.scream, args=(msg.args[0],))
msg.daemon = True
self.quietuntil = time() + self.config["quiet"]
def scream(self, channel):
delay = randrange(self.config["mindelay"], self.config["maxdelay"])"Sleeping for %s seconds" % delay)
sleep(delay), choice(self.config["responses"]))