diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-16 00:19:33 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-16 00:19:33 +0000 |
commit | 9e20940da4694a352a1a11476756d9dd7e021d4a (patch) | |
tree | 4ddca9cee6c6b4946c2e2f5c6c7b780f7a8e7c5d /rbot | |
parent | a00f2d697f4dc87a5568ebdd4946385ce51d9ba7 (diff) |
autoop plugin submitted by Rene Nussbaumer, tweaked by me.
Diffstat (limited to 'rbot')
-rw-r--r-- | rbot/plugins/autoop.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/rbot/plugins/autoop.rb b/rbot/plugins/autoop.rb new file mode 100644 index 00000000..094ee343 --- /dev/null +++ b/rbot/plugins/autoop.rb @@ -0,0 +1,68 @@ +class AutoOP < Plugin + @@handlers = { + "addop" => "handle_addop", + "rmop" => "handle_rmop", + "listop" => "handle_listop" + } + + def help(plugin, topic="") + "perform autoop based on hostmask - usage: addop <hostmask>, rmop <hostmask>, listop" + end + + def join(m) + if(!m.address?) + @registry.each { |mask,channels| + if(Irc.netmaskmatch(mask, m.source) && channels.include?(m.channel)) + @bot.mode(m.channel, "+o", m.sourcenick) + end + } + end + end + + def privmsg(m) + if(m.private?) + if (!m.params || m.params == "list") + handle_listop(m) + elsif (m.params =~ /^add\s+(.+)$/) + handle_addop(m, $1) + elsif (m.params =~ /^rm\s+(.+)$/) + handle_rmop(m, $1) + end + end + end + + def handle_addop(m, params) + ma = /^(.+?)(\s+(.+))?$/.match(params) + channels = ma[2] ? ma[2] : @bot.config['JOIN_CHANNELS'] + if(ma[1] && channels) + @registry[ma[1]] = channels.split(/,\s*/).collect { |x| + x.strip + } + @bot.okay m.replyto + else + m.reply @bot.lang.get('dunno') + end + end + + def handle_rmop(m, params) + if(!@registry.delete(params)) + m.reply @bot.lang.get('dunno') + else + @bot.okay m.replyto + end + end + + def handle_listop(m) + if(@registry.length) + @registry.each { |mask,channels| + m.reply "#{mask} in #{channels.join(', ')}" + } + else + m.reply "No entrys" + end + end +end + +plugin = AutoOP.new +plugin.register("autoop") + |