mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-26 04:51:07 -05:00
finished colored announce, some typos fixs, little enhancement for mass edit
This commit is contained in:
parent
abd832543e
commit
4d3c14c85c
24
config.py
24
config.py
@ -80,7 +80,7 @@ conf.registerChannelValue(ChanTracker, 'logChannel',
|
||||
registry.String("", """where bot announces op's actions; it is highly recommended to set an appropriate operator's channel to receive the various useful messages"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'useColorForAnnounces',
|
||||
registry.Boolean(False, """use colors for announces messages"""))
|
||||
registry.Boolean(False, """use colors for announce messages"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'announceOthers',
|
||||
registry.Boolean(True,"""forward messages from quieted/banned users to logChannel; used when bot stays opped and channel is +z (reduced moderation).
|
||||
@ -144,7 +144,7 @@ conf.registerChannelValue(ChanTracker, 'kickMessage',
|
||||
registry.String("You are banned from this channel", """bot kick reason"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'trackAffected',
|
||||
registry.Boolean(True, """bot tracks affected users by mode change, if you encounters 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"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'doActionAgainstAffected',
|
||||
registry.Boolean(True, """devoice, deop, dehalfop user affected by a mode change"""))
|
||||
@ -159,7 +159,7 @@ conf.registerChannelValue(ChanTracker, 'askOpAboutMode',
|
||||
registry.Boolean(False,"""In a private message, ask the op who added a mode about the duration of the ban and a comment on why it was set"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'checkEvade',
|
||||
registry.Boolean(True,"""bot will apply same duration and mode than the ban evaded, currently only work when someone identify to an account, and the account is banned $a:account, and has ip computed"""))
|
||||
registry.Boolean(True,"""bot will apply same duration and mode as the evaded ban, currently only works when someone identifies to an account, and the account is banned $a:account, and has ip computed"""))
|
||||
|
||||
conf.registerChannelValue(ChanTracker, 'useChanServForQuiets',
|
||||
registry.Boolean(False,"""if bot is not opped, use services for quiet / unquiets"""))
|
||||
@ -195,7 +195,7 @@ conf.registerChannelValue(ChanTracker, 'repeatPermit',
|
||||
registry.Integer(-1,"""Number of repeated text allowed, -1 to disable, note, first message doesn't count,
|
||||
so if you want to trigger it after 3 repeat, you must set it to 1, advice 4"""))
|
||||
conf.registerChannelValue(ChanTracker, 'repeatLife',
|
||||
registry.PositiveInteger(120,"""Duration of messages's life in lowFlood counter in seconds, advice 120"""))
|
||||
registry.PositiveInteger(120,"""Duration of messages's life in repeatPermit counter in seconds, advice 120"""))
|
||||
conf.registerChannelValue(ChanTracker, 'repeatPercent',
|
||||
registry.Probability(0.85,"""percent of similarity needed between previous and current message to trigger a repeat count"""))
|
||||
conf.registerChannelValue(ChanTracker, 'repeatMode',
|
||||
@ -242,9 +242,9 @@ registry.String('capslock detected',"""comment added on mode changes database, e
|
||||
|
||||
# hilight
|
||||
conf.registerChannelValue(ChanTracker, 'hilightPermit',
|
||||
registry.Integer(-1,"""Number of nick allowed per message, -1 to disable, advice 2 - 3, note : it don't care if it's the same nick"""))
|
||||
registry.Integer(-1,"""Number of nick allowed per message, -1 to disable, advice 2 - 3, note : it doesn't care if it's the same nick"""))
|
||||
conf.registerChannelValue(ChanTracker, 'hilightMode',
|
||||
registry.String('q',"""mode used by the bot when cap is triggered"""))
|
||||
registry.String('q',"""mode used by the bot when hilight is triggered"""))
|
||||
conf.registerChannelValue(ChanTracker, 'hilightDuration',
|
||||
registry.PositiveInteger(180,"""punishment duration in seconds"""))
|
||||
conf.registerChannelValue(ChanTracker, 'hilightComment',
|
||||
@ -268,7 +268,7 @@ registry.Integer(-1,"""Number of messages allowed, -1 to disable, advice 0"""))
|
||||
conf.registerChannelValue(ChanTracker, 'ctcpLife',
|
||||
registry.PositiveInteger(3,"""Duration in seconds before messages are removed from count"""))
|
||||
conf.registerChannelValue(ChanTracker, 'ctcpMode',
|
||||
registry.String('b',"""mode used by the bot when ctcp is triggered"""))
|
||||
registry.String('b',"""mode used by the bot when cycle is triggered"""))
|
||||
conf.registerChannelValue(ChanTracker, 'ctcpDuration',
|
||||
registry.PositiveInteger(1800,"""punishment duration in seconds"""))
|
||||
conf.registerChannelValue(ChanTracker, 'ctcpComment',
|
||||
@ -290,7 +290,7 @@ registry.String('',"""if your ircd supports that, you can forward the user to a
|
||||
|
||||
# channel massJoin from an host
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinPermit',
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, note, it could mixup a bit with cycle detection"""))
|
||||
registry.Integer(-1,"""Number of joins allowed, -1 to disable, note, it could mixup a bit with cycle detection"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinLife',
|
||||
registry.PositiveInteger(60,"""Duration in seconds before messages are removed from count"""))
|
||||
conf.registerChannelValue(ChanTracker, 'massJoinMode',
|
||||
@ -302,9 +302,9 @@ registry.String('-rq+z $~a',"""mode used by the bot when massJoinDuration is fin
|
||||
|
||||
# nick changes flood
|
||||
conf.registerChannelValue(ChanTracker, 'nickPermit',
|
||||
registry.Integer(-1,"""Number of messages allowed, -1 to disable, advice 2"""))
|
||||
registry.Integer(-1,"""Number of nick changes allowed, -1 to disable, advice 2"""))
|
||||
conf.registerChannelValue(ChanTracker, 'nickLife',
|
||||
registry.Integer(300,"""Duration in seconds before messages are removed from count, advice 300"""))
|
||||
registry.Integer(300,"""Duration in seconds before nick changes are removed from count, advice 300"""))
|
||||
conf.registerChannelValue(ChanTracker, 'nickMode',
|
||||
registry.String('q',"""mode used by the bot when nick is triggered"""))
|
||||
conf.registerChannelValue(ChanTracker, 'nickDuration',
|
||||
@ -316,7 +316,7 @@ registry.String('nick changes flood detected',"""comment added on mode changes d
|
||||
conf.registerChannelValue(ChanTracker, 'badPermit',
|
||||
registry.Integer(-1,"""Number of bad action allowed, -1 to disable, advice 2, each time bot had to acts on a user, it increase this item"""))
|
||||
conf.registerChannelValue(ChanTracker, 'badLife',
|
||||
registry.Integer(600,"""Duration in seconds before item are removed from count, advice 600"""))
|
||||
registry.Integer(600,"""Duration in seconds before actions are removed from count, advice 600"""))
|
||||
conf.registerChannelValue(ChanTracker, 'badMode',
|
||||
registry.String('b',"""mode used by the bot when bad is triggered"""))
|
||||
conf.registerChannelValue(ChanTracker, 'badDuration',
|
||||
@ -328,7 +328,7 @@ registry.String('bad detected',"""comment added on mode changes database, empty
|
||||
conf.registerChannelValue(ChanTracker, 'attackPermit',
|
||||
registry.Integer(-1,"""Number of bad action allowed, -1 to disable, advice 2, each time bot flags user as bad, it increase this item"""))
|
||||
conf.registerChannelValue(ChanTracker, 'attackLife',
|
||||
registry.Integer(600,"""Duration in seconds before item are removed from count, advice 600"""))
|
||||
registry.Integer(600,"""Duration in seconds before actions are removed from count, advice 600"""))
|
||||
conf.registerChannelValue(ChanTracker, 'attackDuration',
|
||||
registry.PositiveInteger(1800,"""punishment duration in seconds"""))
|
||||
conf.registerChannelValue(ChanTracker, 'attackMode',
|
||||
|
55
plugin.py
55
plugin.py
@ -651,7 +651,7 @@ class Ircd (object):
|
||||
f = ct._logChan
|
||||
if f:
|
||||
if ct.registryValue('useColorForAnnounces',channel=channel):
|
||||
f(irc,channel,'[%s] [#%s %s %s] marked by %s: %s' % (channel,ircutils.mircColor(uid,'orange'),ircutils.bold(ircutils.mircColor('+%s' % kind,'red')),ircutils.mircColor(mask,'light blue'),prefix.split('!')[0],message))
|
||||
f(irc,channel,'[%s] [#%s %s %s] marked by %s: %s' % (ircutils.bold(channel),ircutils.mircColor(uid,'orange'),ircutils.bold(ircutils.mircColor('+%s' % kind,'red')),ircutils.mircColor(mask,'light blue'),prefix.split('!')[0],message))
|
||||
else:
|
||||
f(irc,channel,'[%s] [#%s +%s %s] marked by %s: %s' % (channel,uid,kind,mask,prefix.split('!')[0],message))
|
||||
b = True
|
||||
@ -677,7 +677,7 @@ class Ircd (object):
|
||||
db.commit()
|
||||
if logFunction:
|
||||
if ct.registryValue('useColorForAnnounces',channel=channel):
|
||||
logFunction(irc,channel,'[%s] [#%s %s %s] marked by %s: %s' % (channel,ircutils.mircColor(uid,'orange'),ircutils.bold(ircutils.mircColor('+%s' % kind,'green')),ircutils.mircColor(mask,'light blue'),prefix.split('!')[0],message))
|
||||
logFunction(irc,channel,'[%s] [#%s %s %s] marked by %s: %s' % (ircutils.bold(channel),ircutils.mircColor(uid,'orange'),ircutils.bold(ircutils.mircColor('+%s' % kind,'green')),ircutils.mircColor(mask,'light blue'),prefix.split('!')[0],message))
|
||||
else:
|
||||
logFunction(irc,channel,'[%s] [#%s +%s %s] marked by %s: %s' % (channel,uid,kind,mask,prefix.split('!')[0],message))
|
||||
b = True
|
||||
@ -786,7 +786,7 @@ class Ircd (object):
|
||||
c.close()
|
||||
return b
|
||||
|
||||
def resync (self,irc,channel,mode,db,logFunction):
|
||||
def resync (self,irc,channel,mode,db,logFunction,ct):
|
||||
# here sync mode lists, if items were removed when bot was offline, mark records as removed
|
||||
c = db.cursor()
|
||||
c.execute("""SELECT id,channel,mask FROM bans WHERE channel=? AND kind=?AND removed_at is NULL ORDER BY id""",(channel,mode))
|
||||
@ -805,10 +805,16 @@ class Ircd (object):
|
||||
if not item:
|
||||
c.execute("""UPDATE bans SET removed_at=?, removed_by=? WHERE id=?""", (current,'offline!offline@offline',int(uid)))
|
||||
commits = commits + 1
|
||||
if ct.registryValue('useColorForAnnounces',channel=channel):
|
||||
msgs.append('[#%s %s]' % (ircutils.mircColor(uid,'yellow'),ircutils.mircColor(mask,'light blue')))
|
||||
else:
|
||||
msgs.append('[#%s %s]' % (uid,mask))
|
||||
if commits > 0:
|
||||
db.commit()
|
||||
if logFunction:
|
||||
if ct.registryValue('useColorForAnnounces',channel=channel):
|
||||
logFunction(irc,channel,'[%s] [%s] %s removed: %s' % (ircutils.bold(channel),ircutils.mircColor(mode,'green'),commits, ' '.join(msgs)))
|
||||
else:
|
||||
logFunction(irc,channel,'[%s] [%s] %s removed: %s' % (channel,mode,commits, ' '.join(msgs)))
|
||||
c.close()
|
||||
|
||||
@ -1136,6 +1142,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
change expiration of some active modes"""
|
||||
i = self.getIrc(irc)
|
||||
b = True
|
||||
sf = None
|
||||
if not len(ids) > 1:
|
||||
sf = self._schedule
|
||||
for id in ids:
|
||||
item = i.getItem(irc,id)
|
||||
if item:
|
||||
@ -1146,9 +1155,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
f = self._logChan
|
||||
if getDuration(seconds) == 0 and not self.registryValue('announceInTimeEditAndMark',channel=item.channel):
|
||||
f = None
|
||||
b = b and i.edit(irc,item.channel,item.mode,item.value,getDuration(seconds),msg.prefix,self.getDb(irc.network),self._schedule,f,self)
|
||||
b = b and i.edit(irc,item.channel,item.mode,item.value,getDuration(seconds),msg.prefix,self.getDb(irc.network),sf,f,self)
|
||||
else:
|
||||
b = False;
|
||||
if not sf and duration > 0:
|
||||
self._schedule(irc,float(time.time())+duration)
|
||||
if not msg.nick == irc.nick:
|
||||
if b:
|
||||
irc.replySuccess()
|
||||
@ -1937,8 +1948,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if self.registryValue('announceModeSync',channel=channel):
|
||||
f = self._logChan
|
||||
if b:
|
||||
self._logChan(irc,channel,'[%s] sync %s' % (channel,chan.dones))
|
||||
i.resync(irc,channel,mode,self.getDb(irc.network),f)
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
f(irc,channel,'[%s] sync %s' % (ircutils.bold(channel),chan.dones))
|
||||
else:
|
||||
f(irc,channel,'[%s] sync %s' % (channel,chan.dones))
|
||||
i.resync(irc,channel,mode,self.getDb(irc.network),f,self)
|
||||
self._tickle(irc)
|
||||
|
||||
def do346 (self,irc,msg):
|
||||
@ -2013,6 +2027,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if not chan.syn:
|
||||
chan.syn = True
|
||||
if self.registryValue('announceModeSync',channel=channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,"[%s] is ready" % ircutils.bold(channel))
|
||||
else:
|
||||
self._logChan(irc,channel,"[%s] is ready" % channel)
|
||||
self._tickle(irc)
|
||||
|
||||
@ -2088,6 +2105,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if ircutils.isChannel(channel) and channel in irc.state.channels:
|
||||
if len(reason):
|
||||
if reason.startswith('requested by') and self.registryValue('announceKick',channel=channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s has left (%s)' % (ircutils.bold(channel),ircutils.mircColor(msg.prefix,'light blue'),reason))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s has left (%s)' % (channel,msg.prefix,reason))
|
||||
if self.registryValue('addKickMessageInComment',channel=channel):
|
||||
chan = self.getChan(irc,channel)
|
||||
@ -2157,6 +2177,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
n = self.getNick(irc,target)
|
||||
n.addLog(channel,'kicked by %s (%s)' % (msg.prefix,reason))
|
||||
if self.registryValue('announceKick',channel=channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s kicks %s (%s)' % (ircutils.bold(channel),msg.nick,ircutils.mircColor(n.prefix,'light blue'),reason))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s kicks %s (%s)' % (channel,msg.nick,n.prefix,reason))
|
||||
if len(reason) and msg.prefix != irc.prefix and self.registryValue('addKickMessageInComment',channel=channel):
|
||||
chan = self.getChan(irc,channel)
|
||||
@ -2260,6 +2283,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
chan = self.getChan(irc,channel)
|
||||
if msg.nick in chan.nicks:
|
||||
if self.registryValue('announceKick',channel=channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s has quit (%s)' % (ircutils.bold(channel),ircutils.mircColor(msg.prefix,'light blue'),ircutils.mircColor(reason,'red')))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s has quit (%s)' % (channel,msg.prefix,reason))
|
||||
for channel in irc.state.channels:
|
||||
chan = self.getChan(irc,channel)
|
||||
@ -2457,7 +2483,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
self._act(irc,channel,mode,best,duration,comment)
|
||||
self._isBad(irc,channel,best)
|
||||
self.forceTickle = True
|
||||
if not isMass and isNotice:
|
||||
if isNotice:
|
||||
isBad = self._isSomething(irc,channel,best,'bad')
|
||||
if not isMass:
|
||||
if isNotice or isBad:
|
||||
@ -2473,6 +2499,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
self.forceTickle = True
|
||||
if self.registryValue('announceNotice',channel=channel):
|
||||
if not chan.isWrong(best):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s notice "%s"' % (ircutils.bold(channel),ircutils.mircColor(msg.prefix,'light blue'),text))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s notice "%s"' % (channel,msg.prefix,text))
|
||||
|
||||
self._tickle(irc)
|
||||
@ -2598,6 +2627,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if not chan.isWrong(best):
|
||||
# prevent the bot to flood logChannel with bad user craps
|
||||
if self.registryValue('announceCtcp',channel=channel) and isCtcpMsg and not isAction:
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s ctcps "%s"' % (ircutils.bold(channel),ircutils.mircColor(msg.prefix,'light blue'),text))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s ctcps "%s"' % (channel,msg.prefix,text))
|
||||
self.forceTickle = True
|
||||
else:
|
||||
@ -2621,6 +2653,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if found:
|
||||
break
|
||||
if found:
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
message = '[%s] [#%s +%s %s] <%s> %s' % (ircutils.bold(channel),found[0].uid,ircutils.mircColor(found[0].mode,'red'),ircutils.mircColor(found[0].value,'light blue'),msg.nick,text)
|
||||
else:
|
||||
message = '[%s] [#%s +%s %s] <%s> %s' % (channel,found[0].uid,found[0].mode,found[0].value,msg.nick,text)
|
||||
if message:
|
||||
self._logChan(irc,channel,message)
|
||||
@ -2698,6 +2733,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
if n:
|
||||
n.addLog(channel,'sets topic "%s"' % msg.args[1])
|
||||
if self.registryValue('announceTopic',channel=channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s sets topic "%s"' % (ircutils.bold(channel),ircutils.mircColor(msg.prefix,'light blue'),msg.args[1]))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s sets topic "%s"' % (channel,msg.prefix,msg.args[1]))
|
||||
self.forceTickle = True
|
||||
self._tickle(irc)
|
||||
@ -2884,6 +2922,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
||||
self.forceTickle = True
|
||||
if len(self.registryValue('announceModes',channel=channel)) and len(msgs):
|
||||
if self.registryValue('announceModeMadeByIgnored',channel=channel) or not ircdb.checkIgnored(msg.prefix,channel):
|
||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||
self._logChan(irc,channel,'[%s] %s sets %s' % (ircutils.bold(channel),msg.nick,' '.join(msgs)))
|
||||
else:
|
||||
self._logChan(irc,channel,'[%s] %s sets %s' % (channel,msg.nick,' '.join(msgs)))
|
||||
self.forceTickle = True
|
||||
if len(toexpire):
|
||||
|
Loading…
x
Reference in New Issue
Block a user