mod_spox 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -1
- data/LICENSE +674 -0
- data/README.rdoc +73 -0
- data/bin/mod_spox +28 -28
- data/data/mod_spox/extras/AOLSpeak.rb +2 -3
- data/data/mod_spox/extras/AutoKick.rb +10 -23
- data/data/mod_spox/extras/AutoMode.rb +12 -23
- data/data/mod_spox/extras/Bash.rb +55 -0
- data/data/mod_spox/extras/Bouncer.rb +85 -57
- data/data/mod_spox/extras/Bullshit.rb +1 -1
- data/data/mod_spox/extras/Bytes.rb +1 -2
- data/data/mod_spox/extras/Confess.rb +27 -29
- data/data/mod_spox/extras/DCC.rb +11 -20
- data/data/mod_spox/extras/DevWatch.rb +21 -23
- data/data/mod_spox/extras/DownForEveryoneOrJustMe.rb +47 -0
- data/data/mod_spox/extras/EightBall.rb +1 -1
- data/data/mod_spox/extras/FML.rb +35 -0
- data/data/mod_spox/extras/Headers.rb +31 -50
- data/data/mod_spox/extras/Karma.rb +81 -29
- data/data/mod_spox/extras/Logger.rb +2 -2
- data/data/mod_spox/extras/LolSpeak.rb +1 -2
- data/data/mod_spox/extras/PhpCli.rb +138 -8
- data/data/mod_spox/extras/PhpFuncLookup.rb +20 -23
- data/data/mod_spox/extras/Pinger.rb +1 -1
- data/data/mod_spox/extras/Quotes.rb +8 -10
- data/data/mod_spox/extras/RegexTracker.rb +2 -4
- data/data/mod_spox/extras/Roulette.rb +20 -27
- data/data/mod_spox/extras/RubyCli.rb +93 -0
- data/data/mod_spox/extras/Search.rb +17 -3
- data/data/mod_spox/extras/Seen.rb +150 -0
- data/data/mod_spox/extras/SlashdotHeadlineGenerator.rb +500 -0
- data/data/mod_spox/extras/Talk.rb +2 -4
- data/data/mod_spox/extras/Topten.rb +10 -12
- data/data/mod_spox/extras/TracTicket.rb +3 -5
- data/data/mod_spox/extras/Translate.rb +20 -22
- data/data/mod_spox/extras/Twitter.rb +118 -33
- data/data/mod_spox/extras/UrbanDictionary.rb +8 -17
- data/data/mod_spox/extras/Weather.rb +1 -2
- data/data/mod_spox/plugins/Authenticator.rb +93 -98
- data/data/mod_spox/plugins/Banner.rb +26 -56
- data/data/mod_spox/plugins/Helper.rb +5 -6
- data/data/mod_spox/plugins/Initializer.rb +4 -14
- data/data/mod_spox/plugins/Joiner.rb +1 -1
- data/data/mod_spox/plugins/Nicker.rb +13 -0
- data/data/mod_spox/plugins/Parter.rb +2 -2
- data/data/mod_spox/plugins/Permissions.rb +60 -0
- data/data/mod_spox/plugins/PluginLoader.rb +7 -12
- data/data/mod_spox/plugins/Ponger.rb +51 -0
- data/data/mod_spox/plugins/Quitter.rb +1 -2
- data/data/mod_spox/plugins/Servers.rb +57 -0
- data/data/mod_spox/plugins/Status.rb +3 -2
- data/data/mod_spox/plugins/Triggers.rb +9 -9
- data/lib/mod_spox/Bot.rb +109 -33
- data/lib/mod_spox/BotConfig.rb +2 -2
- data/lib/mod_spox/ConfigurationWizard.rb +12 -12
- data/lib/mod_spox/Database.rb +1 -4
- data/lib/mod_spox/Exceptions.rb +26 -0
- data/lib/mod_spox/Helpers.rb +29 -68
- data/lib/mod_spox/Loader.rb +23 -24
- data/lib/mod_spox/Logger.rb +19 -17
- data/lib/mod_spox/MessageFactory.rb +50 -24
- data/lib/mod_spox/Pipeline.rb +21 -7
- data/lib/mod_spox/Plugin.rb +27 -3
- data/lib/mod_spox/PluginManager.rb +28 -15
- data/lib/mod_spox/PriorityQueue.rb +69 -0
- data/lib/mod_spox/Socket.rb +93 -51
- data/lib/mod_spox/Sockets.rb +76 -63
- data/lib/mod_spox/Timer.rb +21 -141
- data/lib/mod_spox/Version.rb +14 -0
- data/lib/mod_spox/handlers/BadNick.rb +1 -1
- data/lib/mod_spox/handlers/Bounce.rb +5 -5
- data/lib/mod_spox/handlers/Created.rb +13 -5
- data/lib/mod_spox/handlers/Handler.rb +12 -3
- data/lib/mod_spox/handlers/Invite.rb +14 -8
- data/lib/mod_spox/handlers/Join.rb +24 -20
- data/lib/mod_spox/handlers/Kick.rb +22 -13
- data/lib/mod_spox/handlers/Mode.rb +42 -36
- data/lib/mod_spox/handlers/Motd.rb +4 -0
- data/lib/mod_spox/handlers/Names.rb +66 -39
- data/lib/mod_spox/handlers/Nick.rb +20 -14
- data/lib/mod_spox/handlers/Part.rb +25 -8
- data/lib/mod_spox/handlers/Ping.rb +11 -5
- data/lib/mod_spox/handlers/Pong.rb +9 -5
- data/lib/mod_spox/handlers/Privmsg.rb +25 -17
- data/lib/mod_spox/handlers/Quit.rb +13 -8
- data/lib/mod_spox/handlers/Topic.rb +4 -0
- data/lib/mod_spox/handlers/Welcome.rb +16 -24
- data/lib/mod_spox/handlers/Who.rb +64 -48
- data/lib/mod_spox/handlers/Whois.rb +92 -60
- data/lib/mod_spox/messages/incoming/Nick.rb +2 -2
- data/lib/mod_spox/messages/incoming/Privmsg.rb +1 -1
- data/lib/mod_spox/messages/incoming/Whois.rb +1 -0
- data/lib/mod_spox/messages/internal/EstablishConnection.rb +1 -1
- data/lib/mod_spox/messages/internal/PluginsReady.rb +10 -0
- data/lib/mod_spox/messages/internal/QueueSocket.rb +8 -0
- data/lib/mod_spox/messages/internal/Reconnect.rb +8 -0
- data/lib/mod_spox/messages/internal/UnqueueSocket.rb +8 -0
- data/lib/mod_spox/migrations/002_persistent_sigs.rb +14 -0
- data/lib/mod_spox/migrations/003_auth_restructure.rb +31 -0
- data/lib/mod_spox/migrations/004_mode_index_fix.rb +18 -0
- data/lib/mod_spox/migrations/005_nick_mode_nopark.rb +18 -0
- data/lib/mod_spox/models/Auth.rb +16 -46
- data/lib/mod_spox/models/AuthMask.rb +13 -0
- data/lib/mod_spox/models/Channel.rb +46 -27
- data/lib/mod_spox/models/Config.rb +10 -19
- data/lib/mod_spox/models/Group.rb +20 -8
- data/lib/mod_spox/models/Models.rb +1 -1
- data/lib/mod_spox/models/Nick.rb +105 -113
- data/lib/mod_spox/models/NickMode.rb +23 -9
- data/lib/mod_spox/models/Server.rb +12 -1
- data/lib/mod_spox/models/Setting.rb +12 -16
- data/lib/mod_spox/models/Signature.rb +28 -8
- data/tests/BotHolder.rb +24 -0
- data/tests/handlers/tc_BadNick.rb +21 -0
- data/tests/handlers/tc_Created.rb +24 -0
- data/tests/handlers/tc_Invite.rb +50 -0
- data/tests/handlers/tc_Join.rb +33 -0
- data/tests/handlers/tc_Kick.rb +32 -0
- data/tests/handlers/tc_Mode.rb +85 -0
- data/tests/handlers/tc_Names.rb +35 -0
- data/tests/handlers/tc_Nick.rb +55 -0
- data/tests/handlers/tc_Part.rb +44 -0
- data/tests/handlers/tc_Ping.rb +40 -0
- data/tests/handlers/tc_Pong.rb +28 -0
- data/tests/handlers/tc_Privmsg.rb +85 -0
- data/tests/handlers/tc_Quit.rb +40 -0
- data/tests/handlers/tc_Who.rb +50 -0
- data/tests/handlers/tc_Whois.rb +61 -0
- data/tests/models/tc_Auth.rb +34 -0
- data/tests/models/tc_Channel.rb +52 -0
- data/tests/models/tc_Config.rb +19 -0
- data/tests/models/tc_Nick.rb +142 -0
- data/tests/models/tc_NickMode.rb +40 -0
- data/tests/models/tc_Setting.rb +21 -0
- data/tests/models/tc_Signature.rb +14 -0
- data/tests/run_tests.rb +4 -0
- metadata +284 -212
- data/README +0 -36
- data/lib/mod_spox/Cache.rb +0 -57
- data/lib/mod_spox/Monitors.rb +0 -84
- data/lib/mod_spox/Pool.rb +0 -164
- data/lib/mod_spox/models/AuthGroup.rb +0 -16
- data/lib/mod_spox/models/ChannelMode.rb +0 -14
- data/lib/mod_spox/models/NickChannel.rb +0 -45
- data/lib/mod_spox/models/NickGroup.rb +0 -16
@@ -4,8 +4,7 @@ class Weather < ModSpox::Plugin
|
|
4
4
|
|
5
5
|
def initialize(pipeline)
|
6
6
|
super
|
7
|
-
|
8
|
-
:description => 'Show weather for given zipcode').params = [:zipcode]
|
7
|
+
add_sig(:sig => 'weather (\d+)', :method => :weather, :desc => 'Show weather for given zipcode', :params => [:zipcode])
|
9
8
|
end
|
10
9
|
|
11
10
|
def weather(message, params)
|
@@ -2,44 +2,29 @@ class Authenticator < ModSpox::Plugin
|
|
2
2
|
def initialize(pipeline)
|
3
3
|
super(pipeline)
|
4
4
|
group = Models::Group.filter(:name => 'admin').first
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Models::Signature.find_or_create(:signature => 'auth nick password (\S+) (\S+)', :plugin => name, :method => 'nick_pass',
|
22
|
-
:group_id => group.pk, :description => 'Set authentication password for nick').params = [:nick, :password]
|
23
|
-
Models::Signature.find_or_create(:signature => 'auth nick clear password (\S+)', :plugin => name, :method => 'clear_pass',
|
24
|
-
:group_id => group.pk, :description => 'Clear nicks authentication password').params = [:nick]
|
25
|
-
Models::Signature.find_or_create(:signature => 'auth nick info (\S+)', :plugin => name, :method => 'nick_info',
|
26
|
-
:group_id => group.pk, :description => 'Return authentication information about given nick').params = [:nick]
|
27
|
-
Models::Signature.find_or_create(:signature => 'auth nick set (\S+) (\S+)', :plugin => name, :method => 'set_nick',
|
28
|
-
:group_id => group.pk, :description => 'Set the group for a given nick').params = [:nick, :group]
|
29
|
-
Models::Signature.find_or_create(:signature => 'auth nick unset (\S+) (\S+)', :plugin => name, :method => 'unset_nick',
|
30
|
-
:group_id => group.pk, :description => 'Unset the group for a given nick').params = [:nick, :group]
|
31
|
-
Models::Signature.find_or_create(:signature => 'auth group list', :plugin => name, :method => 'list_groups',
|
32
|
-
:group_id => group.pk, :description => 'List available authentication groups')
|
33
|
-
Models::Signature.find_or_create(:signature => 'auth group info (\S+)', :plugin => name, :method => 'group_info',
|
34
|
-
:group_id => group.pk, :description => 'List members of given group').params = [:group]
|
35
|
-
Models::Signature.find_or_create(:signature => 'groups', :plugin => name, :method => 'show_groups',
|
36
|
-
:description => 'Show user groups they are currently a member of')
|
37
|
-
@whois_cache = []
|
5
|
+
add_sig(:sig => 'auth (\S+)', :method => :authenticate, :desc => 'Authenticate with bot using a password', :params => [:password])
|
6
|
+
add_sig(:sig => 'ident', :method => :do_ident, :desc => 'Instructs the bot to check your NickServ status')
|
7
|
+
add_sig(:sig => 'auth mask add (\S+) (\S+)', :method => :add_mask, :group => group, :desc => 'Add authentication mask and set initial group', :params => [:mask, :group])
|
8
|
+
add_sig(:sig => 'auth mask set (\d+) (.+)', :method => :set_mask_groups, :group => group, :desc => 'Set groups for the given mask', :params => [:id, :groups])
|
9
|
+
add_sig(:sig => 'auth mask unset (\d+) (.+)', :method => :del_mask_groups, :group => group, :desc => 'Remove groups for the given mask', :params => [:id, :groups])
|
10
|
+
add_sig(:sig => 'auth mask remove (\d+)', :method => :remove_mask, :group => group, :desc => 'Remove authentication mask', :params => [:id])
|
11
|
+
add_sig(:sig => 'auth mask list', :method => :list_mask, :group => group, :desc => 'List all available authentication masks')
|
12
|
+
add_sig(:sig => 'auth nick ident (\S+) (true|false)', :method => :nick_ident, :group => group, :desc => 'Allow authentication to nicks identified to NickServ', :params => [:nick, :ident])
|
13
|
+
add_sig(:sig => 'auth nick password (\S+) (\S+)', :method => :nick_pass, :group => group, :desc => 'Set authentication password for nick', :params => [:nick, :password])
|
14
|
+
add_sig(:sig => 'auth nick clear password (\S+)', :method => :clear_pass, :group => group, :desc => 'Clear nicks authentication password', :params => [:nick])
|
15
|
+
add_sig(:sig => 'auth nick info (\S+)', :method => :nick_info, :group => group, :desc => 'Return authentication information about given nick', :params => [:nick])
|
16
|
+
add_sig(:sig => 'auth nick set (\S+) (\S+)', :method => :set_nick, :group => group, :desc => 'Set the group for a given nick', :params => [:nick, :group])
|
17
|
+
add_sig(:sig => 'auth nick unset (\S+) (\S+)', :method => :unset_nick, :group => group, :desc => 'Unset the group for a given nick', :params => [:nick, :group])
|
18
|
+
add_sig(:sig => 'auth group list', :method => :list_groups, :group => group, :desc => 'List available authentication groups')
|
19
|
+
add_sig(:sig => 'auth group info (\S+)', :method => :group_info, :group => group, :desc => 'List members of given group', :params => [:group])
|
20
|
+
add_sig(:sig => 'groups', :method => :show_groups, :desc => 'Show user groups they are currently a member of')
|
38
21
|
@nickserv_nicks = []
|
22
|
+
@nickserv_cache = []
|
39
23
|
populate_nickserv
|
40
24
|
@pipeline.hook(self, :check_join, :Incoming_Join)
|
41
25
|
@pipeline.hook(self, :check_nicks, :Incoming_Who)
|
42
26
|
@pipeline.hook(self, :check_nicks, :Incoming_Names)
|
27
|
+
@pipeline.hook(self, :check_notice, :Incoming_Notice)
|
43
28
|
end
|
44
29
|
|
45
30
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
@@ -48,9 +33,9 @@ class Authenticator < ModSpox::Plugin
|
|
48
33
|
def authenticate(message, params)
|
49
34
|
return unless message.is_private?
|
50
35
|
if(message.is_private? && message.source.auth.check_password(params[:password]))
|
51
|
-
|
36
|
+
information message.replyto, 'Authentication was successful'
|
52
37
|
else
|
53
|
-
|
38
|
+
error message.replyto, 'Authentication failed'
|
54
39
|
end
|
55
40
|
end
|
56
41
|
|
@@ -61,12 +46,12 @@ class Authenticator < ModSpox::Plugin
|
|
61
46
|
begin
|
62
47
|
group = Models::Group.filter(:name => params[:group]).first
|
63
48
|
raise Exception.new("Failed to find group") unless group
|
64
|
-
a = Models::
|
65
|
-
a.group
|
49
|
+
a = Models::AuthMask.find_or_create(:mask => Regexp.new(params[:mask]).source)
|
50
|
+
a.add_group(group)
|
66
51
|
a.save
|
67
|
-
|
52
|
+
information message.replyto, 'Mask has been successfully added to authentication table'
|
68
53
|
rescue Object => boom
|
69
|
-
|
54
|
+
error message.replyto, "Authentication failed to add mask. Reason: #{boom}"
|
70
55
|
end
|
71
56
|
end
|
72
57
|
|
@@ -74,15 +59,15 @@ class Authenticator < ModSpox::Plugin
|
|
74
59
|
# params:: Signature parameters
|
75
60
|
# Add an authentication group to a given mask
|
76
61
|
def set_mask_groups(message, params)
|
77
|
-
auth = Models::
|
62
|
+
auth = Models::AuthMask[params[:id].to_i]
|
78
63
|
if(auth)
|
79
64
|
params[:groups].split(/\s/).each do |g|
|
80
65
|
group = Models::Group.filter(:name => g).first
|
81
|
-
auth.group
|
66
|
+
auth.add_group(group) if group
|
82
67
|
end
|
83
|
-
|
68
|
+
information message.replyto, "Mask groups have been updated"
|
84
69
|
else
|
85
|
-
|
70
|
+
error message.replyto, "Failed to find mask with ID: #{params[:id]}"
|
86
71
|
end
|
87
72
|
end
|
88
73
|
|
@@ -90,15 +75,15 @@ class Authenticator < ModSpox::Plugin
|
|
90
75
|
# params:: Signature parameters
|
91
76
|
# Remove an authentication group from a given mask
|
92
77
|
def del_mask_groups(message, params)
|
93
|
-
auth = Models::
|
78
|
+
auth = Models::AuthMask[params[:id].to_i]
|
94
79
|
if(auth)
|
95
80
|
params[:groups].split(/\s/).each do |g|
|
96
81
|
group = Models::Group.filter(:name => g).first
|
97
82
|
auth.remove_group(group) if group
|
98
83
|
end
|
99
|
-
|
84
|
+
information message.replyto, "Mask groups have been updated"
|
100
85
|
else
|
101
|
-
|
86
|
+
error message.replyto, "Failed to find mask with ID: #{params[:id]}"
|
102
87
|
end
|
103
88
|
end
|
104
89
|
|
@@ -106,26 +91,25 @@ class Authenticator < ModSpox::Plugin
|
|
106
91
|
# params:: Signature parameters
|
107
92
|
# List all authentication masks
|
108
93
|
def list_mask(message, params)
|
109
|
-
|
110
|
-
|
111
|
-
Models::Auth.where('mask is not null').each{|a| auths << a}
|
112
|
-
auths.each do |a|
|
94
|
+
output = ["\2Authentication Mask Listing:\2"]
|
95
|
+
Models::AuthMask.all.each do |a|
|
113
96
|
groups = []
|
114
97
|
a.groups.each{|g| groups << g.name}
|
115
|
-
|
98
|
+
output << "\2ID:\2 #{a.pk}: \2mask:\2 #{a.mask} \2groups:\2 #{groups.join(', ')}"
|
116
99
|
end
|
100
|
+
reply message.replyto, output
|
117
101
|
end
|
118
102
|
|
119
103
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
120
104
|
# params:: Signature parameters
|
121
105
|
# Remove given authentication mask
|
122
106
|
def remove_mask(message, params)
|
123
|
-
auth = Models::
|
107
|
+
auth = Models::AuthMask[params[:id].to_i]
|
124
108
|
if(auth)
|
125
109
|
auth.destroy
|
126
|
-
|
110
|
+
information message.replyto, "Authentication mask with ID #{params[:id]} was deleted"
|
127
111
|
else
|
128
|
-
|
112
|
+
error message.replyto, "\2Failed\2: Could not find an authentication mask with ID: #{params[:id]}"
|
129
113
|
end
|
130
114
|
end
|
131
115
|
|
@@ -135,11 +119,12 @@ class Authenticator < ModSpox::Plugin
|
|
135
119
|
def nick_ident(message, params)
|
136
120
|
nick = Models::Nick.locate(params[:nick])
|
137
121
|
if(params[:ident] == 'true')
|
138
|
-
nick.auth.
|
122
|
+
nick.auth.update(:services => true)
|
139
123
|
else
|
140
|
-
nick.auth.
|
124
|
+
nick.auth.update(:services => false)
|
141
125
|
end
|
142
|
-
|
126
|
+
populate_nickserv
|
127
|
+
information message.replyto, "Nick #{params[:nick]} has been updated. Services for authentication has been set to #{params[:ident]}"
|
143
128
|
end
|
144
129
|
|
145
130
|
|
@@ -149,7 +134,7 @@ class Authenticator < ModSpox::Plugin
|
|
149
134
|
def nick_pass(message, params)
|
150
135
|
nick = Models::Nick.locate(params[:nick])
|
151
136
|
nick.auth.password = params[:password]
|
152
|
-
|
137
|
+
information message.replyto, "Nick #{params[:nick]} has been updated. Password has been set."
|
153
138
|
end
|
154
139
|
|
155
140
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
@@ -158,7 +143,8 @@ class Authenticator < ModSpox::Plugin
|
|
158
143
|
def clear_pass(message, params)
|
159
144
|
nick = Models::Nick.locate(params[:nick])
|
160
145
|
nick.auth.password = nil
|
161
|
-
|
146
|
+
nick.auth.save
|
147
|
+
information message.replyto, "Nick #{params[:nick]} has been updated. Password has been unset."
|
162
148
|
end
|
163
149
|
|
164
150
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
@@ -170,25 +156,24 @@ class Authenticator < ModSpox::Plugin
|
|
170
156
|
info = []
|
171
157
|
info << "\2INFO [#{nick.nick}]:\2"
|
172
158
|
groups = []
|
173
|
-
|
174
|
-
groups << ag.
|
159
|
+
nick.auth.groups.each do |ag|
|
160
|
+
groups << ag.name
|
175
161
|
end
|
176
162
|
info << "Groups: #{groups.uniq.sort.join(', ')}."
|
177
|
-
nick.auth.password.nil? ? info << 'Password has not been set.' : info << 'Password has been set.'
|
163
|
+
nick.auth.password.nil? || nick.auth.password.empty? ? info << 'Password has not been set.' : info << 'Password has been set.'
|
178
164
|
nick.auth.services ? info << 'Nickserv ident is enabled.' : info << 'Nickserv ident is disabled.'
|
179
|
-
|
165
|
+
information message.replyto, "#{info.join(' ')}"
|
180
166
|
else
|
181
|
-
|
167
|
+
error message.replyto, "I have no record of nick: #{params[:nick]}"
|
182
168
|
end
|
183
169
|
end
|
184
170
|
|
185
171
|
def show_groups(message, params)
|
186
|
-
groups =
|
187
|
-
|
188
|
-
if(groups.empty?)
|
172
|
+
groups = message.source.auth_groups.map{|g| g.name}
|
173
|
+
if(groups.nil? || groups.empty?)
|
189
174
|
reply message.replyto, "You are not currently a member of any groups"
|
190
175
|
else
|
191
|
-
reply message.replyto, "\2Groups (#{message.source.nick}):\2 #{groups.join(', ')}"
|
176
|
+
reply message.replyto, "\2Groups (#{message.source.nick}):\2 #{groups.sort.join(', ')}"
|
192
177
|
end
|
193
178
|
end
|
194
179
|
|
@@ -199,11 +184,10 @@ class Authenticator < ModSpox::Plugin
|
|
199
184
|
group = Models::Group.filter(:name => params[:group]).first
|
200
185
|
nick = Models::Nick.locate(params[:nick])
|
201
186
|
if(group)
|
202
|
-
nick.auth.group
|
203
|
-
|
187
|
+
nick.auth.add_group(group)
|
188
|
+
information message.replyto, "Nick #{params[:nick]} has been added to the group: #{params[:group]}"
|
204
189
|
else
|
205
|
-
|
206
|
-
|
190
|
+
error message.replyto, "Failed to find authentication group: #{params[:group]}"
|
207
191
|
end
|
208
192
|
end
|
209
193
|
|
@@ -214,29 +198,29 @@ class Authenticator < ModSpox::Plugin
|
|
214
198
|
group = Models::Group.filter(:name => params[:group]).first
|
215
199
|
nick = Helpers.find_model(params[:nick], false)
|
216
200
|
if(group && nick)
|
217
|
-
nick.remove_group(group)
|
218
|
-
|
201
|
+
nick.auth.remove_group(group)
|
202
|
+
information message.replyto, "Removed #{params[:nick]} from the #{params[:group]} authentication group."
|
219
203
|
else
|
220
|
-
|
221
|
-
|
204
|
+
error message.replyto, "Failed to find nick: #{params[:nick]}" unless nick
|
205
|
+
error message.replyto, "Failed to find group: #{params[:group]}" unless group
|
222
206
|
end
|
223
207
|
end
|
224
208
|
|
225
209
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
226
210
|
# params:: Signature parameters
|
227
211
|
# Send WHOIS for nick
|
228
|
-
def
|
229
|
-
message.source.
|
230
|
-
|
212
|
+
def do_ident(message, params)
|
213
|
+
message.source.check_masks
|
214
|
+
check_nickserv(message.source, true)
|
215
|
+
#@pipeline << Messages::Outgoing::Whois.new(message.source.nick)
|
231
216
|
end
|
232
217
|
|
233
218
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
234
219
|
# params:: Signature parameters
|
235
220
|
# Display all available authentication groups
|
236
221
|
def list_groups(message, params)
|
237
|
-
groups =
|
238
|
-
|
239
|
-
@pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "\2Groups:\2 #{groups.join(', ')}")
|
222
|
+
groups = Models::Group.all.map{|g| g.name}
|
223
|
+
information message.replyto, "\2Groups:\2 #{groups.sort.join(', ')}"
|
240
224
|
end
|
241
225
|
|
242
226
|
# message:: ModSpox::Messages::Incoming::Privmsg
|
@@ -246,46 +230,57 @@ class Authenticator < ModSpox::Plugin
|
|
246
230
|
group = Models::Group.filter(:name => params[:group]).first
|
247
231
|
if(group)
|
248
232
|
nicks = []
|
233
|
+
group.auths.each{|a| nicks << a.nick.nick}
|
249
234
|
masks = []
|
250
|
-
|
251
|
-
if(ag.auth.nick)
|
252
|
-
nicks << ag.auth.nick.nick
|
253
|
-
end
|
254
|
-
if(ag.auth.mask)
|
255
|
-
masks << ag.auth.mask
|
256
|
-
end
|
257
|
-
end
|
235
|
+
group.auth_masks.each{|a| masks << a.map}
|
258
236
|
output = []
|
259
237
|
output << "\2Nicks:\2 #{nicks.join(', ')}" if nicks.size > 0
|
260
238
|
output << "\2Masks:\2 #{masks.join(' | ')}" if masks.size > 0
|
261
|
-
|
239
|
+
information message.replyto, "\2Group #{params[:group]}:\2 #{output.join('. ')}"
|
262
240
|
else
|
263
|
-
|
241
|
+
error message.replyto, "Failed to find group named: #{params[:group]}"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def check_notice(m)
|
246
|
+
if(m.source.is_a?(Models::Nick) && m.source.nick.downcase == 'nickserv' && m.source.host == 'dal.net')
|
247
|
+
message = m.message.dup
|
248
|
+
nick = message.slice!(0..message.index(' ')-1)
|
249
|
+
message.slice!(0)
|
250
|
+
message.slice!(0..message.index(' '))
|
251
|
+
setting = message.to_i
|
252
|
+
if(setting == 3)
|
253
|
+
user = Helpers.find_model(nick)
|
254
|
+
user.auth.services_identified = true
|
255
|
+
Logger.info("User has been authenticated through NickServ services. (#{user.nick})")
|
256
|
+
end
|
264
257
|
end
|
265
258
|
end
|
266
259
|
|
267
260
|
# Populates array with nicks that authenticate by nickserv
|
268
261
|
def populate_nickserv
|
262
|
+
@nickserv_nicks.clear
|
269
263
|
Models::Auth.filter('services = ?', true).each do |auth|
|
270
264
|
@nickserv_nicks << auth.nick.nick.downcase
|
271
265
|
end
|
272
266
|
end
|
273
267
|
|
274
|
-
def check_nickserv(nick)
|
268
|
+
def check_nickserv(nick, force=false)
|
269
|
+
populate_nickserv if @nickserv_nicks.empty?
|
275
270
|
if(@nickserv_nicks.include?(nick.nick.downcase))
|
276
|
-
if(!nick.auth.authed && !@
|
277
|
-
@
|
278
|
-
@
|
271
|
+
if(force || (!nick.auth.authed && !@nickserv_cache.include?(nick.nick.downcase)))
|
272
|
+
@nickserv_cache << nick.nick.downcase unless @nickserv_cache.include?(nick.nick.downcase)
|
273
|
+
@pipeline << Messages::Outgoing::Raw.new("nickserv ACC #{nick.nick}")
|
279
274
|
end
|
280
275
|
end
|
281
276
|
end
|
282
277
|
|
283
278
|
def check_join(message)
|
284
|
-
check_nickserv(message.nick)
|
279
|
+
check_nickserv(message.nick) unless message.nick == me
|
285
280
|
end
|
286
281
|
|
287
282
|
def check_nicks(message)
|
288
|
-
message.nicks.each{|nick| check_nickserv(nick) }
|
283
|
+
@pipeline << Messages::Internal::TimerAdd.new(self, 20, nil, true){ message.nicks.each{|nick| check_nickserv(nick) } }
|
289
284
|
end
|
290
285
|
|
291
286
|
end
|
@@ -6,33 +6,19 @@ class Banner < ModSpox::Plugin
|
|
6
6
|
def initialize(pipeline)
|
7
7
|
super
|
8
8
|
admin = Group.find_or_create(:name => 'banner')
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Signature.find_or_create(:signature => 'banlist', :plugin => name, :method => 'ban_list', :group_id => admin.pk,
|
23
|
-
:description => 'List all currently active bans generated from the bot')
|
24
|
-
Signature.find_or_create(:signature => 'banlist remove (\d+)', :plugin => name, :method => 'ban_remove', :group_id => admin.pk,
|
25
|
-
:description => 'Remove a current ban').params = [:id]
|
26
|
-
Signature.find_or_create(:signature => 'exempt mode ([ov]) ?(\S+)?', :plugin => name, :method => 'exempt_mode', :group_id => admin.pk,
|
27
|
-
:description => 'Exempt given modes from kick. Apply to all channels if one is not provided').params = [:mode, :channel]
|
28
|
-
Signature.find_or_create(:signature => 'exempt nick (\S+) ?(\S+)?', :plugin => name, :method => 'exempt_nick', :group_id => admin.pk,
|
29
|
-
:description => 'Exempt a nick from kicks globally or per channel').params = [:nick, :channel]
|
30
|
-
Signature.find_or_create(:signature => 'exempt source (\S+)', :plugin => name, :method => 'exempt_source', :group_id => admin.pk,
|
31
|
-
:description => 'Exempt a source from kicks globally or per channel').params = [:source, :channel]
|
32
|
-
Signature.find_or_create(:signature => 'exempt list (nick|mode|source)', :plugin => name, :method => 'exempt_list', :group_id => admin.pk,
|
33
|
-
:description => 'List current exemptions of given type').params = [:type]
|
34
|
-
Signature.find_or_create(:signature => 'exempt remove (nick|mode|source) (\d+)', :plugin => name, :method => 'exempt_remove', :group_id => admin.pk,
|
35
|
-
:description => 'Remove exemption from given type').params = [:type, :id]
|
9
|
+
add_sig(:sig => 'ban (\S+)', :method => :default_ban, :group => admin, :desc => 'Kickban given nick from current channel', :params => [:nick])
|
10
|
+
add_sig(:sig => 'ban (\S+) (\S+)', :method => :channel_ban, :group => admin, :desc => 'Kickban given nick from given channel', :params => [:nick, :channel])
|
11
|
+
add_sig(:sig => 'ban (\S+) (\S+) (\d+) ?(.+)?', :method => :full_ban, :group => admin, :desc => 'Kickban given nick from given channel for given number of seconds', :params => [:nick, :channel, :time, :message])
|
12
|
+
add_sig(:sig => 'banmask (\S+) (\S+) (\d+) ?(.+)?', :method => :message_mask_ban, :group => admin, :desc => 'Kickban given mask from given channel for given number of seconds providing an optional message', :params => [:mask, :channel, :time, :message])
|
13
|
+
add_sig(:sig => 'banmask list', :method => :mask_list, :group => admin, :desc => 'List all currently active banmasks')
|
14
|
+
add_sig(:sig => 'banmask remove (\d+)', :method => :mask_remove, :group => admin, :desc => 'Remove a currently enabled ban mask', :params => [:id])
|
15
|
+
add_sig(:sig => 'banlist', :method => :ban_list, :group => admin, :desc => 'List all currently active bans generated from the bot')
|
16
|
+
add_sig(:sig => 'banlist remove (\d+)', :method => :ban_remove, :group => admin, :desc => 'Remove a current ban', :params => [:id])
|
17
|
+
add_sig(:sig => 'exempt mode ([ov]) ?(\S+)?', :method => :exempt_mode, :group => admin, :desc => 'Exempt given modes from kick. Apply to all channels if one is not provided', :params => [:mode, :channel])
|
18
|
+
add_sig(:sig => 'exempt nick (\S+) ?(\S+)?', :method => :exempt_nick, :group => admin, :desc => 'Exempt a nick from kicks globally or per channel', :params => [:nick, :channel])
|
19
|
+
add_sig(:sig => 'exempt source (\S+)', :method => :exempt_source, :group => admin, :desc => 'Exempt a source from kicks globally or per channel', :params => [:source, :channel])
|
20
|
+
add_sig(:sig => 'exempt list (nick|mode|source)', :method => :exempt_list, :group => admin, :desc => 'List current exemptions of given type', :params => [:type])
|
21
|
+
add_sig(:sig => 'exempt remove (nick|mode|source) (\d+)', :method => :exempt_remove, :group => admin, :desc => 'Remove exemption from given type', :params => [:type, :id])
|
36
22
|
@pipeline.hook(self, :mode_check, :Incoming_Mode)
|
37
23
|
@pipeline.hook(self, :join_check, :Incoming_Join)
|
38
24
|
@pipeline.hook(self, :who_check, :Incoming_Who)
|
@@ -197,7 +183,7 @@ class Banner < ModSpox::Plugin
|
|
197
183
|
# List all currently active bans originating from the bot
|
198
184
|
def ban_list(message, params)
|
199
185
|
set = BanRecord.filter(:removed => false)
|
200
|
-
if(set.
|
186
|
+
if(set.count > 0)
|
201
187
|
reply(message.replyto, "Currently active bans:")
|
202
188
|
set.each do |record|
|
203
189
|
remains = record.remaining.to_i - (Object::Time.now.to_i - @time.to_i)
|
@@ -477,16 +463,11 @@ class Banner < ModSpox::Plugin
|
|
477
463
|
foreign_key :nick_id, :null => false, :table => :nicks, :key => :id
|
478
464
|
end
|
479
465
|
|
480
|
-
|
481
|
-
|
482
|
-
end
|
483
|
-
|
484
|
-
def channel
|
485
|
-
ModSpox::Models::Channel[channel_id]
|
486
|
-
end
|
466
|
+
many_to_one :channel, :class => ModSpox::Models::Channel
|
467
|
+
many_to_one :nick, :class => ModSpox::Models::Nick
|
487
468
|
|
488
|
-
def
|
489
|
-
|
469
|
+
def before_create
|
470
|
+
update(:stamp => Object::Time.now)
|
490
471
|
end
|
491
472
|
end
|
492
473
|
|
@@ -500,9 +481,7 @@ class Banner < ModSpox::Plugin
|
|
500
481
|
foreign_key :channel_id, :null => false, :table => :channels, :key => :id
|
501
482
|
end
|
502
483
|
|
503
|
-
|
504
|
-
ModSpox::Models::Channel[channel_id]
|
505
|
-
end
|
484
|
+
many_to_one :channel, :class => ModSpox::Models::Channel
|
506
485
|
|
507
486
|
def self.map_masks
|
508
487
|
masks = {}
|
@@ -521,14 +500,9 @@ class Banner < ModSpox::Plugin
|
|
521
500
|
foreign_key :nick_id, :table => :nicks, :null => false, :key => :id
|
522
501
|
foreign_key :channel_id, :table => :channels, :key => :id
|
523
502
|
end
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
end
|
528
|
-
|
529
|
-
def channel
|
530
|
-
return Models::Channel[channel_id]
|
531
|
-
end
|
503
|
+
|
504
|
+
many_to_one :nick, :class => ModSpox::Models::Nick
|
505
|
+
many_to_one :channel, :class => ModSpox::Models::Channel
|
532
506
|
end
|
533
507
|
|
534
508
|
class BanSourceExempt < Sequel::Model
|
@@ -538,16 +512,14 @@ class Banner < ModSpox::Plugin
|
|
538
512
|
foreign_key :channel_id, :table => :channels, :key => :id
|
539
513
|
end
|
540
514
|
|
541
|
-
|
542
|
-
return Models::Channel[channel_id]
|
543
|
-
end
|
515
|
+
many_to_one :channel, :class => ModSpox::Models::Channel
|
544
516
|
|
545
517
|
def mask
|
546
518
|
return values[:source] ? Marshal.load(values[:source].unpack('m')[0]) : nil
|
547
519
|
end
|
548
520
|
|
549
521
|
def mask=(val)
|
550
|
-
|
522
|
+
update(:source => [Marshal.dump(val)].pack('m'))
|
551
523
|
end
|
552
524
|
|
553
525
|
end
|
@@ -559,10 +531,8 @@ class Banner < ModSpox::Plugin
|
|
559
531
|
foreign_key :channel_id, :table => :channels, :key => :id
|
560
532
|
index [:channel_id, :mode]
|
561
533
|
end
|
562
|
-
|
563
|
-
|
564
|
-
return Models::Channel[channel_id]
|
565
|
-
end
|
534
|
+
|
535
|
+
many_to_one :channel, :class => ModSpox::Models::Channel
|
566
536
|
end
|
567
537
|
|
568
538
|
class NotOperator < Exceptions::BotException
|