mod_spox 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +38 -0
- data/INSTALL +5 -2
- data/bin/mod_spox +7 -3
- data/data/mod_spox/extras/Confess.rb +4 -4
- data/data/mod_spox/extras/Karma.rb +2 -2
- data/data/mod_spox/extras/Logger.rb +167 -0
- data/data/mod_spox/extras/Quotes.rb +2 -2
- data/data/mod_spox/extras/Roulette.rb +34 -16
- data/data/mod_spox/extras/Topten.rb +105 -0
- data/data/mod_spox/plugins/Authenticator.rb +2 -2
- data/data/mod_spox/plugins/Banner.rb +10 -10
- data/data/mod_spox/plugins/Initializer.rb +1 -1
- data/data/mod_spox/plugins/Triggers.rb +3 -3
- data/lib/mod_spox/Bot.rb +6 -5
- data/lib/mod_spox/BotConfig.rb +1 -1
- data/lib/mod_spox/ConfigurationWizard.rb +18 -17
- data/lib/mod_spox/Database.rb +9 -0
- data/lib/mod_spox/Helpers.rb +49 -0
- data/lib/mod_spox/Loader.rb +11 -0
- data/lib/mod_spox/PluginManager.rb +1 -0
- data/lib/mod_spox/Pool.rb +23 -107
- data/lib/mod_spox/Socket.rb +23 -37
- data/lib/mod_spox/Timer.rb +3 -3
- data/lib/mod_spox/handlers/Created.rb +1 -1
- data/lib/mod_spox/handlers/Handler.rb +1 -13
- data/lib/mod_spox/handlers/Invite.rb +1 -1
- data/lib/mod_spox/handlers/LuserOp.rb +1 -1
- data/lib/mod_spox/handlers/LuserUnknown.rb +1 -1
- data/lib/mod_spox/messages/internal/TimerAdd.rb +8 -0
- data/lib/mod_spox/messages/internal/TimerRemove.rb +8 -0
- data/lib/mod_spox/messages/internal/TimerResponse.rb +8 -1
- data/lib/mod_spox/models/Auth.rb +4 -4
- data/lib/mod_spox/models/Channel.rb +11 -0
- data/lib/mod_spox/models/Nick.rb +22 -11
- data/lib/mod_spox/models/Setting.rb +2 -2
- data/lib/mod_spox/models/Signature.rb +11 -2
- metadata +4 -2
@@ -4,10 +4,18 @@ module ModSpox
|
|
4
4
|
class TimerRemove
|
5
5
|
# action to remove
|
6
6
|
attr_reader :action
|
7
|
+
# message identification
|
8
|
+
attr_reader :ident
|
7
9
|
# action:: action to remove from timer
|
8
10
|
# Remove action from timer
|
9
11
|
def initialize(action)
|
10
12
|
@action = action
|
13
|
+
@ident = rand(99999999)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Message ID
|
17
|
+
def id
|
18
|
+
@ident
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
@@ -4,13 +4,16 @@ module ModSpox
|
|
4
4
|
class TimerResponse < Response
|
5
5
|
# action from timer
|
6
6
|
attr_reader :action
|
7
|
+
# response to message with this ID
|
8
|
+
attr_reader :ident
|
7
9
|
# object:: object to send response to
|
8
10
|
# action:: action removed from timer
|
9
11
|
# Notification that action has been removed
|
10
|
-
def initialize(object, action, added)
|
12
|
+
def initialize(object, action, added, id)
|
11
13
|
super(object)
|
12
14
|
@action = action
|
13
15
|
@added = added
|
16
|
+
@ident = id
|
14
17
|
end
|
15
18
|
# Action was added to timer
|
16
19
|
def action_added?
|
@@ -20,6 +23,10 @@ module ModSpox
|
|
20
23
|
def action_removed?
|
21
24
|
return !@added
|
22
25
|
end
|
26
|
+
# ID of message this response is for
|
27
|
+
def id
|
28
|
+
@ident
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
data/lib/mod_spox/models/Auth.rb
CHANGED
@@ -47,14 +47,14 @@ module ModSpox
|
|
47
47
|
|
48
48
|
# Set services (nickserv) identification
|
49
49
|
def services_identified=(val)
|
50
|
-
|
50
|
+
update_with_params :authed => true if val && services
|
51
51
|
end
|
52
52
|
|
53
53
|
# pass:: password to compare
|
54
54
|
# Check and authenticate against password
|
55
55
|
def check_password(pass)
|
56
56
|
if(Digest::SHA1.hexdigest(pass) == password)
|
57
|
-
|
57
|
+
update_with_params :authed => true
|
58
58
|
return true
|
59
59
|
else
|
60
60
|
return false
|
@@ -62,14 +62,14 @@ module ModSpox
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def password=(pass)
|
65
|
-
|
65
|
+
update_values :password => Digest::SHA1.hexdigest(pass)
|
66
66
|
end
|
67
67
|
|
68
68
|
# source:: source to apply mask to
|
69
69
|
# Check and authenticate by mask against source
|
70
70
|
def check_mask(source)
|
71
71
|
if(source =~ /^#{mask}$/)
|
72
|
-
|
72
|
+
update_with_params :authed => true
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -10,6 +10,17 @@ module ModSpox
|
|
10
10
|
# parked:: Bot is currently in this channel
|
11
11
|
class Channel < Sequel::Model(:channels)
|
12
12
|
|
13
|
+
set_cache Database.cache, :ttl => 3600 unless Database.cache.nil?
|
14
|
+
|
15
|
+
def Channel.locate(string, create = true)
|
16
|
+
chan = nil
|
17
|
+
if(Database.type == :pgsql)
|
18
|
+
chan = Channel.filter('name = lower(?)', string).first
|
19
|
+
end
|
20
|
+
chan = Channel.find_or_create(:name => string) if !chan && create
|
21
|
+
return chan
|
22
|
+
end
|
23
|
+
|
13
24
|
# Modes for this channel
|
14
25
|
def channel_modes
|
15
26
|
ChannelMode.filter(:channel_id => pk)
|
data/lib/mod_spox/models/Nick.rb
CHANGED
@@ -16,22 +16,33 @@ module ModSpox
|
|
16
16
|
# TODO: for nick field -> "tack a COLLATE NOCASE onto the columns"
|
17
17
|
class Nick < Sequel::Model(:nicks)
|
18
18
|
|
19
|
+
set_cache Database.cache, :ttl => 3600 unless Database.cache.nil?
|
20
|
+
|
21
|
+
def Nick.locate(string, create = true)
|
22
|
+
nick = nil
|
23
|
+
if(Database.type == :pgsql)
|
24
|
+
nick = Nick.filter('nick = lower(?)', string).first
|
25
|
+
end
|
26
|
+
nick = Nick.find_or_create(:nick => string) if !nick && create
|
27
|
+
return nick
|
28
|
+
end
|
29
|
+
|
19
30
|
def visible=(val)
|
20
31
|
unless(val)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
update_with_params :username => nil
|
33
|
+
update_with_params :real_name => nil
|
34
|
+
update_with_params :address => nil
|
35
|
+
update_with_params :source => nil
|
36
|
+
update_with_params :connected_at => nil
|
37
|
+
update_with_params :connected_to => nil
|
38
|
+
update_with_params :seconds_idle => nil
|
39
|
+
update_with_params :away => false
|
29
40
|
end
|
30
|
-
|
41
|
+
update_values :visible => val
|
31
42
|
end
|
32
43
|
|
33
44
|
def source=(mask)
|
34
|
-
|
45
|
+
update_values :source => mask
|
35
46
|
auth.check_mask(mask)
|
36
47
|
end
|
37
48
|
|
@@ -45,7 +56,7 @@ module ModSpox
|
|
45
56
|
groups = []
|
46
57
|
auth_ids = []
|
47
58
|
group_ids = []
|
48
|
-
auth = Auth.filter
|
59
|
+
auth = Auth.filter('nick_id = ?', pk).filter('authed = ?', true).first
|
49
60
|
if(auth)
|
50
61
|
groups = auth.groups
|
51
62
|
end
|
@@ -11,7 +11,7 @@ module ModSpox
|
|
11
11
|
class Setting < Sequel::Model(:settings)
|
12
12
|
|
13
13
|
def value=(val)
|
14
|
-
|
14
|
+
update_values(:value => Base64.encode64(Marshal.dump(val)))
|
15
15
|
end
|
16
16
|
|
17
17
|
def value
|
@@ -33,7 +33,7 @@ module ModSpox
|
|
33
33
|
def self.[]=(key, val)
|
34
34
|
key = key.to_s if key.is_a?(Symbol)
|
35
35
|
model = Setting.find_or_create(:name => key)
|
36
|
-
model.
|
36
|
+
model.update_with_params(:value => Base64.encode64(Marshal.dump(val)))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'base64'
|
1
2
|
module ModSpox
|
2
3
|
module Models
|
3
4
|
# Attributes provided by model:
|
@@ -10,19 +11,27 @@ module ModSpox
|
|
10
11
|
|
11
12
|
def params=(prms)
|
12
13
|
raise InvalidType.new('Parameter names must be provided in an array') unless prms.kind_of?(Array)
|
13
|
-
|
14
|
+
update_values(:params => prms.join('|'))
|
14
15
|
end
|
15
16
|
|
16
17
|
def params
|
17
18
|
return values[:params].nil? ? [] : values[:params].split('|')
|
18
19
|
end
|
19
20
|
|
21
|
+
def signature=(sig)
|
22
|
+
update_values(:signature => Base64.encode64(Marshal.dump(sig)))
|
23
|
+
end
|
24
|
+
|
25
|
+
def signature
|
26
|
+
return values[:signature] ? Marshal.load(Base64.decode64(values[:signature])) : nil
|
27
|
+
end
|
28
|
+
|
20
29
|
def group
|
21
30
|
Group[group_id]
|
22
31
|
end
|
23
32
|
|
24
33
|
def group=(group)
|
25
|
-
|
34
|
+
update_values :group_id => group.pk
|
26
35
|
end
|
27
36
|
|
28
37
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mod_spox
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2008-
|
6
|
+
version: 0.0.4
|
7
|
+
date: 2008-05-09 00:00:00 -07:00
|
8
8
|
summary: The mod_spox IRC robot
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -241,6 +241,8 @@ files:
|
|
241
241
|
- data/mod_spox/extras/Talk.rb
|
242
242
|
- data/mod_spox/extras/EightBall.rb
|
243
243
|
- data/mod_spox/extras/AOLSpeak.rb
|
244
|
+
- data/mod_spox/extras/Logger.rb
|
245
|
+
- data/mod_spox/extras/Topten.rb
|
244
246
|
test_files: []
|
245
247
|
|
246
248
|
rdoc_options: []
|