added ability when bot quiets/bot has been asked to quiet someone to send a notice or privmsg to targeted users

This commit is contained in:
Nicolas Coevoet 2014-12-04 00:05:57 +01:00
parent a59061cfde
commit 3b52169de2
2 changed files with 20 additions and 5 deletions

View File

@ -57,6 +57,9 @@ conf.registerGlobalValue(ChanTracker, 'quietCommand',
conf.registerGlobalValue(ChanTracker, 'unquietCommand', conf.registerGlobalValue(ChanTracker, 'unquietCommand',
registry.String("CS UNQUIET $channel $hostmask","""command issued to unquiet a user $channel and $hostmask will be replaced at runtime""")) registry.String("CS UNQUIET $channel $hostmask","""command issued to unquiet a user $channel and $hostmask will be replaced at runtime"""))
conf.registerGlobalValue(ChanTracker, 'announceNagInterval',
registry.Integer(300,"""interval between two check about announceNagMode, this setting is global."""))
#now per channel #now per channel
conf.registerChannelValue(ChanTracker, 'opCommand', conf.registerChannelValue(ChanTracker, 'opCommand',
@ -131,9 +134,6 @@ conf.registerChannelValue(ChanTracker, 'announceCtcp',
conf.registerChannelValue(ChanTracker, 'announceNagMode', conf.registerChannelValue(ChanTracker, 'announceNagMode',
registry.CommaSeparatedListOfStrings([], """bot will announce that channel has such mode at announceNagInterval""")) registry.CommaSeparatedListOfStrings([], """bot will announce that channel has such mode at announceNagInterval"""))
conf.registerGlobalValue(ChanTracker, 'announceNagInterval',
registry.Integer(300,"""interval between two check about announceNagMode, this setting is global."""))
# others settings # others settings
conf.registerChannelValue(ChanTracker, 'doNothingAboutOwnOpStatus', conf.registerChannelValue(ChanTracker, 'doNothingAboutOwnOpStatus',
@ -149,6 +149,12 @@ conf.registerChannelValue(ChanTracker, 'kickMode',
conf.registerChannelValue(ChanTracker, 'kickMessage', conf.registerChannelValue(ChanTracker, 'kickMessage',
registry.String("You are banned from this channel", """bot kick reason""")) registry.String("You are banned from this channel", """bot kick reason"""))
conf.registerChannelValue(ChanTracker, 'quietMessage',
registry.String("", """leave empty if you don't want the bot to tell something to the user when he has been quieted ( by/via the bot ), in any case, if channel is under attack: bot will not send message"""))
conf.registerChannelValue(ChanTracker, 'quietNotice',
registry.Boolean(False, """if False, private message is used, if 'quietMessage' is not empty"""))
conf.registerChannelValue(ChanTracker, 'trackAffected', conf.registerChannelValue(ChanTracker, 'trackAffected',
registry.Boolean(True, """bot tracks affected users by mode change, if you encounter too much lags/cpu usage, you could disable this feature, but bot will never kick again affected users or remove voice/op/exempt etc of affected users""")) registry.Boolean(True, """bot tracks affected users by mode change, if you encounter too much lags/cpu usage, you could disable this feature, but bot will never kick again affected users or remove voice/op/exempt etc of affected users"""))

View File

@ -851,6 +851,7 @@ class Chan (object):
self.repeatLogs = ircutils.IrcDict() self.repeatLogs = ircutils.IrcDict()
self.nicks = ircutils.IrcDict() self.nicks = ircutils.IrcDict()
self.netsplit = False self.netsplit = False
self.attacked = False
def isWrong (self,pattern): def isWrong (self,pattern):
if 'bad' in self.spam and pattern in self.spam['bad']: if 'bad' in self.spam and pattern in self.spam['bad']:
@ -3017,6 +3018,12 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
chan.queue.enqueue(('-h',nick)) chan.queue.enqueue(('-h',nick))
if nick in irc.state.channels[channel].voices and not nick == irc.nick: if nick in irc.state.channels[channel].voices and not nick == irc.nick:
chan.queue.enqueue(('-v',nick)) chan.queue.enqueue(('-v',nick))
if m == 'q' and self.registryValue('quietMessage',channel=channel).length and not chan.attacked:
qm = self.registryValue('quietMessage',channel=channel)
if self.registryValue('quietNotice',channel=channel):
irc.queueMsg(ircmsgs.notice(nick,qm))
else:
irc.queueMsg(ircmsgs.privmsg(nick,qm))
if m == 'b': if m == 'b':
self.hasExtendedSharedBan(irc,channel,value) self.hasExtendedSharedBan(irc,channel,value)
# bot just got op # bot just got op
@ -3227,13 +3234,15 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
def _isBad (self,irc,channel,key): def _isBad (self,irc,channel,key):
b = self._isSomething(irc,channel,key,'bad') b = self._isSomething(irc,channel,key,'bad')
if b: if b:
if self._isSomething(irc,channel,channel,'attack'): chan = self.getChan(irc,channel)
if self._isSomething(irc,channel,channel,'attack') and not chan.attacked:
# if number of bad users raise the allowed limit, bot has to set channel attackmode # if number of bad users raise the allowed limit, bot has to set channel attackmode
chan = self.getChan(irc,channel) chan.attacked = True
chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel)))) chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackMode',channel=channel))))
def unAttack(): def unAttack():
if channel in list(irc.state.channels.keys()): if channel in list(irc.state.channels.keys()):
chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackUnMode',channel=channel)))) chan.action.enqueue(ircmsgs.IrcMsg('MODE %s %s' % (channel,self.registryValue('attackUnMode',channel=channel))))
chan.attacked = False
schedule.addEvent(unAttack,float(time.time()+self.registryValue('attackDuration',channel=channel))) schedule.addEvent(unAttack,float(time.time()+self.registryValue('attackDuration',channel=channel)))
return b return b