From 4b7a00539c8061a998f99f52154bba6ea07f219a Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 21 Apr 2015 15:01:53 +1000 Subject: [PATCH] bot: add a minimum messages counter for hangouts notifications This should stop the "TuckBot" spam, when he is the only one saying *anything* in the chatroom :) --- bot.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot.py b/bot.py index 256560c..96c9306 100644 --- a/bot.py +++ b/bot.py @@ -10,6 +10,7 @@ class Bot: def __init__(self): + self._messageCount = 0 self.commandList = {} self.config = { @@ -19,14 +20,13 @@ def __init__(self): self.permissions = { "tuckismad": 3, - "TyrantWarship": 1 + "TyrantWarship": 1, + "hcwool": 2 } self.timedEvents = { 'livestreamChecker': [self.CheckLiveStreams, time(), 10], - 'hangoutsAnnoucenment': [ - lambda: - self.Send(self.channel, "24/7 Hangouts room, check it out here! http://goo.gl/HkFFqg"), time(), 3600] + 'hangoutsAnnoucenment': [self.HangoutsNotify, time(), 3600] } self.host = "irc.freenode.net" @@ -47,6 +47,11 @@ def __init__(self): self.AddModules() + def HangoutsNotify(self): + if self._messageCount > 10: + self.Send(self.channel, "24/7 Hangouts room, check it out here! http://goo.gl/HkFFqg") + self._messageCount = 0 + def Send(self, target, message): ''' Send(String target, String message) @@ -130,6 +135,7 @@ def Run(self): while True: try: data = self.irc.recv(4096).decode("UTF-8", "replace") + self._messageCount += 1 except: pass if(data.find("PING") != -1):