mod_spox 0.1.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/CHANGELOG +36 -0
  2. data/INSTALL +2 -2
  3. data/README +0 -1
  4. data/bin/mod_spox +51 -12
  5. data/data/mod_spox/extras/AOLSpeak.rb +5 -18
  6. data/data/mod_spox/extras/AutoKick.rb +44 -23
  7. data/data/mod_spox/extras/AutoMode.rb +2 -5
  8. data/data/mod_spox/extras/AutoRejoin.rb +21 -0
  9. data/data/mod_spox/extras/Bouncer.rb +10 -10
  10. data/data/mod_spox/extras/Bytes.rb +12 -0
  11. data/data/mod_spox/extras/Confess.rb +131 -52
  12. data/data/mod_spox/extras/DCC.rb +189 -0
  13. data/data/mod_spox/extras/DevWatch.rb +32 -33
  14. data/data/mod_spox/extras/FloodKicker.rb +129 -0
  15. data/data/mod_spox/extras/GoogleIt.rb +13 -0
  16. data/data/mod_spox/extras/Headers.rb +31 -4
  17. data/data/mod_spox/extras/Karma.rb +103 -49
  18. data/data/mod_spox/extras/Logger.rb +45 -30
  19. data/data/mod_spox/extras/LolSpeak.rb +1 -1
  20. data/data/mod_spox/extras/NickServ.rb +83 -0
  21. data/data/mod_spox/extras/PhpCli.rb +12 -15
  22. data/data/mod_spox/extras/PhpFuncLookup.rb +57 -25
  23. data/data/mod_spox/extras/Quotes.rb +5 -4
  24. data/data/mod_spox/extras/RegexTracker.rb +160 -0
  25. data/data/mod_spox/extras/Roulette.rb +22 -23
  26. data/data/mod_spox/extras/Search.rb +3 -2
  27. data/data/mod_spox/extras/Slashdot.rb +35 -0
  28. data/data/mod_spox/extras/Topten.rb +5 -5
  29. data/data/mod_spox/extras/TracTicket.rb +68 -0
  30. data/data/mod_spox/extras/Translate.rb +69 -30
  31. data/data/mod_spox/extras/Twitter.rb +372 -0
  32. data/data/mod_spox/extras/UrbanDictionary.rb +21 -12
  33. data/data/mod_spox/extras/Weather.rb +1 -1
  34. data/data/mod_spox/plugins/Authenticator.rb +63 -30
  35. data/data/mod_spox/plugins/Banner.rb +164 -151
  36. data/data/mod_spox/plugins/Helper.rb +18 -7
  37. data/data/mod_spox/plugins/PluginLoader.rb +46 -22
  38. data/data/mod_spox/plugins/PoolConfig.rb +52 -0
  39. data/data/mod_spox/plugins/Quitter.rb +1 -1
  40. data/data/mod_spox/plugins/Status.rb +28 -0
  41. data/lib/mod_spox/Action.rb +20 -3
  42. data/lib/mod_spox/BaseConfig.rb +1 -0
  43. data/lib/mod_spox/Bot.rb +98 -75
  44. data/lib/mod_spox/BotConfig.rb +14 -6
  45. data/lib/mod_spox/ConfigurationWizard.rb +94 -105
  46. data/lib/mod_spox/Database.rb +33 -13
  47. data/lib/mod_spox/Helpers.rb +67 -38
  48. data/lib/mod_spox/Loader.rb +25 -5
  49. data/lib/mod_spox/Logger.rb +20 -62
  50. data/lib/mod_spox/MessageFactory.rb +34 -25
  51. data/lib/mod_spox/Monitors.rb +5 -0
  52. data/lib/mod_spox/Pipeline.rb +40 -51
  53. data/lib/mod_spox/Plugin.rb +40 -9
  54. data/lib/mod_spox/PluginManager.rb +46 -38
  55. data/lib/mod_spox/Pool.rb +129 -143
  56. data/lib/mod_spox/Socket.rb +41 -50
  57. data/lib/mod_spox/Sockets.rb +211 -0
  58. data/lib/mod_spox/Timer.rb +86 -69
  59. data/lib/mod_spox/handlers/BadNick.rb +1 -1
  60. data/lib/mod_spox/handlers/Created.rb +1 -1
  61. data/lib/mod_spox/handlers/Handler.rb +9 -0
  62. data/lib/mod_spox/handlers/Invite.rb +1 -1
  63. data/lib/mod_spox/handlers/Join.rb +2 -2
  64. data/lib/mod_spox/handlers/Kick.rb +1 -1
  65. data/lib/mod_spox/handlers/LuserChannels.rb +1 -1
  66. data/lib/mod_spox/handlers/LuserOp.rb +1 -1
  67. data/lib/mod_spox/handlers/LuserUnknown.rb +1 -1
  68. data/lib/mod_spox/handlers/Mode.rb +2 -2
  69. data/lib/mod_spox/handlers/MyInfo.rb +1 -1
  70. data/lib/mod_spox/handlers/Names.rb +1 -1
  71. data/lib/mod_spox/handlers/Nick.rb +20 -3
  72. data/lib/mod_spox/handlers/NickInUse.rb +3 -3
  73. data/lib/mod_spox/handlers/Notice.rb +5 -15
  74. data/lib/mod_spox/handlers/Part.rb +1 -1
  75. data/lib/mod_spox/handlers/Ping.rb +1 -1
  76. data/lib/mod_spox/handlers/Pong.rb +1 -1
  77. data/lib/mod_spox/handlers/Privmsg.rb +2 -2
  78. data/lib/mod_spox/handlers/Quit.rb +1 -1
  79. data/lib/mod_spox/handlers/Topic.rb +2 -1
  80. data/lib/mod_spox/handlers/Welcome.rb +3 -3
  81. data/lib/mod_spox/handlers/Who.rb +9 -7
  82. data/lib/mod_spox/handlers/Whois.rb +29 -16
  83. data/lib/mod_spox/handlers/YourHost.rb +1 -1
  84. data/lib/mod_spox/messages/incoming/Privmsg.rb +38 -19
  85. data/lib/mod_spox/messages/internal/DCCListener.rb +12 -0
  86. data/lib/mod_spox/messages/internal/DCCRequest.rb +12 -0
  87. data/lib/mod_spox/messages/internal/DCCSocket.rb +19 -0
  88. data/lib/mod_spox/messages/internal/StatusRequest.rb +2 -1
  89. data/lib/mod_spox/messages/outgoing/Privmsg.rb +21 -5
  90. data/lib/mod_spox/migrations/001_initialize_models.rb +115 -0
  91. data/lib/mod_spox/models/Auth.rb +24 -16
  92. data/lib/mod_spox/models/AuthGroup.rb +4 -3
  93. data/lib/mod_spox/models/Channel.rb +20 -12
  94. data/lib/mod_spox/models/ChannelMode.rb +2 -2
  95. data/lib/mod_spox/models/Config.rb +11 -3
  96. data/lib/mod_spox/models/Group.rb +6 -1
  97. data/lib/mod_spox/models/Nick.rb +93 -33
  98. data/lib/mod_spox/models/NickChannel.rb +8 -6
  99. data/lib/mod_spox/models/NickGroup.rb +16 -0
  100. data/lib/mod_spox/models/NickMode.rb +3 -3
  101. data/lib/mod_spox/models/Server.rb +6 -2
  102. data/lib/mod_spox/models/Setting.rb +12 -6
  103. data/lib/mod_spox/models/Signature.rb +7 -13
  104. data/lib/mod_spox/models/Trigger.rb +1 -1
  105. metadata +125 -100
