diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-10 08:40:02 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-10 08:40:02 +0000 |
commit | 1d6478e8f22053749038bf660d34da10791f5c80 (patch) | |
tree | b0041a218c39ace29a0af64de724ba7c88879cde | |
parent | ed4d4a6901683105e75b3704dfbbf494e1def84b (diff) |
op plugin: also provide a deop command. Thanks to Yaohan Chen
-rw-r--r-- | data/rbot/plugins/op.rb | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/data/rbot/plugins/op.rb b/data/rbot/plugins/op.rb index 6ebbc603..217f9c2f 100644 --- a/data/rbot/plugins/op.rb +++ b/data/rbot/plugins/op.rb @@ -1,38 +1,62 @@ class OpPlugin < Plugin def help(plugin, topic="") - return "op [<user>] [<channel>] => grant <user> (if ommitted yourself) ops in <channel> (or in the current channel if no channel is specified)" + return "'op [<user>] [<channel>]' => grant user> (if ommitted yourself) ops in <channel> (or in the current channel if no channel is specified). Use deop instead of op to remove the privilege." end def op(m, params) channel = params[:channel] user = params[:user] + do_mode(m, channel, user, "+o") + end + + def opme(m, params) + params[:user] = m.sourcenick + op(m, params) + end + + def deop(m, params) + channel = params[:channel] + user = params[:user] + do_mode(m, channel, user, "-o") + end + + def deopme(m, params) + params[:user] = m.sourcenick + deop(m, params) + end + + def do_mode(m, channel, user, mode) unless channel if m.private? target = user.nil? ? "you" : user - m.reply "You should tell me where you want me to op #{target}." + m.reply "You should tell me where you want me to #{mode} #{target}." return else - channel = m.channel.to_s + channel = m.channel + end + else + channel = m.server.channel(channel) + + unless channel.has_user?(@bot.nick) + m.reply "I am not in that channel" + return end end + unless user user = m.sourcenick end m.okay unless channel == m.channel.to_s - @bot.sendq("MODE #{channel} +o #{user}") + @bot.mode(channel, mode, user) end - - def opme(m, params) - params[:user] = m.sourcenick - op(m, params) - end - end plugin = OpPlugin.new plugin.map("op [:user] [:channel]") plugin.map("opme [:channel]") # For backwards compatibility with 0.9.10 +plugin.map("deop [:user] [:channel]") +plugin.map("deopme [:channel]") # For backwards compatibility with 0.9.10 plugin.default_auth("*",false) |