- 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")
+
+ def help(plugin, topic="")
+ return "perform autoop based on hostmask - usage: add <hostmask> [channel channel ...], rm <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?
+ @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