@@ -2,7 +2,7 @@ class Authenticator < ModSpox::Plugin
2
2
  def initialize(pipeline)
3
3
  super(pipeline)
4
4
  group = Models::Group.filter(:name => 'admin').first
5
- Models::Signature.find_or_create(:signature => 'auth (\S+)', :plugin => name, :method => 'authenticate',
5
+ Models::Signature.find_or_create(:signature => 'auth (\S+)', :plugin => name, :method => 'authenticate',
6
6
  :description => 'Authenticate with bot using a password').params = [:password]
7
7
  Models::Signature.find_or_create(:signature => 'ident', :plugin => name, :method => 'send_whois',
8
8
  :description => 'Instructs the bot to check your NickServ status')
@@ -18,13 +18,13 @@ class Authenticator < ModSpox::Plugin
18
18
  :group_id => group.pk, :description => 'List all available authentication masks')
19
19
  Models::Signature.find_or_create(:signature => 'auth nick ident (\S+) (true|false)', :plugin => name, :method => 'nick_ident',
20
20
  :group_id => group.pk, :description => 'Allow authentication to nicks identified to NickServ').params = [:nick, :ident]
21
- Models::Signature.find_or_create(:signature => 'auth nick password (\S+) (\S+)', :plugin => name, :method => 'nick_pass',
21
+ Models::Signature.find_or_create(:signature => 'auth nick password (\S+) (\S+)', :plugin => name, :method => 'nick_pass',
22
22
  :group_id => group.pk, :description => 'Set authentication password for nick').params = [:nick, :password]
23
23
  Models::Signature.find_or_create(:signature => 'auth nick clear password (\S+)', :plugin => name, :method => 'clear_pass',
24
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',
25
+ Models::Signature.find_or_create(:signature => 'auth nick info (\S+)', :plugin => name, :method => 'nick_info',
26
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',
27
+ Models::Signature.find_or_create(:signature => 'auth nick set (\S+) (\S+)', :plugin => name, :method => 'set_nick',
28
28
  :group_id => group.pk, :description => 'Set the group for a given nick').params = [:nick, :group]
29
29
  Models::Signature.find_or_create(:signature => 'auth nick unset (\S+) (\S+)', :plugin => name, :method => 'unset_nick',
30
30
  :group_id => group.pk, :description => 'Unset the group for a given nick').params = [:nick, :group]
@@ -34,8 +34,14 @@ class Authenticator < ModSpox::Plugin
34
34
  :group_id => group.pk, :description => 'List members of given group').params = [:group]
35
35
  Models::Signature.find_or_create(:signature => 'groups', :plugin => name, :method => 'show_groups',
36
36
  :description => 'Show user groups they are currently a member of')
37
+ @whois_cache = []
38
+ @nickserv_nicks = []
39
+ populate_nickserv
40
+ @pipeline.hook(self, :check_join, :Incoming_Join)
41
+ @pipeline.hook(self, :check_nicks, :Incoming_Who)
42
+ @pipeline.hook(self, :check_nicks, :Incoming_Names)
37
43
  end
38
-
44
+
39
45
  # message:: ModSpox::Messages::Incoming::Privmsg
40
46
  # params:: Signature parameters
41
47
  # Authenticate a user by password
@@ -45,9 +51,9 @@ class Authenticator < ModSpox::Plugin
45
51
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, 'Authentication was successful')
46
52
  else
47
53
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, 'Authentication failed')
48
- end
54
+ end
49
55
  end
