Skip to content
Browse files

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

…xtra).
  • Loading branch information...
1 parent 74273b0 commit 4eb674843e17a4c4521df5dc75adfd207ace9471 @ProgVal committed
Showing with 19 additions and 0 deletions.
  1. +3 −0 plugins/AutoMode/config.py
  2. +16 −0 plugins/AutoMode/plugin.py
View
3 plugins/AutoMode/config.py
@@ -75,5 +75,8 @@ def configure(advanced):
registry.Integer(0, _("""Determines how many seconds the bot will wait
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:
View
16 plugins/AutoMode/plugin.py
@@ -108,6 +108,22 @@ def unban():
irc.queueMsg(ircmsgs.ban(channel, banmask))
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

0 comments on commit 4eb6748

Please sign in to comment.
Something went wrong with that request. Please try again.