Add yelling module

dave/xdcc
dpedu 7 years ago
parent d1a4cf4451
commit 803f852817
  1. 30
      examples/data/config/Triggered.json
  2. 46
      pyircbot/modules/Triggered.py

@ -0,0 +1,30 @@
{
"channels": [
"#mychannel",
"#myotherchannel"
],
"words": [
"fuck",
"shit",
"crap",
"bitch",
"php"
],
"responses": [
"AHHHHHHHH",
"HELP",
"AHHHHHHHHHHHHH",
"OH GOD PLEASE NO MORE",
"AHHHH",
"FOR THE LOVE OF DOG STOP",
"I HAVE A FAMILY NOOO",
"NOOOOOO",
"AHHHHH",
"NO",
"AGHHHHHHH",
"NO GOD! PLEASE NO!!! NOOOOOOOOOO"
],
"mindelay": 5,
"maxdelay": 180,
"quiet": 6000
}

@ -0,0 +1,46 @@
#!/usr/bin/env python
"""
.. module::Triggered
:synopsis: Scream when tirggered
.. moduleauthor::Dave Pedu <git@davepedu.com>
"""
from threading import Thread
from time import sleep,time
from pyircbot.modulebase import ModuleBase, ModuleHook
from random import randrange,choice
class Triggered(ModuleBase):
def __init__(self, bot, moduleName):
ModuleBase.__init__(self, bot, moduleName)
self.loadConfig()
self.quietuntil = time()
self.hooks.append(ModuleHook("PRIVMSG", self.check))
def check(self, args):
if time() < self.quietuntil:
return
if not args.args[0].lower() in self.config["channels"]:
return
message = args.trailing.lower()
triggered = False
for word in self.config["words"]:
if word.lower() in message:
triggered = True
break
if not triggered:
return
msg = Thread(target=self.scream, args=(args.args[0],))
msg.daemon = True
msg.start()
self.quietuntil = time() + self.config["quiet"]
def scream(self, channel):
delay = randrange(self.config["mindelay"], self.config["maxdelay"])
self.log.debug("Sleeping for %s seconds" % delay)
sleep(delay)
self.bot.act_PRIVMSG(channel, choice(self.config["responses"]))
Loading…
Cancel
Save