X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fnickserv.rb;h=8768895282c1f85760055f639e842f48c648b69f;hb=24bb60775741d3731400f1e430ef6bf3a2e1b933;hp=7a9ff0c601f40ca83891f90d407f3199895a1d8c;hpb=1dc872c99dccc0c34cb15c4083b7a70d4266d635;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb index 7a9ff0c6..87688952 100644 --- a/data/rbot/plugins/nickserv.rb +++ b/data/rbot/plugins/nickserv.rb @@ -1,25 +1,50 @@ +#-- vim:sw=2:et +#++ +# +# :title: Nickserv management plugin for rbot +# +# Author:: Tom Gilbert (giblet) +# Author:: Giuseppe "Oblomov" Bilotta +# +# Copyright:: (C) 2002-2005 Tom Gilbert +# Copyright:: (C) 2006 Tom Gilbert, Giuseppe Bilotta +# Copyright:: (C) 2006-2007 Giuseppe Bilotta +# # Automatically lookup nicks in @registry and identify when asked +# # Takes over proper nick if required and nick is registered -# TODO allow custom IDENTIFY and GHOST names + +# TODO:: allow custom IDENTIFY and GHOST names +# +# FIXME:: identified? status returns false after a rescan, even if the bot +# previously identified successfully class NickServPlugin < Plugin - BotConfig.register BotConfigStringValue.new('nickserv.name', + Config.register Config::StringValue.new('nickserv.name', :default => "nickserv", :requires_restart => false, :desc => "Name of the nick server (all lowercase)") - BotConfig.register BotConfigStringValue.new('nickserv.ident_request', + + Config.register Config::StringValue.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 BotConfigStringValue.new('nickserv.nick_avail', + Config.register Config::StringValue.new('nickserv.nick_avail', :default => "not (currently )?online|killed|recovered|disconnesso|libero", :requires_restart => false, :on_change => Proc.new { |bot, v| bot.plugins.delegate "set_nick_avail", v }, :desc => "String to look for to see if the nick server is informing us that our nick is now available") - BotConfig.register BotConfigBooleanValue.new('nickserv.wants_nick', + Config.register Config::StringValue.new('nickserv.identified_string', + :default => "(Password|Contrase|Mot de passe).+(acce[pt]t|r[ie]cog?n).+(identif|r[ie]cog?n)", + :requires_restart => false, + :on_change => Proc.new { |bot, v| bot.plugins.delegate "set_identified_string", v }, + :desc => "String to look for to see if the nick server is informing us that we have identified successfully") + + Config.register Config::BooleanValue.new('nickserv.wants_nick', :default => false, :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', + + Config.register Config::IntegerValue.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") @@ -39,7 +64,7 @@ class NickServPlugin < Plugin end def genpasswd - return Irc::Auth.random_password + return Irc::Bot::Auth.random_password end def set_ident_request(val) @@ -50,6 +75,10 @@ class NickServPlugin < Plugin @nick_avail = Regexp.new(val) end + def set_identified_string(val) + @identified_string = Regexp.new(val) + end + def initialize super # this plugin only wants to store strings! @@ -63,6 +92,8 @@ class NickServPlugin < Plugin end set_ident_request(@bot.config['nickserv.ident_request']) set_nick_avail(@bot.config['nickserv.nick_avail']) + set_identified_string(@bot.config['nickserv.identified_string']) + @identified = false end # Returns the nickserv name @@ -138,6 +169,7 @@ class NickServPlugin < Plugin end def connect + @identified = false do_identify end @@ -158,9 +190,17 @@ class NickServPlugin < Plugin when @nick_avail debug "our nick seems to be free now" @bot.nickchg @bot.config['irc.nick'] + when @identified_string + debug "we identified successfully to nickserv" + @identified = true + @bot.plugins.delegate('identified') end end + def identified? + return @identified + end + end plugin = NickServPlugin.new plugin.map 'nickserv password [:nick] :passwd', :action => "password"