From e76b5665bf0ce7b1c81a201e2bc4fc230d4ab8a1 Mon Sep 17 00:00:00 2001 From: Nicolas Coevoet Date: Tue, 16 Sep 2014 16:05:28 +0200 Subject: [PATCH] added 'nag' feature, which can announce in logChannel at regular interval that some modes are setted --- config.py | 6 ++++++ plugin.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/config.py b/config.py index ad94619..eab1bd9 100644 --- a/config.py +++ b/config.py @@ -128,6 +128,12 @@ conf.registerChannelValue(ChanTracker, 'announceNotice', conf.registerChannelValue(ChanTracker, 'announceCtcp', registry.Boolean(True,"""announce channel ctcps to logChannel""")) +conf.registerChannelValue(ChanTracker, 'announceNagMode', + registry.CommaSeparatedListOfStrings([], """bot will announce that channel has such mode at announceNagInterval""")) + +conf.registerGlobalValue(ChanTracker, 'announceNagInterval', + registry.PositiveInteger(300,"""interval between two check about announceNagMode, this setting is global.""")) + # others settings conf.registerChannelValue(ChanTracker, 'doNothingAboutOwnOpStatus', diff --git a/plugin.py b/plugin.py index a33df04..22b2d53 100644 --- a/plugin.py +++ b/plugin.py @@ -1100,7 +1100,25 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler): self._ircs = ircutils.IrcDict() self.getIrc(irc) self.recaps = re.compile("[A-Z]") + schedule.addEvent(self.checkNag,time.time()+self.registryValue('announceNagInterval')) + def checkNag (self): + if world: + if world.ircs: + for irc in world.ircs: + for channel in irc.state.channels: + if self.registryValue('logChannel',channel=channel) in irc.state.channels: + toNag = '' + for mode in self.registryValue('announceNagMode',channel=channel): + if mode in irc.state.channels[channel].modes: + toNag = mode + break + if len(toNag): + message = '[%s] has %s mode' % (channel,toNag) + if self.registryValue('useColorForAnnounces',channel=channel): + message = '[%s] has %s mode' % (ircutils.bold(channel),toNag) + self._logChan(irc,channel,message) + schedule.addEvent(self.checkNag,time.time()+self.registryValue('announceNagInterval')) def editandmark (self,irc,msg,args,user,ids,seconds,reason): """[,] [y] [w] [d] [h] [m] [s] [<-1> or empty means forever, <0s> means remove] []