AutoMode: Add support for extra modes (add supybot.plugins.AutoMode.extra).

This commit is contained in:
Valentin Lorentz 2012-09-17 17:06:34 +02:00
parent 74273b0d84
commit 4eb674843e
2 changed files with 19 additions and 0 deletions

View File

@ -75,5 +75,8 @@ conf.registerChannelValue(AutoMode, 'delay',
registry.Integer(0, _("""Determines how many seconds the bot will wait registry.Integer(0, _("""Determines how many seconds the bot will wait
before applying a mode. Has no effect on bans."""))) before applying a mode. Has no effect on bans.""")))
conf.registerChannelValue(AutoMode, 'extra',
registry.SpaceSeparatedListOfStrings([], _("""Extra modes that will be
applied to a user. Example syntax: user1+o-v user2+v user3-v""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -108,6 +108,22 @@ class AutoMode(callbacks.Plugin):
irc.queueMsg(ircmsgs.ban(channel, banmask)) irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, msg.nick)) irc.queueMsg(ircmsgs.kick(channel, msg.nick))
user = ircdb.users.getUser(ircdb.users.getUserId(msg.prefix))
pattern = re.compile('-\+')
for item in self.registryValue('extra', channel):
try:
username, modes = pattern.split(item, maxsplit=1)
except ValueError: # No - or + in item
log.error('%r is not a valid item for '
'supybot.plugins.AutoMode.extra')
continue
if username != user.name:
continue
else:
schedule_msg(ircmsgs.mode(msg.nick, modes), lambda :True)
break
Class = AutoMode Class = AutoMode