50
-
56
+
51
57
  # message:: ModSpox::Messages::Incoming::Privmsg
52
58
  # params:: Signature parameters
53
59
  # Add an authentication mask
@@ -63,7 +69,7 @@ class Authenticator < ModSpox::Plugin
63
69
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Authentication failed to add mask. Reason: #{boom}")
64
70
  end
65
71
  end
66
-
72
+
67
73
  # message:: ModSpox::Messages::Incoming::Privmsg
68
74
  # params:: Signature parameters
69
75
  # Add an authentication group to a given mask
@@ -79,7 +85,7 @@ class Authenticator < ModSpox::Plugin
79
85
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Failed to find mask with ID: #{params[:id]}")
80
86
  end
81
87
  end
82
-
88
+
83
89
  # message:: ModSpox::Messages::Incoming::Privmsg
84
90
  # params:: Signature parameters
85
91
  # Remove an authentication group from a given mask
@@ -95,7 +101,7 @@ class Authenticator < ModSpox::Plugin
95
101
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Failed to find mask with ID: #{params[:id]}")
96
102
  end
97
103
  end
98
-
104
+
99
105
  # message:: ModSpox::Messages::Incoming::Privmsg
100
106
  # params:: Signature parameters
101
107
  # List all authentication masks
@@ -109,7 +115,7 @@ class Authenticator < ModSpox::Plugin
109
115
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "\2ID:\2 #{a.pk}: \2mask:\2 #{a.mask} \2groups:\2 #{groups.join(', ')}")
110
116
  end
