summaryrefslogtreecommitdiff
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
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.
-rw-r--r--data/rbot/plugins/nickserv.rb32
-rw-r--r--lib/rbot/ircbot.rb2
2 files changed, 31 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
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 51457a56..eb194e68 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -178,6 +178,7 @@ class IrcBot
}
@client[:nicktaken] = proc { |data|
nickchg "#{data[:nick]}_"
+ @plugins.delegate "nicktaken", data[:nick]
}
@client[:badnick] = proc {|data|
puts "WARNING, bad nick (#{data[:nick]})"
@@ -301,6 +302,7 @@ class IrcBot
users.each {|u|
@channels[channel].users[u[0].sub(/^[@&~+]/, '')] = ["mode", u[1]]
}
+ @plugins.delegate "names"
}
@client[:unknown] = proc {|data|
#debug "UNKNOWN: #{data[:serverstring]}"