X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fnickserv.rb;h=5c2e068f79d58b1725c50a4f6a4fa39e543e7d00;hb=6b4751c8b6e99dcff80cfe5e66c746cf9106dc6a;hp=ad77dff7add5ff13e50e2ff0775ab1b4b7b2d775;hpb=d1717e487f9781dfc2eca55fd006191ca55725aa;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb index ad77dff7..5c2e068f 100644 --- a/data/rbot/plugins/nickserv.rb +++ b/data/rbot/plugins/nickserv.rb @@ -7,12 +7,15 @@ class NickServPlugin < Plugin BotConfig.register BotConfigStringValue.new('nickserv.name', - :default => "NickServ", :requires_restart => false, - :desc => "Name of the nick server") + :default => "nickserv", :requires_restart => false, + :desc => "Name of the nick server (all lowercase)") BotConfig.register BotConfigStringValue.new('nickserv.ident_request', :default => "IDENTIFY", :requires_restart => false, :on_change => Proc.new { |bot, v| bot.plugins.delegate "set_ident_request", v }, :desc => "String to look for to see if the nick server is asking us to identify") + BotConfig.register BotConfigBooleanValue.new('nickserv.wants_nick', + :default => true, :requires_restart => false, + :desc => "Set to false if the nick server doesn't expect the nick as a parameter in the identify command") BotConfig.register BotConfigIntegerValue.new('nickserv.wait', :default => 30, :validate => Proc.new { |v| v > 0 }, :requires_restart => false, :desc => "Seconds to wait after sending a message to nickserv, e.g. after ghosting") @@ -60,7 +63,14 @@ class NickServPlugin < Plugin end def password(m, params) - @registry[params[:nick]] = params[:passwd] + nick = params[:nick] || @bot.nick + passwd = params[:passwd] + if nick == @bot.nick + @bot.say @bot.config['nickserv.name'], "SET PASSWORD #{passwd}" + else + m.reply "I'm only changing this in my database, I won't inform #{@bot.config['nickserv.name']} of the change" + end + @registry[nick] = passwd m.okay end @@ -85,7 +95,16 @@ class NickServPlugin < Plugin def do_identify(nick=@bot.nick) if @registry.has_key?(nick) - @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{nick} #{@registry[nick]}" + if @bot.config['nickserv.wants_nick'] + @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{nick} #{@registry[nick]}" + else + if nick == @bot.nick + @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{@registry[nick]}" + else + # We cannot identify for different nicks if we can't use the nickname ... + return false + end + end return true end return false @@ -105,17 +124,20 @@ class NickServPlugin < Plugin def nicktaken(nick) if @registry.has_key?(nick) - @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "GHOST #{nick} #{@registry[@bot.nick]}" - do_identify nick - sleep @bot.config['nickserv.wait'] - @bot.nickchg nick - # We need to wait after changing nick, otherwise the server - # might refuse to execute further commangs, e.g. subsequent JOIN - # commands until the nick has changed. - sleep @bot.config['nickserv.wait'] + @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "GHOST #{nick} #{@registry[nick]}" + if do_identify nick + sleep @bot.config['nickserv.wait'] + @bot.nickchg nick + # We need to wait after changing nick, otherwise the server + # might refuse to execute further commangs, e.g. subsequent JOIN + # commands until the nick has changed. + sleep @bot.config['nickserv.wait'] + else + debug "Failed to identify for nick #{nick}, cannot take over" + end end end - + def listen(m) return unless(m.kind_of? NoticeMessage) @@ -127,8 +149,11 @@ class NickServPlugin < Plugin end plugin = NickServPlugin.new -plugin.map 'nickserv password :nick :passwd', :action => "password" +plugin.map 'nickserv password [:nick] :passwd', :action => "password" plugin.map 'nickserv register :passwd :email', :action => 'nick_register', :defaults => {:passwd => false, :email => false} plugin.map 'nickserv listnicks', :action => "listnicks" plugin.map 'nickserv identify', :action => "identify" + +plugin.default_auth('*', false) +