111
117
  end
112
-
118
+
113
119
  # message:: ModSpox::Messages::Incoming::Privmsg
114
120
  # params:: Signature parameters
115
121
  # Remove given authentication mask
@@ -122,12 +128,12 @@ class Authenticator < ModSpox::Plugin
122
128
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "\2Failed\2: Could not find an authentication mask with ID: #{params[:id]}")
123
129
  end
124
130
  end
125
-
131
+
126
132
  # message:: ModSpox::Messages::Incoming::Privmsg
127
133
  # params:: Signature parameters
128
134
  # Set nick authentication by NickServ
129
135
  def nick_ident(message, params)
130
- nick = Models::Nick.find_or_create(:nick => params[:nick])
136
+ nick = Models::Nick.locate(params[:nick])
131
137
  if(params[:ident] == 'true')
132
138
  nick.auth.update_with_params(:services => true)
133
139
  else
@@ -135,26 +141,26 @@ class Authenticator < ModSpox::Plugin
135
141
  end
136
142
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Nick #{params[:nick]} has been updated. Services for authentication has been set to #{params[:ident]}")
137
143
  end
138
-
139
-
144
+
145
+
140
146
  # message:: ModSpox::Messages::Incoming::Privmsg
141
147
  # params:: Signature parameters
142
148
  # Set password for given nick
143
149
  def nick_pass(message, params)
144
- nick = Models::Nick.find_or_create(:nick => params[:nick])
150
+ nick = Models::Nick.locate(params[:nick])
145
151
  nick.auth.password = params[:password]
146
152
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Nick #{params[:nick]} has been updated. Password has been set.")
147
153
  end
148
-
154
+
149
155
  # message:: ModSpox::Messages::Incoming::Privmsg
150
156
  # params:: Signature parameters
151
157
  # Clear password field for given nick
152
- def nick_clear(message, params)
153
- nick = Models::Nick.find_or_create(:nick => params[:nick])
158
+ def clear_pass(message, params)
159
+ nick = Models::Nick.locate(params[:nick])
154
160
  nick.auth.password = nil
155
- @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Nick #{params[:nick]} has been updated. Password has been set.")
161
+ @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Nick #{params[:nick]} has been updated. Password has been unset.")
156
162
  end
157
-
163
+
158
164
  # message:: ModSpox::Messages::Incoming::Privmsg
159
165
  # params:: Signature parameters
160
166
  # Display info for given nick
@@ -164,7 +170,9 @@ class Authenticator < ModSpox::Plugin
164
170
  info = []
165
171
  info << "\2INFO [#{nick.nick}]:\2"
166
172
  groups = []
167
- nick.auth_groups.each{|g| groups << g.name}
173
+ Models::AuthGroup.filter(:auth_id => nick.auth.pk).each do |ag|
174
+ groups << ag.group.name
175
+ end
168
176
  info << "Groups: #{groups.uniq.sort.join(', ')}."
