]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - data/rbot/plugins/quakeauth.rb
Thu Aug 04 23:03:30 BST 2005 Tom Gilbert <tom@linuxbrit.co.uk>
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / quakeauth.rb
1 # automatically auths with Q on quakenet servers
2
3 class QPlugin < Plugin
4   
5   def help(plugin, topic="")
6     case topic
7     when ""
8       return "quath plugin: handles Q auths. topics set, identify"
9     when "set"
10       return "nickserv set <user> <passwd>: set the Q user and password and use it to identify in future"
11     when "identify"
12       return "quath identify: identify with Q (if user and auth are set)"
13     end
14   end
15   
16   def initialize
17     super
18     # this plugin only wants to store strings!
19     class << @registry
20       def store(val)
21         val
22       end
23       def restore(val)
24         val
25       end
26     end
27   end
28
29   def set(m, params)
30     @registry['quakenet.user'] = params[:user]
31     @registry['quakenet.auth'] = params[:passwd]
32     m.okay
33   end
34   
35   def connect
36     identify(nil, nil)
37   end
38   def identify(m, params)
39     if @registry.has_key?('quakenet.user') && @registry.has_key?('quakenet.auth')
40       debug "authing with Q using  #{@registry['quakenet.user']} #{@registry['quakenet.auth']}"
41       @bot.sendmsg "PRIVMSG", "Q@CServe.quakenet.org", "auth #{@registry['quakenet.user']} #{@registry['quakenet.auth']}"                                                    
42       m.okay if m
43     else
44       m.reply "not configured, try 'qauth set :nick :passwd'" if m
45     end
46   end
47
48 end
49 plugin = QPlugin.new
50 plugin.map 'qauth set :nick :passwd', :action => "set"
51 plugin.map 'quath identify', :action => "identify"