Added in modeD

This commit is contained in:
Nicolas Coevoet 2021-06-30 09:10:01 +02:00
parent 70e98f2c74
commit be7cb231dd
2 changed files with 15 additions and 13 deletions

View File

@ -62,7 +62,7 @@ conf.registerGlobalValue(ChanTracker, 'resolveIp',
registry.Boolean(True, """trying to resolve host's ip with socket, could add latency""")) registry.Boolean(True, """trying to resolve host's ip with socket, could add latency"""))
conf.registerGlobalValue(ChanTracker, 'modeD', conf.registerGlobalValue(ChanTracker, 'modeD',
registry.String("", """special mode if you want to use some specific stuff $hostmask (*!*@*) $klinemask (*@*) $host $channel $reason and $duration are available""")) registry.String("", """special mode if you want to use some specific stuff $hostmask (*!*@*) $klinemask (*@*) $host $channel $reason $nick and $duration are available"""))
# per channel settings # per channel settings

View File

@ -3293,7 +3293,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
n.setPrefix(item.value) n.setPrefix(item.value)
if match('*!*@%s' % prefix.split('ip.')[1], n, irc, self.registryValue('resolveIp')): if match('*!*@%s' % prefix.split('ip.')[1], n, irc, self.registryValue('resolveIp')):
self._act(irc, channel, 'b', best, self.registryValue( self._act(irc, channel, 'b', best, self.registryValue(
'autoExpire', channel=channel), 'evade of [#%s +%s %s]' % (item.uid, item.mode, item.value)) 'autoExpire', channel=channel), 'evade of [#%s +%s %s]' % (item.uid, item.mode, item.value), nick)
f = None f = None
banned = True banned = True
self.forceTickle = True self.forceTickle = True
@ -3428,7 +3428,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
r = self.getIrcdMode(irc, self.registryValue( r = self.getIrcdMode(irc, self.registryValue(
'cloneMode', channel=channel), best) 'cloneMode', channel=channel), best)
self._act(irc, channel, r[0], r[1], self.registryValue( self._act(irc, channel, r[0], r[1], self.registryValue(
'cloneDuration', channel=channel), self.registryValue('cloneComment', channel)) 'cloneDuration', channel=channel), self.registryValue('cloneComment', channel), msg.nick)
self.forceTickle = True self.forceTickle = True
self._tickle(irc) self._tickle(irc)
@ -3515,7 +3515,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
best = best + '$' + forward best = best + '$' + forward
r = self.getIrcdMode(irc, mode, best) r = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, self._act(irc, channel,
r[0], r[1], duration, comment) r[0], r[1], duration, comment, msg.nick)
self.forceTickle = True self.forceTickle = True
if canRemove: if canRemove:
self._rmNick(irc, n) self._rmNick(irc, n)
@ -3723,7 +3723,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
best = best + '$' + forward best = best + '$' + forward
r = self.getIrcdMode(irc, mode, best) r = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, self._act(irc, channel,
r[0], r[1], duration, comment) r[0], r[1], duration, comment, msg.nick)
self.forceTickle = True self.forceTickle = True
if removeNick: if removeNick:
i = self.getIrc(irc) i = self.getIrc(irc)
@ -3786,7 +3786,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
comment = self.registryValue( comment = self.registryValue(
'%sComment' % kind, channel=channel) '%sComment' % kind, channel=channel)
r = self.getIrcdMode(irc, mode, best) r = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, r[0], r[1], duration, comment) self._act(irc, channel, r[0], r[1], duration, comment, newNick)
self.forceTickle = True self.forceTickle = True
self._tickle(irc) self._tickle(irc)
@ -3796,6 +3796,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
def doAccount(self, irc, msg): def doAccount(self, irc, msg):
# update nick's model # update nick's model
n = None n = None
nick = None
if ircutils.isUserHostmask(msg.prefix): if ircutils.isUserHostmask(msg.prefix):
nick = ircutils.nickFromHostmask(msg.prefix) nick = ircutils.nickFromHostmask(msg.prefix)
n = self.getNick(irc, nick) n = self.getNick(irc, nick)
@ -3807,7 +3808,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
n.addLog('ALL', '%s is now identified as %s' % (old, acc)) n.addLog('ALL', '%s is now identified as %s' % (old, acc))
else: else:
return return
if n and n.account and n.ip: if n and n.account and n.ip and nick:
i = self.getIrc(irc) i = self.getIrc(irc)
for channel in irc.state.channels: for channel in irc.state.channels:
if self.registryValue('checkEvade', channel=channel): if self.registryValue('checkEvade', channel=channel):
@ -3837,7 +3838,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
r = self.getIrcdMode(irc, found.mode, getBestPattern(n, irc, self.registryValue( r = self.getIrcdMode(irc, found.mode, getBestPattern(n, irc, self.registryValue(
'useIpForGateway', channel=channel), self.registryValue('resolveIp'))[0]) 'useIpForGateway', channel=channel), self.registryValue('resolveIp'))[0])
self._act(irc, channel, r[0], r[1], duration, 'evade of [#%s +%s %s]' % ( self._act(irc, channel, r[0], r[1], duration, 'evade of [#%s +%s %s]' % (
found.uid, found.mode, found.value)) found.uid, found.mode, found.value), nick)
f = None f = None
if self.registryValue('announceBotMark', channel=found.channel): if self.registryValue('announceBotMark', channel=found.channel):
f = self._logChan f = self._logChan
@ -3904,7 +3905,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
'%sComment' % kind, channel=channel) '%sComment' % kind, channel=channel)
r = self.getIrcdMode(irc, mode, best) r = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, self._act(irc, channel,
r[0], r[1], duration, comment) r[0], r[1], duration, comment, msg.nick)
self.forceTickle = True self.forceTickle = True
if self.registryValue('announceNotice', channel=channel): if self.registryValue('announceNotice', channel=channel):
if not chan.isWrong(best): if not chan.isWrong(best):
@ -4040,7 +4041,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
if isPattern: if isPattern:
r = self.getIrcdMode(irc, isPattern.mode, best) r = self.getIrcdMode(irc, isPattern.mode, best)
self._act( self._act(
irc, channel, r[0], r[1], isPattern.duration, 'matches #%s' % isPattern.uid) irc, channel, r[0], r[1], isPattern.duration, 'matches #%s' % isPattern.uid, msg.nick)
isBad = self._isBad(irc, channel, best) isBad = self._isBad(irc, channel, best)
self.forceTickle = True self.forceTickle = True
chan.countpattern( chan.countpattern(
@ -4061,7 +4062,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
'repeatMode', channel=channel), best) 'repeatMode', channel=channel), best)
# hidden reason matches "%s"' % isTemporaryPattern # hidden reason matches "%s"' % isTemporaryPattern
self._act(irc, channel, r[0], r[1], self.registryValue( self._act(irc, channel, r[0], r[1], self.registryValue(
'repeatDuration', channel=channel), '') 'repeatDuration', channel=channel), 'temporary pattern', msg.nick)
isBad = self._isBad(irc, channel, best) isBad = self._isBad(irc, channel, best)
self.forceTickle = True self.forceTickle = True
elif not isPattern and not isTemporaryPattern: elif not isPattern and not isTemporaryPattern:
@ -4120,7 +4121,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
'%sComment' % kind, channel=channel) '%sComment' % kind, channel=channel)
r = self.getIrcdMode(irc, mode, best) r = self.getIrcdMode(irc, mode, best)
self._act(irc, channel, self._act(irc, channel,
r[0], r[1], duration, comment) r[0], r[1], duration, comment, msg.nick)
self.forceTickle = True self.forceTickle = True
if not chan.isWrong(best): if not chan.isWrong(best):
# prevent the bot to flood logChannel with bad user craps # prevent the bot to flood logChannel with bad user craps
@ -4559,7 +4560,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
# protection features # protection features
def _act(self, irc, channel, mode, mask, duration, reason): def _act(self, irc, channel, mode, mask, duration, reason, nick):
if mode == 'D': if mode == 'D':
action = self.registryValue('modeD') action = self.registryValue('modeD')
if len(action): if len(action):
@ -4572,6 +4573,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
s = s.replace('$host', h) s = s.replace('$host', h)
s = s.replace('$duration', str(duration)) s = s.replace('$duration', str(duration))
s = s.replace('$reason', reason) s = s.replace('$reason', reason)
s = s.replace('$nick', nick)
irc.queueMsg(ircmsgs.IrcMsg(s)) irc.queueMsg(ircmsgs.IrcMsg(s))
return return
if mode == 'd': if mode == 'd':