mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-25 20:41:19 -05:00
Make 'isvip' output differentiate between types.
Also drop capability checks off functions where they are already done at command level.
This commit is contained in:
parent
7fe15a15d8
commit
0ff2476e87
14
README.md
14
README.md
@ -28,11 +28,11 @@ Then `@load ChanTracker`.
|
|||||||
@b,e,i,q [<channel>] <nick|hostmask>[,<nick|hostmask>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1> or empty means forever] <reason>) -- +mode targets for duration <reason> is mandatory
|
@b,e,i,q [<channel>] <nick|hostmask>[,<nick|hostmask>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1> or empty means forever] <reason>) -- +mode targets for duration <reason> is mandatory
|
||||||
@ub,ue,ui,uq [<channel>] <nick|hostmask|*> [<nick|hostmask>]) -- sets -mode on them, if * found, remove them all
|
@ub,ue,ui,uq [<channel>] <nick|hostmask|*> [<nick|hostmask>]) -- sets -mode on them, if * found, remove them all
|
||||||
@check [<channel>] <pattern> returns list of users who will be affected by such pattern
|
@check [<channel>] <pattern> returns list of users who will be affected by such pattern
|
||||||
@edit <id> [,<id>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1>] means forever) -- change expiration of some active modes
|
@edit <id>[,<id>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1>] means forever) -- change expiration of some active modes
|
||||||
@info <id> returns information about a mode change
|
@info <id> returns information about a mode change
|
||||||
@affect <id> returns affected users by a mode placed
|
@affect <id> returns affected users by a mode placed
|
||||||
@mark <id> [,<id>] <message> add a comment about a mode change
|
@mark <id>[,<id>] <message> add a comment about a mode change
|
||||||
@editandmark <id> [,<id>] [,<id>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1>] [<comment>] edit duration and add comment on a mode change
|
@editandmark <id>[,<id>] [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] [<-1>] [<comment>] edit duration and add comment on a mode change
|
||||||
@pending [<channel>] (pending [--mode=<e|b|q|l>] [--oper=<nick|hostmask>] [--never] [<channel>] ) -- returns active items for --mode if given, filtered by --oper if given, --never never expire only if given
|
@pending [<channel>] (pending [--mode=<e|b|q|l>] [--oper=<nick|hostmask>] [--never] [<channel>] ) -- returns active items for --mode if given, filtered by --oper if given, --never never expire only if given
|
||||||
@query [--deep] [--never] [--active] [--channel=<channel>] <pattern|hostmask|comment>) -- search inside ban database, --deep to search on log, --never returns items set forever and active, --active returns only active modes, --channel reduces results to a specific channel
|
@query [--deep] [--never] [--active] [--channel=<channel>] <pattern|hostmask|comment>) -- search inside ban database, --deep to search on log, --never returns items set forever and active, --active returns only active modes, --channel reduces results to a specific channel
|
||||||
@match [<channel>] <nick|hostmask> returns list of modes that affects the nick,hostmask given
|
@match [<channel>] <nick|hostmask> returns list of modes that affects the nick,hostmask given
|
||||||
@ -42,7 +42,7 @@ Then `@load ChanTracker`.
|
|||||||
@summary [<channel>] returns some stats about <channel>
|
@summary [<channel>] returns some stats about <channel>
|
||||||
@addpattern [<channel>] <limit> <life> <mode>(qbeId) [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] <pattern>) add a <pattern> which triggers <mode> for <duration> if the <pattern> appears more than <limit> (0 for immediate action) during <life> in seconds
|
@addpattern [<channel>] <limit> <life> <mode>(qbeId) [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] <pattern>) add a <pattern> which triggers <mode> for <duration> if the <pattern> appears more than <limit> (0 for immediate action) during <life> in seconds
|
||||||
@addregexpattern [<channel>] <limit> <life> <mode>(qbeId) [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] /<pattern>/) add a <pattern> which triggers <mode> for <duration> if the <pattern> appears more than <limit> (0 for immediate action) during <life> in seconds
|
@addregexpattern [<channel>] <limit> <life> <mode>(qbeId) [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] /<pattern>/) add a <pattern> which triggers <mode> for <duration> if the <pattern> appears more than <limit> (0 for immediate action) during <life> in seconds
|
||||||
@rmpattern [<channel>] <id> [<id>] remove patterns
|
@rmpattern [<channel>] <id>[,<id>] remove patterns
|
||||||
@lspattern [<channel>] [<id|pattern>] return patterns in <channel> filtered by optional <pattern> or <id>
|
@lspattern [<channel>] [<id|pattern>] return patterns in <channel> filtered by optional <pattern> or <id>
|
||||||
@addtmp [<channel>] <pattern> add temporary pattern which follows repeat punishments
|
@addtmp [<channel>] <pattern> add temporary pattern which follows repeat punishments
|
||||||
@rmtmp [<channel>] remove temporary patterns if any
|
@rmtmp [<channel>] remove temporary patterns if any
|
||||||
@ -307,10 +307,10 @@ Maintaining separate bots for the banning/bantracking functions and other factoi
|
|||||||
or amusement functions is good practice.
|
or amusement functions is good practice.
|
||||||
|
|
||||||
If the main purpose of your bot is to manage bans etc and never interact with users, you should remove all plugins
|
If the main purpose of your bot is to manage bans etc and never interact with users, you should remove all plugins
|
||||||
from `defaultcapabilities`, which will prevent the bot from responding to various commands and being used as a
|
from the default capabilities, which will prevent the bot from responding to various commands and being used as a
|
||||||
flood tool by others (like with `@echo SPAM`):
|
flood tool by others (like with `@echo SPAM`):
|
||||||
|
|
||||||
@defaultcapabilities remove <pluginname>
|
@defaultcapability remove <pluginname>
|
||||||
|
|
||||||
You could otherwise change the value of `supybot.capabilities.default`, but be prepared to waste a lot of time
|
You could otherwise change the value of `supybot.capabilities.default`, but be prepared to waste a lot of time
|
||||||
each time you add a new user account on your bot. If the setting is changed to `False`, then when you want to grant
|
each time you add a new user account on your bot. If the setting is changed to `False`, then when you want to grant
|
||||||
@ -320,7 +320,7 @@ access to a command for someone, you must do it this way:
|
|||||||
@admin capability add <accountname> User.whoami
|
@admin capability add <accountname> User.whoami
|
||||||
@admin capability add <accountname> whoami
|
@admin capability add <accountname> whoami
|
||||||
|
|
||||||
If your bot manages different channels or communities, remove all `User.<action>` from `defaultcapabilities`,
|
If your bot manages different channels or communities, remove all `User.<action>` from the default capabilities,
|
||||||
create one user per channel/community, and add ops' hostmasks to it -- it's easier to manage this way.
|
create one user per channel/community, and add ops' hostmasks to it -- it's easier to manage this way.
|
||||||
Until you have someone with rights in multiple channels/communities, who will need a separate account.
|
Until you have someone with rights in multiple channels/communities, who will need a separate account.
|
||||||
|
|
||||||
|
53
plugin.py
53
plugin.py
@ -455,8 +455,6 @@ class Ircd(object):
|
|||||||
# returns active items for a channel mode
|
# returns active items for a channel mode
|
||||||
if not (channel and mode and prefix):
|
if not (channel and mode and prefix):
|
||||||
return []
|
return []
|
||||||
if not ircdb.checkCapability(prefix, '%s,op' % channel):
|
|
||||||
return []
|
|
||||||
chan = self.getChan(irc, channel)
|
chan = self.getChan(irc, channel)
|
||||||
results = []
|
results = []
|
||||||
r = []
|
r = []
|
||||||
@ -509,8 +507,6 @@ class Ircd(object):
|
|||||||
# returns active items that match n
|
# returns active items that match n
|
||||||
if not (channel and n and db):
|
if not (channel and n and db):
|
||||||
return []
|
return []
|
||||||
if not ircdb.checkCapability(prefix, '%s,op' % channel):
|
|
||||||
return []
|
|
||||||
chan = self.getChan(irc, channel)
|
chan = self.getChan(irc, channel)
|
||||||
results = []
|
results = []
|
||||||
r = []
|
r = []
|
||||||
@ -1185,9 +1181,6 @@ class Chan(object):
|
|||||||
return i
|
return i
|
||||||
|
|
||||||
def addpattern(self, prefix, limit, life, mode, duration, pattern, regexp, db):
|
def addpattern(self, prefix, limit, life, mode, duration, pattern, regexp, db):
|
||||||
if not (ircdb.checkCapability(prefix, '%s,op' % self.name)
|
|
||||||
or prefix == irc.prefix):
|
|
||||||
return False
|
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
c.execute("""INSERT INTO patterns VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)""",
|
c.execute("""INSERT INTO patterns VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)""",
|
||||||
(self.name, prefix, time.time(), pattern, regexp, limit, life, mode, duration))
|
(self.name, prefix, time.time(), pattern, regexp, limit, life, mode, duration))
|
||||||
@ -1201,9 +1194,6 @@ class Chan(object):
|
|||||||
return '[#%s "%s"%s]' % (uid, pattern, r)
|
return '[#%s "%s"%s]' % (uid, pattern, r)
|
||||||
|
|
||||||
def rmpattern(self, prefix, uid, db):
|
def rmpattern(self, prefix, uid, db):
|
||||||
if not (ircdb.checkCapability(prefix, '%s,op' % self.name)
|
|
||||||
or prefix == irc.prefix):
|
|
||||||
return False
|
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
c.execute("""SELECT id,channel,pattern,regexp FROM patterns
|
c.execute("""SELECT id,channel,pattern,regexp FROM patterns
|
||||||
WHERE id=? and channel=? LIMIT 1""", (uid, self.name))
|
WHERE id=? and channel=? LIMIT 1""", (uid, self.name))
|
||||||
@ -1235,9 +1225,6 @@ class Chan(object):
|
|||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
def lspattern(self, prefix, pattern, db):
|
def lspattern(self, prefix, pattern, db):
|
||||||
if not (ircdb.checkCapability(prefix, '%s,op' % self.name)
|
|
||||||
or prefix != irc.prefix):
|
|
||||||
return []
|
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
results = []
|
results = []
|
||||||
items = []
|
items = []
|
||||||
@ -1842,7 +1829,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
for result in results:
|
for result in results:
|
||||||
irc.queueMsg(ircmsgs.privmsg(msg.nick, result))
|
irc.queueMsg(ircmsgs.privmsg(msg.nick, result))
|
||||||
else:
|
else:
|
||||||
irc.reply('no result')
|
irc.reply('nothing found')
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
pending = wrap(pending, ['op', getopts({'flood': '', 'mode': 'letter', 'never': '',
|
pending = wrap(pending, ['op', getopts({'flood': '', 'mode': 'letter', 'never': '',
|
||||||
@ -2097,7 +2084,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
if len(results):
|
if len(results):
|
||||||
irc.reply(' '.join(results), private=True)
|
irc.reply(' '.join(results), private=True)
|
||||||
else:
|
else:
|
||||||
irc.reply('no results or unknown mode')
|
irc.reply('nothing found or unknown mode')
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
overlap = wrap(overlap, ['op', 'text'])
|
overlap = wrap(overlap, ['op', 'text'])
|
||||||
@ -2151,7 +2138,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
if len(results):
|
if len(results):
|
||||||
irc.reply(' '.join(results), private=True)
|
irc.reply(' '.join(results), private=True)
|
||||||
else:
|
else:
|
||||||
irc.reply('no results')
|
irc.reply('nothing found')
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
match = wrap(match, ['op', 'text'])
|
match = wrap(match, ['op', 'text'])
|
||||||
|
|
||||||
@ -2185,9 +2172,9 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
"""[<channelSource>] <channelMode> <channelTarget> <targetMode> [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] <reason>
|
"""[<channelSource>] <channelMode> <channelTarget> <targetMode> [<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s] <reason>
|
||||||
|
|
||||||
copy <channelSource> <channelMode> elements in <channelTarget> on <targetMode>; <-1> or empty means forever"""
|
copy <channelSource> <channelMode> elements in <channelTarget> on <targetMode>; <-1> or empty means forever"""
|
||||||
op = ircdb.makeChannelCapability(target, 'protected')
|
op = ircdb.makeChannelCapability(target, 'op')
|
||||||
if not ircdb.checkCapability(msg.prefix, op):
|
if not ircdb.checkCapability(msg.prefix, op):
|
||||||
irc.errorNoCapability('%s,op' % target)
|
irc.errorNoCapability(op)
|
||||||
return
|
return
|
||||||
chan = self.getChan(irc, channel)
|
chan = self.getChan(irc, channel)
|
||||||
targets = set([])
|
targets = set([])
|
||||||
@ -2232,8 +2219,10 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
tell if <nick> is vip in <channel>; mostly used for debugging"""
|
tell if <nick> is vip in <channel>; mostly used for debugging"""
|
||||||
i = self.getIrc(irc)
|
i = self.getIrc(irc)
|
||||||
if nick in i.nicks:
|
if nick in i.nicks:
|
||||||
isVip = self._isVip(irc, channel, self.getNick(irc, nick))
|
vip = self._isVip(irc, channel, self.getNick(irc, nick))
|
||||||
irc.reply(str(isVip))
|
if not vip:
|
||||||
|
vip = 'no vip'
|
||||||
|
irc.reply('%s is %s' % (nick, vip))
|
||||||
else:
|
else:
|
||||||
irc.reply('nick not found')
|
irc.reply('nick not found')
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
@ -2323,10 +2312,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
chan = self.getChan(irc, channel)
|
chan = self.getChan(irc, channel)
|
||||||
result = chan.addpattern(msg.prefix, limit, life, mode, getDuration(duration),
|
result = chan.addpattern(msg.prefix, limit, life, mode, getDuration(duration),
|
||||||
pattern, 0, self.getDb(irc.network))
|
pattern, 0, self.getDb(irc.network))
|
||||||
if result:
|
irc.reply(result)
|
||||||
irc.reply(result)
|
|
||||||
else:
|
|
||||||
irc.reply('not enough rights to add a pattern on %s' % channel)
|
|
||||||
addpattern = wrap(addpattern, ['op', 'nonNegativeInt', 'positiveInt', 'letter',
|
addpattern = wrap(addpattern, ['op', 'nonNegativeInt', 'positiveInt', 'letter',
|
||||||
any('getTs', True), rest('text')])
|
any('getTs', True), rest('text')])
|
||||||
|
|
||||||
@ -2338,17 +2324,14 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
chan = self.getChan(irc, channel)
|
chan = self.getChan(irc, channel)
|
||||||
result = chan.addpattern(msg.prefix, limit, life, mode, getDuration(duration),
|
result = chan.addpattern(msg.prefix, limit, life, mode, getDuration(duration),
|
||||||
pattern[0], 1, self.getDb(irc.network))
|
pattern[0], 1, self.getDb(irc.network))
|
||||||
if result:
|
irc.reply(result)
|
||||||
irc.reply(result)
|
|
||||||
else:
|
|
||||||
irc.reply('not enough rights to add a pattern on %s' % channel)
|
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
addregexpattern = wrap(addregexpattern, ['op', 'nonNegativeInt', 'positiveInt', 'letter',
|
addregexpattern = wrap(addregexpattern, ['op', 'nonNegativeInt', 'positiveInt', 'letter',
|
||||||
any('getTs', True), rest('getPatternAndMatcher')])
|
any('getTs', True), rest('getPatternAndMatcher')])
|
||||||
|
|
||||||
def rmpattern(self, irc, msg, args, channel, ids):
|
def rmpattern(self, irc, msg, args, channel, ids):
|
||||||
"""[<channel>] <id> [<id>]
|
"""[<channel>] <id>[,<id>]
|
||||||
|
|
||||||
remove patterns by <id>"""
|
remove patterns by <id>"""
|
||||||
results = []
|
results = []
|
||||||
@ -2360,7 +2343,7 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
if len(results):
|
if len(results):
|
||||||
irc.reply('%s removed: %s' % (len(results), ','.join(results)))
|
irc.reply('%s removed: %s' % (len(results), ','.join(results)))
|
||||||
else:
|
else:
|
||||||
irc.reply('not found or not enough rights')
|
irc.reply('nothing found')
|
||||||
self.forceTickle = True
|
self.forceTickle = True
|
||||||
self._tickle(irc)
|
self._tickle(irc)
|
||||||
rmpattern = wrap(rmpattern, ['op', many('positiveInt')])
|
rmpattern = wrap(rmpattern, ['op', many('positiveInt')])
|
||||||
@ -3916,17 +3899,17 @@ class ChanTracker(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
|
|
||||||
def _isVip(self, irc, channel, n):
|
def _isVip(self, irc, channel, n):
|
||||||
if n.prefix == irc.prefix:
|
if n.prefix == irc.prefix:
|
||||||
return True
|
return 'me!'
|
||||||
if ircdb.checkCapability(n.prefix, 'trusted'):
|
if ircdb.checkCapability(n.prefix, 'trusted'):
|
||||||
return True
|
return 'trusted'
|
||||||
if ircdb.checkCapability(n.prefix, 'protected'):
|
if ircdb.checkCapability(n.prefix, 'protected'):
|
||||||
return True
|
return 'protected'
|
||||||
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 'protected'
|
||||||
if self.registryValue('ignoreVoicedUser', channel=channel, network=irc.network) \
|
if self.registryValue('ignoreVoicedUser', channel=channel, network=irc.network) \
|
||||||
and irc.state.channels[channel].isVoicePlus(n.prefix.split('!')[0]):
|
and irc.state.channels[channel].isVoicePlus(n.prefix.split('!')[0]):
|
||||||
return True
|
return 'voiced'
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user