169
177
  nick.auth.password.nil? ? info << 'Password has not been set.' : info << 'Password has been set.'
170
178
  nick.auth.services ? info << 'Nickserv ident is enabled.' : info << 'Nickserv ident is disabled.'
@@ -173,7 +181,7 @@ class Authenticator < ModSpox::Plugin
173
181
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "I have no record of nick: #{params[:nick]}")
174
182
  end
175
183
  end
176
-
184
+
177
185
  def show_groups(message, params)
178
186
  groups = []
179
187
  message.source.auth_groups.each{|g| groups << g.name}
@@ -183,22 +191,22 @@ class Authenticator < ModSpox::Plugin
183
191
  reply message.replyto, "\2Groups (#{message.source.nick}):\2 #{groups.join(', ')}"
184
192
  end
185
193
  end
186
-
194
+
187
195
  # message:: ModSpox::Messages::Incoming::Privmsg
188
196
  # params:: Signature parameters
189
197
  # Add given nick to authentication group
190
198
  def set_nick(message, params)
191
199
  group = Models::Group.filter(:name => params[:group]).first
192
- nick = Models::Nick.find_or_create(:nick => params[:nick])
200
+ nick = Models::Nick.locate(params[:nick])
193
201
  if(group)
194
- nick.group = group
202
+ nick.auth.group = group
195
203
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Nick #{params[:nick]} has been added to the group: #{params[:group]}")
196
204
  else
197
205
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Failed to find authentication group: #{params[:group]}")
198
206
 
199
207
  end
200
208
  end
201
-
209
+
202
210
  # message:: ModSpox::Messages::Incoming::Privmsg
203
211
  # params:: Signature parameters
204
212
  # Remove given nick from authenticationg group
@@ -213,14 +221,15 @@ class Authenticator < ModSpox::Plugin
213
221
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Failed to find group: #{params[:group]}") unless group
214
222
  end
215
223
  end
216
-
224
+
217
225
  # message:: ModSpox::Messages::Incoming::Privmsg
218
226
  # params:: Signature parameters
219
227
  # Send WHOIS for nick
220
228
  def send_whois(message, params)
229
+ message.source.clear_auth
221
230
  @pipeline << Messages::Outgoing::Whois.new(message.source.nick)
222
231
  end
223
-
232
+
224
233
  # message:: ModSpox::Messages::Incoming::Privmsg
225
234
  # params:: Signature parameters
226
235
  # Display all available authentication groups
@@ -229,7 +238,7 @@ class Authenticator < ModSpox::Plugin
229
238
  Models::Group.all.each{|g| groups << g.name}
230
239
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "\2Groups:\2 #{groups.join(', ')}")
231
240
  end
232
-
241
+
233
242
  # message:: ModSpox::Messages::Incoming::Privmsg
234
243
  # params:: Signature parameters
235
244
  # Display info about given group
@@ -255,4 +264,28 @@ class Authenticator < ModSpox::Plugin
255
264
  end
256
265
  end
257
266
 
267
+ # Populates array with nicks that authenticate by nickserv
268
+ def populate_nickserv
269
+ Models::Auth.filter('services = ?', true).each do |auth|
270
+ @nickserv_nicks << auth.nick.nick.downcase
271
+ end
272
+ end
273
+
274
+ def check_nickserv(nick)
275
+ if(@nickserv_nicks.include?(nick.nick.downcase))
276
+ if(!nick.auth.authed && !@whois_cache.include?(nick.nick.downcase))
277
+ @pipeline << Messages::Outgoing::Whois.new(nick)
278
+ @whois_cache << nick.nick.downcase
279
+ end
280
+ end
281
+ end
282
+
283
+ def check_join(message)
284
+ check_nickserv(message.nick)
285
+ end
286
+
287
+ def check_nicks(message)
288
+ message.nicks.each{|nick| check_nickserv(nick) }
289
+ end
290
+
258
291
  end