summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/nickserv.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-28 21:44:18 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-06-28 21:44:18 +0000
commit849a727c9f1334c5b5e31b76e52a9cc07009e588 (patch)
tree24c38f5387af243d06066d7d5d22ceb32a17a85f /data/rbot/plugins/nickserv.rb
parentd764894efae89970e22bad48db4c76d878b35630 (diff)
There are now three nickserv config options (name, ident_request, wait). The bot now also kills any ghosts that use its nick. Close ticket #88. Also provide a workaround for ticket #58.
Diffstat (limited to 'data/rbot/plugins/nickserv.rb')
-rw-r--r--data/rbot/plugins/nickserv.rb32
1 files changed, 29 insertions, 3 deletions
diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb
index 93b0b015..ff375d15 100644
--- a/data/rbot/plugins/nickserv.rb
+++ b/data/rbot/plugins/nickserv.rb
@@ -1,7 +1,19 @@
# automatically lookup nicks in @registry and identify when asked
+# TODO customize name of nickserv
class NickServPlugin < Plugin
+ BotConfig.register BotConfigStringValue.new('nickserv.name',
+ :default => "NickServ", :requires_restart => false,
+ :desc => "Name of the nick server")
+ 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 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")
+
def help(plugin, topic="")
case topic
when ""
@@ -26,6 +38,10 @@ class NickServPlugin < Plugin
return passwd
end
+ def set_ident_request(val)
+ @ident_request = Regexp.new(val)
+ end
+
def initialize
super
# this plugin only wants to store strings!
@@ -37,17 +53,19 @@ class NickServPlugin < Plugin
val
end
end
+ set_ident_request(@bot.config['nickserv.ident_request'])
end
def password(m, params)
@registry[params[:nick]] = params[:passwd]
m.okay
end
+
def nick_register(m, params)
passwd = params[:passwd] ? params[:passwd] : genpasswd
message = "REGISTER #{passwd}"
message += " #{params[:email]}" if params[:email]
- @bot.sendmsg "PRIVMSG", "NickServ", message
+ @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], message
@registry[@bot.nick] = passwd
m.okay
end
@@ -64,7 +82,7 @@ class NickServPlugin < Plugin
def do_identify
if @registry.has_key?(@bot.nick)
- @bot.sendmsg "PRIVMSG", "NickServ", "IDENTIFY #{@registry[@bot.nick]}"
+ @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "IDENTIFY #{@registry[@bot.nick]}"
return true
end
return false
@@ -82,10 +100,18 @@ class NickServPlugin < Plugin
do_identify
end
+ def nicktaken(nick)
+ if @registry.has_key?(nick)
+ @bot.sendmsg "PRIVMSG", @bot.config['nickserv.name'], "GHOST #{nick} #{@registry[@bot.nick]}"
+ sleep @bot.config['nickserv.wait']
+ @bot.nickchg nick
+ end
+ end
+
def listen(m)
return unless(m.kind_of? NoticeMessage)
- if (m.sourcenick == "NickServ" && m.message =~ /IDENTIFY/)
+ if (m.sourcenick == @bot.config['nickserv.name'] && m.message =~ @ident_request)
debug "nickserv asked us to identify for nick #{@bot.nick}"
do_identify
end