mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-26 13:01:06 -05:00
added optional wildcard for bans/quiets on gateway/*/ip.* > *@*ip
This commit is contained in:
parent
b20c703365
commit
c30bb66ddf
@ -60,6 +60,9 @@ conf.registerGlobalValue(ChanTracker, 'unquietCommand',
|
|||||||
conf.registerGlobalValue(ChanTracker, 'announceNagInterval',
|
conf.registerGlobalValue(ChanTracker, 'announceNagInterval',
|
||||||
registry.Integer(300,"""interval between two check about announceNagMode, this setting is global."""))
|
registry.Integer(300,"""interval between two check about announceNagMode, this setting is global."""))
|
||||||
|
|
||||||
|
conf.registerChannelValue(ChanTracker, 'useIpForGateway',
|
||||||
|
registry.Boolean(False, """use *!*@*ip bans instead of *!ident@gateway/* when gateways cloak is found and ends with ip.*"""))
|
||||||
|
|
||||||
#now per channel
|
#now per channel
|
||||||
|
|
||||||
conf.registerChannelValue(ChanTracker, 'opCommand',
|
conf.registerChannelValue(ChanTracker, 'opCommand',
|
||||||
|
61
plugin.py
61
plugin.py
@ -200,7 +200,7 @@ def match (pattern,n,irc):
|
|||||||
log.error('%s pattern is not supported' % pattern)
|
log.error('%s pattern is not supported' % pattern)
|
||||||
return cache[key]
|
return cache[key]
|
||||||
|
|
||||||
def getBestPattern (n,irc):
|
def getBestPattern (n,irc,useIp=False):
|
||||||
# return best pattern for a given Nick
|
# return best pattern for a given Nick
|
||||||
match(n.prefix,n,irc)
|
match(n.prefix,n,irc)
|
||||||
results = []
|
results = []
|
||||||
@ -219,17 +219,24 @@ def getBestPattern (n,irc):
|
|||||||
m = a[0]+':'+a[1]+':'+a[2]+':'+a[3]+':*'
|
m = a[0]+':'+a[1]+':'+a[2]+':'+a[3]+':*'
|
||||||
results.append('*!%s@%s' % (ident,m))
|
results.append('*!%s@%s' % (ident,m))
|
||||||
else:
|
else:
|
||||||
results.append('*!%s@%s' % (ident,n.ip))
|
if useIp:
|
||||||
|
results.append('*!%s@*%s' % (ident,n.ip))
|
||||||
|
else:
|
||||||
|
results.append('*!%s@%s' % (ident,n.ip))
|
||||||
if host.find('/') != -1:
|
if host.find('/') != -1:
|
||||||
# cloaks
|
# cloaks
|
||||||
if host.startswith('gateway/'):
|
if host.startswith('gateway/'):
|
||||||
h = host.split('/')
|
if useIp and host.find('ip.') != -1:
|
||||||
# gateway/type/(domain|account) [?/random]
|
ident = '*'
|
||||||
p = ''
|
host = '*%s' % host.split('ip.')[1]
|
||||||
if len(h) > 3:
|
else:
|
||||||
p = '/*'
|
h = host.split('/')
|
||||||
h = h[:3]
|
# gateway/type/(domain|account) [?/random]
|
||||||
host = '%s%s' % ('/'.join(h),p)
|
p = ''
|
||||||
|
if len(h) > 3:
|
||||||
|
p = '/*'
|
||||||
|
h = h[:3]
|
||||||
|
host = '%s%s' % ('/'.join(h),p)
|
||||||
elif host.startswith('nat/'):
|
elif host.startswith('nat/'):
|
||||||
h = host.replace('nat/','')
|
h = host.replace('nat/','')
|
||||||
if h.find('/') != -1:
|
if h.find('/') != -1:
|
||||||
@ -1641,7 +1648,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
returns a list of hostmask's pattern, best first, mostly used for debug"""
|
returns a list of hostmask's pattern, best first, mostly used for debug"""
|
||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
if prefix in i.nicks:
|
if prefix in i.nicks:
|
||||||
irc.reply(' '.join(getBestPattern(self.getNick(irc,prefix),irc)))
|
irc.reply(' '.join(getBestPattern(self.getNick(irc,prefix),irc,self.registryValue('useIpForGateway'))))
|
||||||
else:
|
else:
|
||||||
n = Nick(0)
|
n = Nick(0)
|
||||||
#gecos ( $x )
|
#gecos ( $x )
|
||||||
@ -1654,7 +1661,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
else:
|
else:
|
||||||
n.setPrefix(prefix)
|
n.setPrefix(prefix)
|
||||||
if ircutils.isUserHostmask(prefix):
|
if ircutils.isUserHostmask(prefix):
|
||||||
irc.reply(' '.join(getBestPattern(n,irc)))
|
irc.reply(' '.join(getBestPattern(n,irc,self.registryValue('useIpForGateway'))))
|
||||||
return
|
return
|
||||||
irc.reply('nick not found or wrong hostmask given')
|
irc.reply('nick not found or wrong hostmask given')
|
||||||
getmask = wrap(getmask,['op','text'])
|
getmask = wrap(getmask,['op','text'])
|
||||||
@ -1677,7 +1684,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
if nick in i.nicks:
|
if nick in i.nicks:
|
||||||
chan = self.getChan(irc,channel)
|
chan = self.getChan(irc,channel)
|
||||||
irc.reply(chan.isWrong(getBestPattern(self.getNick(irc,nick),irc)[0]))
|
irc.reply(chan.isWrong(getBestPattern(self.getNick(irc,nick),irc,self.registryValue('useIpForGateway'))[0]))
|
||||||
else:
|
else:
|
||||||
irc.reply('nick not found')
|
irc.reply('nick not found')
|
||||||
isbad = wrap(isbad,['op','nick'])
|
isbad = wrap(isbad,['op','nick'])
|
||||||
@ -1737,7 +1744,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
for item in items:
|
for item in items:
|
||||||
if item in chan.nicks or item in irc.state.channels[channel].users:
|
if item in chan.nicks or item in irc.state.channels[channel].users:
|
||||||
n = self.getNick(irc,item)
|
n = self.getNick(irc,item)
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
# when resync patterns may be empty, until the bot computed WHO
|
# when resync patterns may be empty, until the bot computed WHO
|
||||||
if len(patterns):
|
if len(patterns):
|
||||||
targets.append(patterns[0])
|
targets.append(patterns[0])
|
||||||
@ -1934,10 +1941,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
chan = self.getChan(irc,channel)
|
chan = self.getChan(irc,channel)
|
||||||
# check expired items
|
# check expired items
|
||||||
for mode in list(chan.getItems().keys()):
|
for mode in list(chan.getItems().keys()):
|
||||||
|
l = len(list(chan._lists[mode].keys()))
|
||||||
for value in list(chan._lists[mode].keys()):
|
for value in list(chan._lists[mode].keys()):
|
||||||
item = chan._lists[mode][value]
|
item = chan._lists[mode][value]
|
||||||
if item.expire != None and item.expire != item.when and not item.asked and item.expire <= t:
|
if item.expire != None and item.expire != item.when and not item.asked and item.expire <= t:
|
||||||
if mode == 'q' and item.value.find(self.getIrcdExtbansPrefix(irc)) == -1 and self.registryValue('useChanServForQuiets',channel=channel) and not irc.nick in irc.state.channels[channel].ops and not len(chan.queue):
|
if mode == 'q' and l == 1 and self.registryValue('useChanServForQuiets',channel=channel) and not irc.nick in irc.state.channels[channel].ops and not len(chan.queue):
|
||||||
s = self.registryValue('unquietCommand')
|
s = self.registryValue('unquietCommand')
|
||||||
s = s.replace('$channel',channel)
|
s = s.replace('$channel',channel)
|
||||||
s = s.replace('$hostmask',item.value)
|
s = s.replace('$hostmask',item.value)
|
||||||
@ -1952,9 +1960,10 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
# if chan.syn: # remove syn mandatory for support to unreal which doesn't like q list
|
# if chan.syn: # remove syn mandatory for support to unreal which doesn't like q list
|
||||||
if len(chan.queue):
|
if len(chan.queue):
|
||||||
index = 0
|
index = 0
|
||||||
|
l = len(list(chan.queue))
|
||||||
for item in list(chan.queue):
|
for item in list(chan.queue):
|
||||||
(mode,value) = item
|
(mode,value) = item
|
||||||
if mode == '+q' and value.find(self.getIrcdExtbansPrefix(irc)) == -1 and self.registryValue('useChanServForQuiets',channel=channel) and not irc.nick in irc.state.channels[channel].ops and len(chan.queue) == 1:
|
if mode == '+q' and l == 1 and self.registryValue('useChanServForQuiets',channel=channel) and not irc.nick in irc.state.channels[channel].ops and len(chan.queue) == 1:
|
||||||
s = self.registryValue('quietCommand')
|
s = self.registryValue('quietCommand')
|
||||||
s = s.replace('$channel',channel)
|
s = s.replace('$channel',channel)
|
||||||
s = s.replace('$hostmask',value)
|
s = s.replace('$hostmask',value)
|
||||||
@ -2228,7 +2237,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if 'LIST' in i.caps and 'extended-join' in i.caps['LIST'] and len(msg.args) == 3:
|
if 'LIST' in i.caps and 'extended-join' in i.caps['LIST'] and len(msg.args) == 3:
|
||||||
n.setRealname(msg.args[2])
|
n.setRealname(msg.args[2])
|
||||||
n.setAccount(msg.args[1])
|
n.setAccount(msg.args[1])
|
||||||
best = getBestPattern(n,irc)[0]
|
best = getBestPattern(n,irc,self.registryValue('useIpForGateway'))[0]
|
||||||
if msg.nick == irc.nick:
|
if msg.nick == irc.nick:
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
@ -2269,7 +2278,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
n = self.getNick(irc,msg.nick)
|
n = self.getNick(irc,msg.nick)
|
||||||
n.setPrefix(msg.prefix)
|
n.setPrefix(msg.prefix)
|
||||||
reason = ''
|
reason = ''
|
||||||
best = getBestPattern(n,irc)[0]
|
best = getBestPattern(n,irc,self.registryValue('useIpForGateway'))[0]
|
||||||
if len(msg.args) == 2:
|
if len(msg.args) == 2:
|
||||||
reason = msg.args[1].lstrip().rstrip()
|
reason = msg.args[1].lstrip().rstrip()
|
||||||
canRemove = True
|
canRemove = True
|
||||||
@ -2379,7 +2388,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def _rmNick (self,irc,n):
|
def _rmNick (self,irc,n):
|
||||||
def nrm():
|
def nrm():
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
if not len(patterns):
|
if not len(patterns):
|
||||||
return
|
return
|
||||||
@ -2440,7 +2449,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
return
|
return
|
||||||
if not isBot:
|
if not isBot:
|
||||||
n = self.getNick(irc,msg.nick)
|
n = self.getNick(irc,msg.nick)
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
best = None
|
best = None
|
||||||
if len(patterns):
|
if len(patterns):
|
||||||
best = patterns[0]
|
best = patterns[0]
|
||||||
@ -2504,7 +2513,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
n = self.getNick(irc,newNick)
|
n = self.getNick(irc,newNick)
|
||||||
n.addLog('ALL','%s is now known as %s' % (oldNick,newNick))
|
n.addLog('ALL','%s is now known as %s' % (oldNick,newNick))
|
||||||
best = None
|
best = None
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
if len(patterns):
|
if len(patterns):
|
||||||
best = patterns[0]
|
best = patterns[0]
|
||||||
if not best:
|
if not best:
|
||||||
@ -2603,11 +2612,11 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
duration = -1
|
duration = -1
|
||||||
if found.expire and found.expire != found.when:
|
if found.expire and found.expire != found.when:
|
||||||
duration = int(found.expire-time.time())
|
duration = int(found.expire-time.time())
|
||||||
self._act (irc,channel,found.mode,getBestPattern(n,irc)[0],duration,'evade of [#%s +%s %s]' % (found.uid,found.mode,found.value))
|
self._act (irc,channel,found.mode,getBestPattern(n,irc,self.registryValue('useIpForGateway'))[0],duration,'evade of [#%s +%s %s]' % (found.uid,found.mode,found.value))
|
||||||
f = None
|
f = None
|
||||||
if self.registryValue('announceBotMark',channel=found.channel):
|
if self.registryValue('announceBotMark',channel=found.channel):
|
||||||
f = self._logChan
|
f = self._logChan
|
||||||
i.mark(irc,found.uid,'evade with %s --> %s' % (msg.prefix,getBestPattern(n,irc)[0]),irc.prefix,self.getDb(irc.network),f,self)
|
i.mark(irc,found.uid,'evade with %s --> %s' % (msg.prefix,getBestPattern(n,irc,self.registryValue('useIpForGateway'))[0]),irc.prefix,self.getDb(irc.network),f,self)
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
|
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
@ -2635,7 +2644,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if msg.nick == irc.nick:
|
if msg.nick == irc.nick:
|
||||||
return
|
return
|
||||||
n = self.getNick(irc,msg.nick)
|
n = self.getNick(irc,msg.nick)
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
best = False
|
best = False
|
||||||
if len(patterns):
|
if len(patterns):
|
||||||
best = patterns[0]
|
best = patterns[0]
|
||||||
@ -2692,6 +2701,8 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
|
|
||||||
def _isVip (self,irc,channel,n):
|
def _isVip (self,irc,channel,n):
|
||||||
|
if n.prefix == irc.prefix:
|
||||||
|
return True
|
||||||
protected = ircdb.makeChannelCapability(channel, 'protected')
|
protected = ircdb.makeChannelCapability(channel, 'protected')
|
||||||
if ircdb.checkCapability(n.prefix, protected):
|
if ircdb.checkCapability(n.prefix, protected):
|
||||||
return True
|
return True
|
||||||
@ -2715,7 +2726,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
if ircutils.isUserHostmask(msg.prefix):
|
if ircutils.isUserHostmask(msg.prefix):
|
||||||
n = self.getNick(irc,msg.nick)
|
n = self.getNick(irc,msg.nick)
|
||||||
patterns = getBestPattern(n,irc)
|
patterns = getBestPattern(n,irc,self.registryValue('useIpForGateway'))
|
||||||
if len(patterns):
|
if len(patterns):
|
||||||
best = patterns[0]
|
best = patterns[0]
|
||||||
# if it fails here stacktrace
|
# if it fails here stacktrace
|
||||||
@ -2998,7 +3009,7 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if msg.nick != irc.nick and self.registryValue('askOpAboutMode',channel=channel) and ircdb.checkCapability(msg.prefix, '%s,op' % channel):
|
if msg.nick != irc.nick and self.registryValue('askOpAboutMode',channel=channel) and ircdb.checkCapability(msg.prefix, '%s,op' % channel):
|
||||||
data = [item.uid,m,value,channel,msg.prefix,'For [#%s %s %s in %s - %s user(s)] type <duration> <reason>, you have 3 minutes' % (item.uid,'+%s' % m,value,channel,len(item.affects)),False]
|
data = [item.uid,m,value,channel,msg.prefix,'For [#%s %s %s in %s - %s user(s)] type <duration> <reason>, you have 3 minutes' % (item.uid,'+%s' % m,value,channel,len(item.affects)),False]
|
||||||
if self.registryValue('useColorForAnnounces',channel=channel):
|
if self.registryValue('useColorForAnnounces',channel=channel):
|
||||||
data[5] = 'For [#%s +%s %s in %s - %s user(s)] type <duration> <reason>, you have 3 minutes' % (ircutils.mircColor(item.uid,'yellow','black'),ircutils.bold(ircutils.mircColor('+%s' % m,'green')),ircutils.mircColor(value,'light blue'),channel,len(item.affects))
|
data[5] = 'For [#%s %s %s in %s - %s user(s)] type <duration> <reason>, you have 3 minutes' % (ircutils.mircColor(item.uid,'yellow','black'),ircutils.bold(ircutils.mircColor('+%s' % m,'green')),ircutils.mircColor(value,'light blue'),channel,len(item.affects))
|
||||||
self.addToAsked (irc,msg.prefix,data,msg.nick)
|
self.addToAsked (irc,msg.prefix,data,msg.nick)
|
||||||
if overexpire > 0:
|
if overexpire > 0:
|
||||||
if msg.nick != irc.nick:
|
if msg.nick != irc.nick:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user