mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-26 21:11:13 -05:00
modified announceMode, now it's announceModes with list of modes to announce, you can also choose to use notice or privmsg for announces
This commit is contained in:
parent
a02eabca9d
commit
f11f327e90
@ -83,11 +83,11 @@ 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).
|
registry.Boolean(True,"""forward messages from quieted/banned users to logChannel; used when bot stays opped and channel is +z (reduced moderation).
|
||||||
Messages from users flagged as bad, or when channel is under attack will not be forwarded"""))
|
Messages from users flagged as bad, or when channel is under attack will not be forwarded"""))
|
||||||
|
|
||||||
conf.registerChannelValue(ChanTracker, 'announceMode',
|
conf.registerChannelValue(ChanTracker, 'announceWithNotice',
|
||||||
registry.Boolean(True,"""announce all channel mode changes to logChannel"""))
|
registry.Boolean(False,"""use NOTICE instead of PRIVMSG to logChannel"""))
|
||||||
|
|
||||||
conf.registerChannelValue(ChanTracker, 'announceVoiceAndOpMode',
|
conf.registerChannelValue(ChanTracker, 'announceModes',
|
||||||
registry.Boolean(True,"""announce channel mode changes for op, halfop and voice to logChannel"""))
|
registry.CommaSeparatedListOfStrings(['b','q','e','I','r','l','v','o','h','k','n','t','F'],"""announce modes listed to logChannel"""))
|
||||||
|
|
||||||
conf.registerChannelValue(ChanTracker, 'announceModeSync',
|
conf.registerChannelValue(ChanTracker, 'announceModeSync',
|
||||||
registry.Boolean(False,"""announce to logChannel that synchronisation of channel modes to tracking database has completed"""))
|
registry.Boolean(False,"""announce to logChannel that synchronisation of channel modes to tracking database has completed"""))
|
||||||
|
35
plugin.py
35
plugin.py
@ -58,8 +58,7 @@ def applymodes(channel, args=(), prefix='', msg=None):
|
|||||||
modes = args
|
modes = args
|
||||||
if msg and not prefix:
|
if msg and not prefix:
|
||||||
prefix = msg.prefix
|
prefix = msg.prefix
|
||||||
return ircmsgs.IrcMsg(prefix=prefix, command='MODE',
|
return ircmsgs.IrcMsg(prefix=prefix, command='MODE', args=[channel] + ircutils.joinModes(modes), msg=msg)
|
||||||
args=[channel] + ircutils.joinModes(modes), msg=msg)
|
|
||||||
|
|
||||||
def matchHostmask (pattern,n):
|
def matchHostmask (pattern,n):
|
||||||
# return the machted pattern for Nick
|
# return the machted pattern for Nick
|
||||||
@ -1973,6 +1972,9 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
logChannel = self.registryValue('logChannel',channel=channel)
|
logChannel = self.registryValue('logChannel',channel=channel)
|
||||||
if logChannel in irc.state.channels:
|
if logChannel in irc.state.channels:
|
||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
|
if self.registryValue ('announceWithNotice',channel=channel):
|
||||||
|
i.lowQueue.enqueue(ircmsgs.notice(logChannel,message))
|
||||||
|
else:
|
||||||
i.lowQueue.enqueue(ircmsgs.privmsg(logChannel,message))
|
i.lowQueue.enqueue(ircmsgs.privmsg(logChannel,message))
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
|
|
||||||
@ -2669,14 +2671,16 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
modes = ircutils.separateModes(msg.args[1:])
|
modes = ircutils.separateModes(msg.args[1:])
|
||||||
chan = self.getChan(irc,channel)
|
chan = self.getChan(irc,channel)
|
||||||
msgs = []
|
msgs = []
|
||||||
|
announces = list(self.registryValue('announceModes',channel=channel))
|
||||||
overexpire = self.registryValue('autoExpire',channel=channel)
|
overexpire = self.registryValue('autoExpire',channel=channel)
|
||||||
for change in modes:
|
for change in modes:
|
||||||
(mode,value) = change
|
(mode,value) = change
|
||||||
|
m = mode[1:]
|
||||||
|
log.debug('%s - %s / %s' % (mode,value,m))
|
||||||
if value:
|
if value:
|
||||||
value = value.lstrip().rstrip()
|
value = str(value).lstrip().rstrip()
|
||||||
item = None
|
item = None
|
||||||
if '+' in mode:
|
if '+' in mode:
|
||||||
m = mode[1:]
|
|
||||||
if m in self.registryValue('modesToAskWhenOpped',channel=channel) or m in self.registryValue('modesToAsk',channel=channel):
|
if m in self.registryValue('modesToAskWhenOpped',channel=channel) or m in self.registryValue('modesToAsk',channel=channel):
|
||||||
item = chan.addItem(m,value,msg.prefix,now,self.getDb(irc.network))
|
item = chan.addItem(m,value,msg.prefix,now,self.getDb(irc.network))
|
||||||
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):
|
||||||
@ -2728,7 +2732,6 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
# flush pending queue, if items are waiting
|
# flush pending queue, if items are waiting
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
else:
|
else:
|
||||||
m = mode[1:]
|
|
||||||
if m == 'o' and value == irc.nick:
|
if m == 'o' and value == irc.nick:
|
||||||
# prevent bot to sent many -o modes when server takes time to reply
|
# prevent bot to sent many -o modes when server takes time to reply
|
||||||
chan.deopAsked = False
|
chan.deopAsked = False
|
||||||
@ -2740,40 +2743,39 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
if item:
|
if item:
|
||||||
if '+' in mode:
|
if '+' in mode:
|
||||||
if not len(item.affects):
|
if not len(item.affects):
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s]' % (str(item.uid),mode,value))
|
msgs.append('[#%s %s %s]' % (str(item.uid),mode,value))
|
||||||
elif len(item.affects) != 1:
|
elif len(item.affects) != 1:
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s - %s users]' % (str(item.uid),mode,value,str(len(item.affects))))
|
msgs.append('[#%s %s %s - %s users]' % (str(item.uid),mode,value,str(len(item.affects))))
|
||||||
else:
|
else:
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s - %s]' % (str(item.uid),mode,value,item.affects[0]))
|
msgs.append('[#%s %s %s - %s]' % (str(item.uid),mode,value,item.affects[0]))
|
||||||
else:
|
else:
|
||||||
if not len(item.affects):
|
if not len(item.affects):
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s %s]' % (str(item.uid),mode,value,str(utils.timeElapsed(item.removed_at-item.when))))
|
msgs.append('[#%s %s %s %s]' % (str(item.uid),mode,value,str(utils.timeElapsed(item.removed_at-item.when))))
|
||||||
elif len(item.affects) != 1:
|
elif len(item.affects) != 1:
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s - %s users, %s]' % (str(item.uid),mode,value,str(len(item.affects)),str(utils.timeElapsed(item.removed_at-item.when))))
|
msgs.append('[#%s %s %s - %s users, %s]' % (str(item.uid),mode,value,str(len(item.affects)),str(utils.timeElapsed(item.removed_at-item.when))))
|
||||||
else:
|
else:
|
||||||
if self.registryValue('announceMode',channel=channel):
|
if m in announces:
|
||||||
msgs.append('[#%s %s %s - %s, %s]' % (str(item.uid),mode,value,item.affects[0],str(utils.timeElapsed(item.removed_at-item.when))))
|
msgs.append('[#%s %s %s - %s, %s]' % (str(item.uid),mode,value,item.affects[0],str(utils.timeElapsed(item.removed_at-item.when))))
|
||||||
else:
|
else:
|
||||||
if mode.find ('o') != -1 or mode.find('h') != -1 or mode.find ('v') != -1:
|
if m in announces:
|
||||||
if self.registryValue('announceVoiceAndOpMode',channel=channel):
|
|
||||||
msgs.append('[%s %s]' % (mode,value))
|
|
||||||
else:
|
|
||||||
msgs.append('[%s %s]' % (mode,value))
|
msgs.append('[%s %s]' % (mode,value))
|
||||||
else:
|
else:
|
||||||
|
log.debug('%s --> %s' % (m,m in announces))
|
||||||
if n:
|
if n:
|
||||||
n.addLog(channel,'sets %s' % mode)
|
n.addLog(channel,'sets %s' % mode)
|
||||||
|
if m in announces:
|
||||||
msgs.append(mode)
|
msgs.append(mode)
|
||||||
if toCommit:
|
if toCommit:
|
||||||
db.commit()
|
db.commit()
|
||||||
c.close()
|
c.close()
|
||||||
if irc.nick in irc.state.channels[channel].ops and not self.registryValue('keepOp',channel=channel):
|
if irc.nick in irc.state.channels[channel].ops and not self.registryValue('keepOp',channel=channel):
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
if self.registryValue('announceMode',channel=channel) and len(msgs):
|
if len(self.registryValue('announceModes',channel=channel)) and len(msgs):
|
||||||
self._logChan(irc,channel,'[%s] %s sets %s' % (channel,msg.nick,' '.join(msgs)))
|
self._logChan(irc,channel,'[%s] %s sets %s' % (channel,msg.nick,' '.join(msgs)))
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
if len(toexpire):
|
if len(toexpire):
|
||||||
@ -2801,7 +2803,6 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
def do478(self,irc,msg):
|
def do478(self,irc,msg):
|
||||||
# message when ban list is full after adding something to eqIb list
|
# message when ban list is full after adding something to eqIb list
|
||||||
(nick,channel,ban,info) = msg.args
|
(nick,channel,ban,info) = msg.args
|
||||||
if info == 'Channel ban list is full':
|
|
||||||
if self.registryValue('logChannel',channel=channel) in irc.state.channels:
|
if self.registryValue('logChannel',channel=channel) in irc.state.channels:
|
||||||
L = []
|
L = []
|
||||||
for user in list(irc.state.channels[self.registryValue('logChannel',channel=channel)].users):
|
for user in list(irc.state.channels[self.registryValue('logChannel',channel=channel)].users):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user