rbot 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +8 -0
- data/ChangeLog +51 -0
- data/INSTALL +4 -0
- data/README +1 -0
- data/REQUIREMENTS +11 -0
- data/TODO +2 -0
- data/bin/rbot +21 -2
- data/data/rbot/languages/german.lang +4 -1
- data/data/rbot/languages/russian.lang +75 -0
- data/data/rbot/plugins/autoop.rb +42 -51
- data/data/rbot/plugins/bans.rb +205 -0
- data/data/rbot/plugins/bash.rb +56 -0
- data/data/rbot/plugins/chucknorris.rb +74 -0
- data/data/rbot/plugins/chucknorris.yml.gz +0 -0
- data/data/rbot/plugins/deepthoughts.rb +95 -0
- data/data/rbot/plugins/demauro.rb +95 -0
- data/data/rbot/plugins/digg.rb +51 -0
- data/data/rbot/plugins/figlet.rb +24 -0
- data/data/rbot/plugins/forecast.rb +133 -0
- data/data/rbot/plugins/freshmeat.rb +13 -7
- data/data/rbot/plugins/google.rb +2 -0
- data/data/rbot/plugins/grouphug.rb +36 -0
- data/data/rbot/plugins/imdb.rb +92 -0
- data/data/rbot/plugins/insult.rb +8 -1
- data/data/rbot/plugins/iplookup.rb +227 -0
- data/data/rbot/plugins/karma.rb +2 -2
- data/data/rbot/plugins/keywords.rb +470 -0
- data/data/rbot/plugins/lart.rb +132 -146
- data/data/rbot/plugins/lastfm.rb +25 -0
- data/data/rbot/plugins/markov.rb +204 -0
- data/data/rbot/plugins/math.rb +5 -1
- data/data/rbot/plugins/nickserv.rb +71 -11
- data/data/rbot/plugins/opme.rb +19 -19
- data/data/rbot/plugins/quakeauth.rb +2 -2
- data/data/rbot/plugins/quotes.rb +40 -25
- data/data/rbot/plugins/remind.rb +1 -1
- data/data/rbot/plugins/rot13.rb +2 -2
- data/data/rbot/plugins/roulette.rb +49 -15
- data/data/rbot/plugins/rss.rb +585 -0
- data/data/rbot/plugins/rubyurl.rb +39 -0
- data/data/rbot/plugins/seen.rb +2 -1
- data/data/rbot/plugins/slashdot.rb +5 -5
- data/data/rbot/plugins/spell.rb +5 -0
- data/data/rbot/plugins/theyfightcrime.rb +121 -0
- data/data/rbot/plugins/threat.rb +55 -0
- data/data/rbot/plugins/tinyurl.rb +39 -0
- data/data/rbot/plugins/topic.rb +204 -0
- data/data/rbot/plugins/urban.rb +71 -0
- data/data/rbot/plugins/url.rb +399 -4
- data/data/rbot/plugins/wow.rb +123 -0
- data/data/rbot/plugins/wserver.rb +1 -1
- data/data/rbot/templates/levels.rbot +2 -0
- data/lib/rbot/auth.rb +207 -96
- data/lib/rbot/channel.rb +5 -5
- data/lib/rbot/config.rb +125 -24
- data/lib/rbot/dbhash.rb +87 -21
- data/lib/rbot/httputil.rb +181 -13
- data/lib/rbot/ircbot.rb +525 -179
- data/lib/rbot/ircsocket.rb +330 -54
- data/lib/rbot/message.rb +66 -23
- data/lib/rbot/messagemapper.rb +25 -17
- data/lib/rbot/plugins.rb +244 -115
- data/lib/rbot/post-clean.rb +1 -0
- data/lib/rbot/{post-install.rb → post-config.rb} +1 -1
- data/lib/rbot/rbotconfig.rb +29 -14
- data/lib/rbot/registry.rb +111 -72
- data/lib/rbot/rfc2812.rb +208 -197
- data/lib/rbot/timer.rb +4 -0
- data/lib/rbot/utils.rb +2 -2
- metadata +127 -104
- data/data/rbot/plugins/rss.rb.disabled +0 -414
- data/lib/rbot/keywords.rb +0 -433
@@ -0,0 +1,123 @@
|
|
1
|
+
#
|
2
|
+
# World of Warcraft Realm Status plugin for rbot
|
3
|
+
# by MrChucho (mrchucho@mrchucho.net)
|
4
|
+
# Copyright (C) 2006 Ralph M. Churchill
|
5
|
+
#
|
6
|
+
# Requires: insatiable appetite for World of Warcraft
|
7
|
+
#
|
8
|
+
require 'open-uri'
|
9
|
+
require 'rexml/document'
|
10
|
+
|
11
|
+
class Realm
|
12
|
+
attr_accessor :name,:status,:type,:pop
|
13
|
+
def initialize(name,status,type,pop)
|
14
|
+
self.name = pretty_realm(name)
|
15
|
+
self.status = pretty_status(status)
|
16
|
+
self.type = pretty_type(type)
|
17
|
+
self.pop = pretty_pop(pop)
|
18
|
+
end
|
19
|
+
def Realm.get_realm_status(realm_name)
|
20
|
+
begin
|
21
|
+
open("http://www.worldofwarcraft.com/realmstatus/status.xml") do |xmldoc|
|
22
|
+
realm_list = (REXML::Document.new xmldoc).root
|
23
|
+
realm_data = realm_list.elements["r[@n=\"#{realm_name}\"]"]
|
24
|
+
if realm_data and realm_data.attributes.any? then
|
25
|
+
realm = Realm.new(
|
26
|
+
realm_data.attributes['n'],
|
27
|
+
realm_data.attributes['s'].to_i,
|
28
|
+
realm_data.attributes['t'].to_i,
|
29
|
+
realm_data.attributes['l'].to_i)
|
30
|
+
else
|
31
|
+
"Realm, #{realm_name}, not found."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
rescue => err
|
35
|
+
"Error retrieving realm status: #{err}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def to_s
|
39
|
+
"#{name} (#{type}) Status: #{status} Population: #{pop}"
|
40
|
+
end
|
41
|
+
# just a longer, tabluar format
|
42
|
+
# might be good if displaying multiple realms
|
43
|
+
def _to_s
|
44
|
+
sprintf("%-8s %-20s %-8s %-9s\n%-11s %-22s %-8s %-9s",
|
45
|
+
"Status","Realm","Type","Population",
|
46
|
+
status,name,type,pop)
|
47
|
+
end
|
48
|
+
private
|
49
|
+
def pretty_status(status)
|
50
|
+
case status
|
51
|
+
when 1
|
52
|
+
"3Up"
|
53
|
+
when 2
|
54
|
+
"5Down"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
def pretty_pop(pop)
|
58
|
+
case pop
|
59
|
+
when 1
|
60
|
+
"3Low"
|
61
|
+
when 2
|
62
|
+
"7Medium"
|
63
|
+
when 3
|
64
|
+
"4High"
|
65
|
+
when 4
|
66
|
+
"5Max(Queued)"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
def pretty_realm(realm)
|
70
|
+
"#{realm}"
|
71
|
+
end
|
72
|
+
def pretty_type(type)
|
73
|
+
case type
|
74
|
+
when 0
|
75
|
+
'RP-PVP'
|
76
|
+
when 1
|
77
|
+
'Normal'
|
78
|
+
when 2
|
79
|
+
'PVP'
|
80
|
+
when 3
|
81
|
+
'RP'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class RealmPlugin < Plugin
|
87
|
+
USAGE="realm <realm> => determine the status of a Warcraft realm"
|
88
|
+
def initialize
|
89
|
+
super
|
90
|
+
class << @registry
|
91
|
+
def store(val)
|
92
|
+
val
|
93
|
+
end
|
94
|
+
def restore(val)
|
95
|
+
val
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
def help(plugin,topic="")
|
100
|
+
USAGE
|
101
|
+
end
|
102
|
+
def usage(m,params={})
|
103
|
+
m.reply USAGE
|
104
|
+
end
|
105
|
+
def realm(m,params)
|
106
|
+
if params[:realm_name] and params[:realm_name].any?
|
107
|
+
realm_name = params[:realm_name].collect{|tok|
|
108
|
+
tok.capitalize
|
109
|
+
}.join(' ')
|
110
|
+
@registry[m.sourcenick] = realm_name
|
111
|
+
m.reply Realm.get_realm_status(realm_name)
|
112
|
+
else
|
113
|
+
if @registry.has_key?(m.sourcenick)
|
114
|
+
realm_name = @registry[m.sourcenick]
|
115
|
+
m.reply Realm.get_realm_status(realm_name)
|
116
|
+
else
|
117
|
+
m.reply "I don't know which realm you want.\n#{USAGE}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
plugin = RealmPlugin.new
|
123
|
+
plugin.map 'realm *realm_name', :defaults => {:realm_name => false}
|
data/lib/rbot/auth.rb
CHANGED
@@ -4,39 +4,45 @@ module Irc
|
|
4
4
|
# netmask:: netmask to test against
|
5
5
|
# Compare a netmask with a standard IRC glob, e.g foo!bar@baz.com would
|
6
6
|
# match *!*@baz.com, foo!*@*, *!bar@*, etc.
|
7
|
-
def Irc.netmaskmatch(globmask, netmask)
|
8
|
-
regmask =
|
9
|
-
|
7
|
+
def Irc.netmaskmatch( globmask, netmask )
|
8
|
+
regmask = Regexp.escape( globmask )
|
9
|
+
regmask.gsub!( /\\\*/, '.*' )
|
10
|
+
return true if(netmask =~ /#{regmask}/i)
|
10
11
|
return false
|
11
12
|
end
|
12
13
|
|
13
14
|
# check if a string is an actual IRC hostmask
|
14
|
-
def Irc.ismask(mask)
|
15
|
+
def Irc.ismask?(mask)
|
15
16
|
mask =~ /^.+!.+@.+$/
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
+
Struct.new( 'UserData', :level, :password, :hostmasks )
|
20
|
+
|
19
21
|
# User-level authentication to allow/disallow access to bot commands based
|
20
22
|
# on hostmask and userlevel.
|
21
23
|
class IrcAuth
|
22
|
-
BotConfig.register BotConfigStringValue.new('auth.password',
|
23
|
-
:default =>
|
24
|
-
:desc =>
|
25
|
-
|
24
|
+
BotConfig.register BotConfigStringValue.new( 'auth.password',
|
25
|
+
:default => 'rbotauth', :wizard => true,
|
26
|
+
:desc => 'Your password for maxing your auth with the bot (used to associate new hostmasks with your owner-status etc)' )
|
27
|
+
BotConfig.register BotConfigIntegerValue.new( 'auth.default_level',
|
28
|
+
:default => 10, :wizard => true,
|
29
|
+
:desc => 'The default level for new/unknown users' )
|
30
|
+
|
26
31
|
# create a new IrcAuth instance.
|
27
32
|
# bot:: associated bot class
|
28
33
|
def initialize(bot)
|
29
34
|
@bot = bot
|
30
|
-
@users = Hash.new
|
35
|
+
@users = Hash.new do
|
36
|
+
Struct::UserData.new(@bot.config['auth.default_level'], '', [])
|
37
|
+
end
|
31
38
|
@levels = Hash.new(0)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
39
|
+
@currentUsers = Hash.new( nil )
|
40
|
+
if( File.exist?( "#{@bot.botclass}/users.yaml" ) )
|
41
|
+
File.open( "#{@bot.botclass}/users.yaml" ) { |file|
|
42
|
+
# work around YAML not maintaining the default proc
|
43
|
+
@loadedusers = YAML::parse(file).transform
|
44
|
+
@users.update(@loadedusers)
|
45
|
+
}
|
40
46
|
end
|
41
47
|
if(File.exist?("#{@bot.botclass}/levels.rbot"))
|
42
48
|
IO.foreach("#{@bot.botclass}/levels.rbot") do |line|
|
@@ -47,22 +53,43 @@ module Irc
|
|
47
53
|
end
|
48
54
|
end
|
49
55
|
end
|
56
|
+
if @levels.length < 1
|
57
|
+
raise RuntimeError, "No valid levels.rbot found! If you really want a free-for-all bot and this isn't the result of a previous error, write a proper levels.rbot"
|
58
|
+
end
|
50
59
|
end
|
51
60
|
|
52
61
|
# save current users and levels to files.
|
53
62
|
# levels are written to #{botclass}/levels.rbot
|
54
|
-
# users are written to #{botclass}/users.
|
63
|
+
# users are written to #{botclass}/users.yaml
|
55
64
|
def save
|
56
65
|
Dir.mkdir("#{@bot.botclass}") if(!File.exist?("#{@bot.botclass}"))
|
57
|
-
|
58
|
-
|
59
|
-
|
66
|
+
begin
|
67
|
+
debug "Writing new users.yaml ..."
|
68
|
+
File.open("#{@bot.botclass}/users.yaml.new", 'w') do |file|
|
69
|
+
file.puts @users.to_yaml
|
60
70
|
end
|
71
|
+
debug "Officializing users.yaml ..."
|
72
|
+
File.rename("#{@bot.botclass}/users.yaml.new",
|
73
|
+
"#{@bot.botclass}/users.yaml")
|
74
|
+
rescue
|
75
|
+
error "failed to write configuration file users.yaml! #{$!}"
|
76
|
+
error "#{e.class}: #{e}"
|
77
|
+
error e.backtrace.join("\n")
|
61
78
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
79
|
+
begin
|
80
|
+
debug "Writing new levels.rbot ..."
|
81
|
+
File.open("#{@bot.botclass}/levels.rbot.new", 'w') do |file|
|
82
|
+
@levels.each do |key, value|
|
83
|
+
file.puts "#{value} #{key}"
|
84
|
+
end
|
65
85
|
end
|
86
|
+
debug "Officializing levels.rbot ..."
|
87
|
+
File.rename("#{@bot.botclass}/levels.rbot.new",
|
88
|
+
"#{@bot.botclass}/levels.rbot")
|
89
|
+
rescue
|
90
|
+
error "failed to write configuration file levels.rbot! #{$!}"
|
91
|
+
error "#{e.class}: #{e}"
|
92
|
+
error e.backtrace.join("\n")
|
66
93
|
end
|
67
94
|
end
|
68
95
|
|
@@ -73,30 +100,58 @@ module Irc
|
|
73
100
|
# returns true if user with hostmask +mask+ is permitted to perform
|
74
101
|
# +command+ optionally pass tell as the target for the "insufficient auth"
|
75
102
|
# message, if the user is not authorised
|
76
|
-
def allow?(command, mask, tell=nil)
|
77
|
-
auth =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
103
|
+
def allow?( command, mask, tell=nil )
|
104
|
+
auth = @users[matchingUser(mask)].level # Directly using @users[] is possible, because UserData has a default setting
|
105
|
+
if( auth >= @levels[command] )
|
106
|
+
return true
|
107
|
+
else
|
108
|
+
debug "#{mask} is not allowed to perform #{command}"
|
109
|
+
@bot.say tell, "insufficient \"#{command}\" auth (have #{auth}, need #{@levels[command]})" if tell
|
110
|
+
return false
|
111
|
+
end
|
85
112
|
end
|
86
113
|
|
87
114
|
# add user with hostmask matching +mask+ with initial auth level +level+
|
88
|
-
def useradd(
|
89
|
-
|
90
|
-
@users[mask] = level
|
91
|
-
end
|
115
|
+
def useradd( username, level=@bot.config['auth.default_level'], password='', hostmask='*!*@*' )
|
116
|
+
@users[username] = Struct::UserData.new( level, password, [hostmask] ) if ! @users.has_key? username
|
92
117
|
end
|
93
|
-
|
118
|
+
|
94
119
|
# mask:: mask of user to remove
|
95
120
|
# remove user with mask +mask+
|
96
|
-
def userdel(
|
97
|
-
|
98
|
-
|
121
|
+
def userdel( username )
|
122
|
+
@users.delete( username ) if @users.has_key? username
|
123
|
+
end
|
124
|
+
|
125
|
+
def usermod( username, item, value=nil )
|
126
|
+
if @users.has_key?( username )
|
127
|
+
case item
|
128
|
+
when 'hostmask'
|
129
|
+
if Irc.ismask?( value )
|
130
|
+
@users[username].hostmasks = [ value ]
|
131
|
+
return true
|
132
|
+
end
|
133
|
+
when '+hostmask'
|
134
|
+
if Irc.ismask?( value )
|
135
|
+
@users[username].hostmasks += [ value ]
|
136
|
+
return true
|
137
|
+
end
|
138
|
+
when '-hostmask'
|
139
|
+
if Irc.ismask?( value )
|
140
|
+
@users[username].hostmasks -= [ value ]
|
141
|
+
return true
|
142
|
+
end
|
143
|
+
when 'password'
|
144
|
+
@users[username].password = value
|
145
|
+
return true
|
146
|
+
when 'level'
|
147
|
+
@users[username].level = value.to_i
|
148
|
+
return true
|
149
|
+
else
|
150
|
+
debug "usermod: Tried to modify unknown item #{item}"
|
151
|
+
# @bot.say tell, "Unknown item #{item}" if tell
|
152
|
+
end
|
99
153
|
end
|
154
|
+
return false
|
100
155
|
end
|
101
156
|
|
102
157
|
# command:: command to adjust
|
@@ -106,30 +161,33 @@ module Irc
|
|
106
161
|
@levels[command] = level
|
107
162
|
end
|
108
163
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
level = userlevel if userlevel > level
|
164
|
+
def matchingUser( mask )
|
165
|
+
currentUser = nil
|
166
|
+
currentLevel = 0
|
167
|
+
@users.each { |user, data| # TODO Will get easier if YPaths are used...
|
168
|
+
if data.level > currentLevel
|
169
|
+
data.hostmasks.each { |hostmask|
|
170
|
+
if Irc.netmaskmatch( hostmask, mask )
|
171
|
+
currentUser = user
|
172
|
+
currentLevel = data.level
|
173
|
+
end
|
174
|
+
}
|
121
175
|
end
|
122
176
|
}
|
123
|
-
|
177
|
+
currentUser
|
178
|
+
end
|
179
|
+
|
180
|
+
def identify( mask, username, password )
|
181
|
+
return false unless @users.has_key?(username) && @users[username].password == password
|
182
|
+
@bot.auth.usermod( username, '+hostmask', mask )
|
183
|
+
return true
|
124
184
|
end
|
125
185
|
|
126
186
|
# return all currently defined commands (for which auth is required) and
|
127
187
|
# their required authlevels
|
128
188
|
def showlevels
|
129
|
-
reply =
|
130
|
-
@levels.sort.each {|
|
131
|
-
key = a[0]
|
132
|
-
value = a[1]
|
189
|
+
reply = 'Current levels are:'
|
190
|
+
@levels.sort.each { |key, value|
|
133
191
|
reply += " #{key}(#{value})"
|
134
192
|
}
|
135
193
|
reply
|
@@ -137,32 +195,46 @@ module Irc
|
|
137
195
|
|
138
196
|
# return all currently defined users and their authlevels
|
139
197
|
def showusers
|
140
|
-
reply =
|
141
|
-
@users.sort.each {|
|
142
|
-
|
143
|
-
value = a[1]
|
144
|
-
reply += " #{key}(#{value})"
|
198
|
+
reply = 'Current users are:'
|
199
|
+
@users.sort.each { |key, value|
|
200
|
+
reply += " #{key}(#{value.level})"
|
145
201
|
}
|
146
202
|
reply
|
147
203
|
end
|
148
|
-
|
204
|
+
|
205
|
+
def showdetails( username )
|
206
|
+
if @users.has_key? username
|
207
|
+
reply = "#{username}(#{@users[username].level}):"
|
208
|
+
@users[username].hostmasks.each { |hostmask|
|
209
|
+
reply += " #{hostmask}"
|
210
|
+
}
|
211
|
+
end
|
212
|
+
reply
|
213
|
+
end
|
214
|
+
|
149
215
|
# module help
|
150
|
-
def help(topic=
|
216
|
+
def help(topic='')
|
151
217
|
case topic
|
152
|
-
when
|
153
|
-
return
|
154
|
-
when
|
155
|
-
return
|
156
|
-
when
|
157
|
-
return
|
158
|
-
when
|
159
|
-
return
|
160
|
-
when
|
161
|
-
return
|
162
|
-
when
|
163
|
-
return
|
218
|
+
when 'setlevel'
|
219
|
+
return 'setlevel <command> <level> => Sets required level for <command> to <level> (private addressing only)'
|
220
|
+
when 'useradd'
|
221
|
+
return 'useradd <username> => Add user <mask>, you still need to set him up correctly (private addressing only)'
|
222
|
+
when 'userdel'
|
223
|
+
return 'userdel <username> => Remove user <username> (private addressing only)'
|
224
|
+
when 'usermod'
|
225
|
+
return 'usermod <username> <item> <value> => Modify <username>s settings. Valid <item>s are: hostmask, (+|-)hostmask, password, level (private addressing only)'
|
226
|
+
when 'auth'
|
227
|
+
return 'auth <masterpw> => Create a user with your hostmask and master password as bot master (private addressing only)'
|
228
|
+
when 'levels'
|
229
|
+
return 'levels => list commands and their required levels (private addressing only)'
|
230
|
+
when 'users'
|
231
|
+
return 'users [<username>]=> list users and their levels or details about <username> (private addressing only)'
|
232
|
+
when 'whoami'
|
233
|
+
return 'whoami => Show as whom you are recognized (private addressing only)'
|
234
|
+
when 'identify'
|
235
|
+
return 'identify <username> <password> => Identify your hostmask as belonging to <username> (private addressing only)'
|
164
236
|
else
|
165
|
-
return
|
237
|
+
return 'Auth module (User authentication) topics: setlevel, useradd, userdel, usermod, auth, levels, users, whoami, identify'
|
166
238
|
end
|
167
239
|
end
|
168
240
|
|
@@ -171,31 +243,70 @@ module Irc
|
|
171
243
|
if(m.address? && m.private?)
|
172
244
|
case m.message
|
173
245
|
when (/^setlevel\s+(\S+)\s+(\d+)$/)
|
174
|
-
if(@bot.auth.allow?(
|
175
|
-
@bot.auth.setlevel($1, $2.to_i)
|
246
|
+
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
247
|
+
@bot.auth.setlevel( $1, $2.to_i )
|
176
248
|
m.reply "level for #$1 set to #$2"
|
177
249
|
end
|
178
|
-
when
|
179
|
-
if(@bot.auth.allow?(
|
180
|
-
@bot.auth.useradd($1
|
181
|
-
m.reply "added user #$1
|
250
|
+
when( /^useradd\s+(\S+)/ ) # FIXME Needs review!!! (\s+(\S+)(\s+(\S+)(\s+(\S+))?)?)? Should this part be added to make complete useradds possible?
|
251
|
+
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
252
|
+
@bot.auth.useradd( $1 )
|
253
|
+
m.reply "added user #$1, please set him up correctly"
|
182
254
|
end
|
183
|
-
when
|
184
|
-
if(@bot.auth.allow?(
|
185
|
-
@bot.auth.userdel($1)
|
255
|
+
when( /^userdel\s+(\S+)/ )
|
256
|
+
if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
257
|
+
@bot.auth.userdel( $1 )
|
186
258
|
m.reply "user #$1 is gone"
|
187
259
|
end
|
260
|
+
when( /^usermod\s+(\S+)\s+(\S+)\s+(\S+)/ )
|
261
|
+
if( @bot.auth.allow?('auth', m.source, m.replyto ) )
|
262
|
+
if( @bot.auth.usermod( $1, $2, $3 ) )
|
263
|
+
m.reply "Set #$2 of #$1 to #$3"
|
264
|
+
else
|
265
|
+
m.reply "Failed to set #$2 of #$1 to #$3"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
when( /^setpassword\s+(\S+)/ )
|
269
|
+
password = $1
|
270
|
+
user = @bot.auth.matchingUser( m.source )
|
271
|
+
if user
|
272
|
+
if @bot.auth.usermod(user, 'password', password)
|
273
|
+
m.reply "Your password has been set to #{password}"
|
274
|
+
else
|
275
|
+
m.reply "Couldn't set password"
|
276
|
+
end
|
277
|
+
else
|
278
|
+
m.reply 'You don\'t belong to any user.'
|
279
|
+
end
|
188
280
|
when (/^auth\s+(\S+)/)
|
189
|
-
if($1 == @bot.config[
|
190
|
-
@
|
191
|
-
|
281
|
+
if( $1 == @bot.config['auth.password'] )
|
282
|
+
if ! @users.has_key? 'master'
|
283
|
+
@bot.auth.useradd( 'master', 1000, @bot.config['auth.password'], m.source )
|
284
|
+
else
|
285
|
+
@bot.auth.usermod( 'master', '+hostmask', m.source )
|
286
|
+
end
|
287
|
+
m.reply 'Identified, security level maxed out'
|
288
|
+
else
|
289
|
+
m.reply 'Incorrect password'
|
290
|
+
end
|
291
|
+
when( /^identify\s+(\S+)\s+(\S+)/ )
|
292
|
+
if @bot.auth.identify( m.source, $1, $2 )
|
293
|
+
m.reply "Identified as #$1 (#{@users[$1].level})"
|
294
|
+
else
|
295
|
+
m.reply 'Incorrect username/password'
|
296
|
+
end
|
297
|
+
when( 'whoami' )
|
298
|
+
user = @bot.auth.matchingUser( m.source )
|
299
|
+
if user
|
300
|
+
m.reply "I recognize you as #{user} (#{@users[user].level})"
|
192
301
|
else
|
193
|
-
m.reply
|
302
|
+
m.reply 'You don\'t belong to any user.'
|
194
303
|
end
|
195
|
-
when (
|
196
|
-
m.reply @bot.auth.
|
197
|
-
when (
|
198
|
-
m.reply @bot.auth.
|
304
|
+
when( /^users\s+(\S+)/ )
|
305
|
+
m.reply @bot.auth.showdetails( $1 ) if( @bot.auth.allow?( 'auth', m.source, m.replyto ) )
|
306
|
+
when ( 'levels' )
|
307
|
+
m.reply @bot.auth.showlevels if( @bot.auth.allow?( 'config', m.source, m.replyto ) )
|
308
|
+
when ( 'users' )
|
309
|
+
m.reply @bot.auth.showusers if( @bot.auth.allow?( 'users', m.source, m.replyto ) )
|
199
310
|
end
|
200
311
|
end
|
201
312
|
end
|