From d6a80e795a64c91244f1d2a96763f5c41e9722ff Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 10 Feb 2007 08:58:54 +0000 Subject: Ahem. Rename usermodes plugin to modes plugin :D. Are we done with this yet? --- data/rbot/plugins/modes.rb | 114 +++++++++++++++++++++++++++++++++++++++++ data/rbot/plugins/usermodes.rb | 114 ----------------------------------------- 2 files changed, 114 insertions(+), 114 deletions(-) create mode 100644 data/rbot/plugins/modes.rb delete mode 100644 data/rbot/plugins/usermodes.rb (limited to 'data') diff --git a/data/rbot/plugins/modes.rb b/data/rbot/plugins/modes.rb new file mode 100644 index 00000000..9f2a4380 --- /dev/null +++ b/data/rbot/plugins/modes.rb @@ -0,0 +1,114 @@ +class ModesPlugin < Plugin + + def help(plugin, topic="") + return "'op [] []' => grant user> (if ommitted yourself) ops in (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 hop(m, params) + channel = params[:channel] + user = params[:user] + do_mode(m, channel, user, "+h") + end + + def hopme(m, params) + params[:user] = m.sourcenick + hop(m, params) + end + + def dehop(m, params) + channel = params[:channel] + user = params[:user] + do_mode(m, channel, user, "-h") + end + + def dehopme(m, params) + params[:user] = m.sourcenick + dehop(m, params) + end + + def voice(m, params) + channel = params[:channel] + user = params[:user] + do_mode(m, channel, user, "+v") + end + + def voiceme(m, params) + params[:user] = m.sourcenick + voice(m, params) + end + + def devoice(m, params) + channel = params[:channel] + user = params[:user] + do_mode(m, channel, user, "-v") + end + + def devoiceme(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 #{mode} #{target}." + return + else + 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.mode(channel, mode, user) + end +end + +plugin = ModesPlugin.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.map("hop [:user] [:channel]") +plugin.map("hopme [:channel]") +plugin.map("dehop [:user] [:channel]") +plugin.map("dehopme [:channel]") +plugin.map("voice [:user] [:channel]") +plugin.map("voiceme [:channel]") +plugin.map("devoice [:user] [:channel]") +plugin.map("devoiceme [:channel]") +plugin.default_auth("*",false) + diff --git a/data/rbot/plugins/usermodes.rb b/data/rbot/plugins/usermodes.rb deleted file mode 100644 index 5f6e9bff..00000000 --- a/data/rbot/plugins/usermodes.rb +++ /dev/null @@ -1,114 +0,0 @@ -class OpPlugin < Plugin - - def help(plugin, topic="") - return "'op [] []' => grant user> (if ommitted yourself) ops in (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 hop(m, params) - channel = params[:channel] - user = params[:user] - do_mode(m, channel, user, "+h") - end - - def hopme(m, params) - params[:user] = m.sourcenick - hop(m, params) - end - - def dehop(m, params) - channel = params[:channel] - user = params[:user] - do_mode(m, channel, user, "-h") - end - - def dehopme(m, params) - params[:user] = m.sourcenick - dehop(m, params) - end - - def voice(m, params) - channel = params[:channel] - user = params[:user] - do_mode(m, channel, user, "+v") - end - - def voiceme(m, params) - params[:user] = m.sourcenick - voice(m, params) - end - - def devoice(m, params) - channel = params[:channel] - user = params[:user] - do_mode(m, channel, user, "-v") - end - - def devoiceme(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 #{mode} #{target}." - return - else - 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.mode(channel, mode, user) - 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.map("hop [:user] [:channel]") -plugin.map("hopme [:channel]") -plugin.map("dehop [:user] [:channel]") -plugin.map("dehopme [:channel]") -plugin.map("voice [:user] [:channel]") -plugin.map("voiceme [:channel]") -plugin.map("devoice [:user] [:channel]") -plugin.map("devoiceme [:channel]") -plugin.default_auth("*",false) - -- cgit v1.2.3