X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fusermodes.rb;h=bc85f8f4a05657f2b1a5e0951011eef424e49afe;hb=052217de30c59206d7025b582d4604557a747470;hp=5f6e9bff3d4521d96a85e3a3c8501fa78e255a9f;hpb=8352107a0fd9e57a40fd948793d1daac7b66bf1a;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/usermodes.rb b/data/rbot/plugins/usermodes.rb index 5f6e9bff..bc85f8f4 100644 --- a/data/rbot/plugins/usermodes.rb +++ b/data/rbot/plugins/usermodes.rb @@ -1,114 +1,26 @@ -class OpPlugin < Plugin +#-- vim:sw=2:et +#++ +# +# :title: Usermodes plugin +# +# Author:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2007 Giuseppe Bilotta +# License:: rbot's licence +# + +class UserModesPlugin < Plugin + Config.register Config::StringValue.new('irc.usermodes', + :default => '', + :desc => "User modes to set when connecting to the server") 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." + "handles automatic usermode settings on connect. See the config variable irc.usermodes" 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) + def connect + modes = @bot.config['irc.usermodes'] + @bot.mode(@bot.nick, modes, '') unless modes.empty? 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) - +plugin = UserModesPlugin.new