diff options
author | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-28 23:55:59 +0000 |
---|---|---|
committer | Tom Gilbert <tom@linuxbrit.co.uk> | 2005-07-28 23:55:59 +0000 |
commit | 8caeee3853ef66dd0e326ff17906f9ca544b8a35 (patch) | |
tree | 03faa650efa4ca6ed11bcc4faec1f2ee4ab3a9dc /data/rbot/plugins | |
parent | da8e3efa6400c25f4e572c4187a15a37c72af6b8 (diff) |
Thu Jul 28 23:45:26 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
* Reworked the Timer module. The Timer now has a smart thread manager to
start/stop the tick() thread. This means the timer isn't called every 0.1
seconds to see what needs doing, which is much more efficient
* reworked the ircsocket queue mechanism to use a Timer
* reworked the nickserv plugin to use maps
* made server.reconnect_wait configurable
* added Class tracing mechanism to bin/rbot, use --trace Classname for
debugging
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/cal.rb | 2 | ||||
-rw-r--r-- | data/rbot/plugins/nickserv.rb | 92 |
2 files changed, 42 insertions, 52 deletions
diff --git a/data/rbot/plugins/cal.rb b/data/rbot/plugins/cal.rb index 4f28310b..dd1d1538 100644 --- a/data/rbot/plugins/cal.rb +++ b/data/rbot/plugins/cal.rb @@ -1,6 +1,6 @@ class CalPlugin < Plugin def help(plugin, topic="") - "cal [options] => show current calendar [unix cal options]" + "cal [month year] => show current calendar [optionally specify month and year]" end def cal(m, params) if params.has_key?(:month) diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb index 1ef2baf7..246f253c 100644 --- a/data/rbot/plugins/nickserv.rb +++ b/data/rbot/plugins/nickserv.rb @@ -17,6 +17,15 @@ class NickServPlugin < Plugin end end + def genpasswd + # generate a random password + passwd = "" + 8.times do + passwd += (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr + end + return passwd + end + def initialize super # this plugin only wants to store strings! @@ -29,49 +38,34 @@ class NickServPlugin < Plugin end end end - - def privmsg(m) - return unless m.params - - case m.params - when (/^password\s*(\S*)\s*(.*)$/) - nick = $1 - passwd = $2 - @registry[nick] = passwd - m.okay - when (/^register$/) - passwd = genpasswd - @bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd - @registry[@bot.nick] = passwd - m.okay - when (/^register\s*(\S*)\s*(.*)$/) - passwd = $1 - email = $2 - @bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd + " " + email - @registry[@bot.nick] = passwd - m.okay - when (/^register\s*(.*)\s*$/) - passwd = $1 - @bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd - @registry[@bot.nick] = passwd + + 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 + @registry[@bot.nick] = passwd + m.okay + end + def listnicks(m, params) + if @registry.length > 0 + @registry.each {|k,v| + @bot.say m.sourcenick, "#{k} => #{v}" + } + else + m.reply "none known" + end + end + def identify(m, params) + if @registry.has_key?(@bot.nick) + @bot.sendmsg "PRIVMSG", "NickServ", "IDENTIFY #{@registry[@bot.nick]}" m.okay - when (/^listnicks$/) - if @bot.auth.allow?("config", m.source, m.replyto) - if @registry.length > 0 - @registry.each {|k,v| - @bot.say m.sourcenick, "#{k} => #{v}" - } - else - m.reply "none known" - end - end - when (/^identify$/) - if @registry.has_key?(@bot.nick) - @bot.sendmsg "PRIVMSG", "NickServ", "IDENTIFY " + @registry[@bot.nick] - m.okay - else - m.reply "I dunno the nickserv password for the nickname #{@bot.nick} :(" - end + else + m.reply "I dunno the nickserv password for the nickname #{@bot.nick} :(" end end @@ -86,14 +80,10 @@ class NickServPlugin < Plugin end end - def genpasswd - # generate a random password - passwd = "" - 8.times do - passwd += (rand(26) + (rand(2) == 0 ? 65 : 97) ).chr - end - return passwd - end end plugin = NickServPlugin.new -plugin.register("nickserv") +plugin.map 'nickserv password :nick :passwd' +plugin.map 'nickserv register :passwd :email', :action => 'nick_register', + :defaults => {:passwd => false, :email => false} +plugin.map 'nickserv listnicks' +plugin.map 'nickserv identify' |