- def help(plugin, topic="")
- "perform autoop based on hostmask - usage: addop <hostmask> [channel channel ...], rmop <hostmask> [channel], list - list current ops. If you don't specify which channels, all channels are assumed"
- end
-
- def join(m)
- return if m.address?
+ Config.register Config::BooleanValue.new('autoop.on_nick',
+ :default => true,
+ :desc => "Determines if the bot should auto-op when someone changes nick " +
+ "and the new nick matches a listed netmask")
+
+ Config.register Config::StringValue.new('autoop.seed_format',
+ :default => "*!%{user}@*",
+ :desc => "Hostmask format used when seeding channels. Recognized tokens: " +
+ "nick, user, host")
+
+ def help(plugin, topic="")
+ return "perform autoop based on hostmask - usage:" +
+ "add <hostmask> [channel channel ...], rm <hostmask> [channel], " +
+ "If you don't specify which channels, all channels are assumed, " +
+ "list - list current ops, " +
+ "restore [channel] - op anybody that would " +
+ "have been opped if they had just joined, " +
+ "seed [channel] - Find current ops and make sure they will " +
+ "continue to be autoopped"
+ end
+
+ def join(m)
+ return if m.address?
+ @registry.each { |mask,channels|
+ if m.source.matches?(mask.to_irc_netmask(:server => m.server)) &&
+ (channels.empty? || channels.include?(m.channel.to_s))
+ @bot.mode(m.channel, "+o", m.source.nick)
+ return
+ end
+ }
+ end
+
+ def nick(m)
+ return if m.address?
+ return unless @bot.config['autoop.on_nick']
+ is_on = m.server.channels.inject(ChannelList.new) { |list, ch|
+ list << ch if ch.users.include?(m.source)
+ list
+ }
+ is_on.each { |channel|
+ ch = channel.to_s