mod_spox 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGELOG +16 -0
  2. data/INSTALL +4 -1
  3. data/bin/mod_spox +3 -1
  4. data/data/mod_spox/extras/AOLSpeak.rb +2 -2
  5. data/data/mod_spox/extras/AutoKick.rb +3 -8
  6. data/data/mod_spox/extras/AutoMode.rb +135 -0
  7. data/data/mod_spox/extras/EightBall.rb +1 -0
  8. data/data/mod_spox/extras/Headers.rb +4 -3
  9. data/data/mod_spox/extras/PhpFuncLookup.rb +14 -11
  10. data/data/mod_spox/extras/Roulette.rb +3 -3
  11. data/data/mod_spox/extras/Search.rb +3 -2
  12. data/data/mod_spox/extras/Talk.rb +1 -9
  13. data/data/mod_spox/extras/Translate.rb +3 -3
  14. data/data/mod_spox/extras/UrbanDictionary.rb +5 -3
  15. data/data/mod_spox/extras/Weather.rb +5 -4
  16. data/data/mod_spox/plugins/Authenticator.rb +2 -2
  17. data/data/mod_spox/plugins/Banner.rb +207 -2
  18. data/data/mod_spox/plugins/Helper.rb +1 -1
  19. data/data/mod_spox/plugins/PluginLoader.rb +22 -6
  20. data/data/mod_spox/plugins/Triggers.rb +6 -4
  21. data/lib/mod_spox/Action.rb +2 -0
  22. data/lib/mod_spox/BaseConfig.rb +2 -0
  23. data/lib/mod_spox/Bot.rb +32 -6
  24. data/lib/mod_spox/BotConfig.rb +3 -0
  25. data/lib/mod_spox/Cache.rb +57 -0
  26. data/lib/mod_spox/ConfigurationWizard.rb +6 -2
  27. data/lib/mod_spox/Helpers.rb +36 -18
  28. data/lib/mod_spox/Loader.rb +5 -54
  29. data/lib/mod_spox/Logger.rb +49 -3
  30. data/lib/mod_spox/MessageFactory.rb +5 -0
  31. data/lib/mod_spox/Monitors.rb +14 -12
  32. data/lib/mod_spox/Pipeline.rb +38 -6
  33. data/lib/mod_spox/Plugin.rb +3 -0
  34. data/lib/mod_spox/PluginHolder.rb +22 -0
  35. data/lib/mod_spox/PluginManager.rb +123 -25
  36. data/lib/mod_spox/Pool.rb +52 -23
  37. data/lib/mod_spox/Socket.rb +21 -10
  38. data/lib/mod_spox/Timer.rb +32 -6
  39. data/lib/mod_spox/handlers/BadNick.rb +2 -0
  40. data/lib/mod_spox/handlers/Bounce.rb +3 -0
  41. data/lib/mod_spox/handlers/Created.rb +2 -0
  42. data/lib/mod_spox/handlers/Handler.rb +5 -0
  43. data/lib/mod_spox/handlers/Invite.rb +2 -0
  44. data/lib/mod_spox/handlers/Join.rb +21 -5
  45. data/lib/mod_spox/handlers/Kick.rb +2 -0
  46. data/lib/mod_spox/handlers/LuserChannels.rb +2 -0
  47. data/lib/mod_spox/handlers/LuserClient.rb +1 -0
  48. data/lib/mod_spox/handlers/LuserMe.rb +1 -0
  49. data/lib/mod_spox/handlers/LuserOp.rb +2 -0
  50. data/lib/mod_spox/handlers/LuserUnknown.rb +2 -0
  51. data/lib/mod_spox/handlers/Mode.rb +2 -0
  52. data/lib/mod_spox/handlers/Motd.rb +5 -2
  53. data/lib/mod_spox/handlers/MyInfo.rb +2 -0
  54. data/lib/mod_spox/handlers/Names.rb +5 -1
  55. data/lib/mod_spox/handlers/Nick.rb +2 -0
  56. data/lib/mod_spox/handlers/NickInUse.rb +2 -0
  57. data/lib/mod_spox/handlers/Notice.rb +16 -4
  58. data/lib/mod_spox/handlers/Part.rb +2 -0
  59. data/lib/mod_spox/handlers/Ping.rb +2 -0
  60. data/lib/mod_spox/handlers/Pong.rb +2 -0
  61. data/lib/mod_spox/handlers/Privmsg.rb +16 -4
  62. data/lib/mod_spox/handlers/Quit.rb +2 -0
  63. data/lib/mod_spox/handlers/Topic.rb +2 -0
  64. data/lib/mod_spox/handlers/Welcome.rb +3 -0
  65. data/lib/mod_spox/handlers/Who.rb +3 -1
  66. data/lib/mod_spox/handlers/Whois.rb +8 -0
  67. data/lib/mod_spox/handlers/YourHost.rb +2 -0
  68. data/lib/mod_spox/messages/Messages.rb +6 -0
  69. data/lib/mod_spox/messages/incoming/BadNick.rb +1 -0
  70. data/lib/mod_spox/messages/incoming/Bounce.rb +1 -0
  71. data/lib/mod_spox/messages/incoming/Created.rb +1 -0
  72. data/lib/mod_spox/messages/incoming/Invite.rb +1 -0
  73. data/lib/mod_spox/messages/incoming/Join.rb +1 -0
  74. data/lib/mod_spox/messages/incoming/Kick.rb +1 -0
  75. data/lib/mod_spox/messages/incoming/LuserChannels.rb +1 -0
  76. data/lib/mod_spox/messages/incoming/LuserClient.rb +1 -0
  77. data/lib/mod_spox/messages/incoming/LuserMe.rb +1 -0
  78. data/lib/mod_spox/messages/incoming/LuserOp.rb +1 -0
  79. data/lib/mod_spox/messages/incoming/LuserUnknown.rb +1 -0
  80. data/lib/mod_spox/messages/incoming/Mode.rb +1 -0
  81. data/lib/mod_spox/messages/incoming/Motd.rb +1 -0
  82. data/lib/mod_spox/messages/incoming/MyInfo.rb +1 -0
  83. data/lib/mod_spox/messages/incoming/Names.rb +1 -0
  84. data/lib/mod_spox/messages/incoming/Nick.rb +1 -0
  85. data/lib/mod_spox/messages/incoming/NickInUse.rb +1 -0
  86. data/lib/mod_spox/messages/incoming/Notice.rb +1 -0
  87. data/lib/mod_spox/messages/incoming/Part.rb +1 -0
  88. data/lib/mod_spox/messages/incoming/Ping.rb +1 -0
  89. data/lib/mod_spox/messages/incoming/Pong.rb +1 -0
  90. data/lib/mod_spox/messages/incoming/Privmsg.rb +1 -0
  91. data/lib/mod_spox/messages/incoming/Quit.rb +1 -0
  92. data/lib/mod_spox/messages/incoming/Topic.rb +1 -0
  93. data/lib/mod_spox/messages/incoming/TopicInfo.rb +1 -0
  94. data/lib/mod_spox/messages/incoming/Welcome.rb +1 -0
  95. data/lib/mod_spox/messages/incoming/Who.rb +1 -0
  96. data/lib/mod_spox/messages/incoming/Whois.rb +1 -0
  97. data/lib/mod_spox/messages/incoming/YourHost.rb +1 -0
  98. data/lib/mod_spox/messages/internal/NickRequest.rb +1 -0
  99. data/lib/mod_spox/messages/internal/NickResponse.rb +1 -0
  100. data/lib/mod_spox/messages/internal/PluginLoadRequest.rb +1 -0
  101. data/lib/mod_spox/messages/internal/PluginLoadResponse.rb +1 -0
  102. data/lib/mod_spox/messages/internal/PluginModuleRequest.rb +1 -0
  103. data/lib/mod_spox/messages/internal/PluginModuleResponse.rb +1 -0
  104. data/lib/mod_spox/messages/internal/PluginReload.rb +10 -0
  105. data/lib/mod_spox/messages/internal/PluginRequest.rb +1 -0
  106. data/lib/mod_spox/messages/internal/PluginResponse.rb +1 -0
  107. data/lib/mod_spox/messages/internal/PluginUnloadRequest.rb +1 -0
  108. data/lib/mod_spox/messages/internal/PluginUnloadResponse.rb +1 -0
  109. data/lib/mod_spox/messages/internal/StatusResponse.rb +1 -0
  110. data/lib/mod_spox/messages/internal/TimerAdd.rb +1 -0
  111. data/lib/mod_spox/messages/internal/TimerClear.rb +8 -0
  112. data/lib/mod_spox/messages/internal/TimerResponse.rb +1 -0
  113. data/lib/mod_spox/messages/outgoing/Away.rb +1 -0
  114. data/lib/mod_spox/messages/outgoing/Notice.rb +1 -0
  115. data/lib/mod_spox/messages/outgoing/Ping.rb +1 -0
  116. data/lib/mod_spox/messages/outgoing/Quit.rb +1 -0
  117. data/lib/mod_spox/messages/outgoing/Raw.rb +16 -0
  118. data/lib/mod_spox/models/Models.rb +4 -0
  119. data/lib/mod_spox/models/Nick.rb +9 -0
  120. data/lib/mod_spox/models/Setting.rb +3 -5
  121. data/lib/mod_spox/models/Signature.rb +2 -3
  122. metadata +8 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,19 @@
1
+ 0.0.5 Release (Alpha status)
2
+ * Added new RAW message type for outgoing messages
3
+ * Ability to load/unload/reload individual plugins
4
+ * Plugins that fail to load are completely removed
5
+ * memcache support
6
+ * PluginHolder introduced to reduce instances of stale plugins
7
+ * Faster signature matching
8
+ * Updated threading for better performance
9
+ * Removed Base64 dependency
10
+ * Ban exemptions available
11
+ * New AutoMode plugin
12
+ * Fixed connection monitoring
13
+ * Removed lazying loading of classes/modules
14
+ * Output bursting is now working properly
15
+ * Added multiline support in Privmsgs to allow ordered output
16
+
1
17
  0.0.4 Release (Alpha status)
2
18
  * Signatures now encoded when stored
3
19
  * SQLite lockup fixed on new version of sequel
data/INSTALL CHANGED
@@ -9,4 +9,7 @@ Requirements include:
9
9
 
10
10
  Optional:
11
11
  * fastthread
12
- * termios
12
+ * termios
13
+
14
+ More detailed information can be found at:
15
+ http://dev.modspox.com/cgi-bin/trac.cgi/wiki/InstallHowto
data/bin/mod_spox CHANGED
@@ -18,7 +18,7 @@ rescue Object => boom
18
18
  # ignore if not found #
19
19
  end
20
20
 
21
- $BOTVERSION='0.0.4'
21
+ $BOTVERSION='0.0.5'
22
22
  $VERBOSITY = 0
23
23
  $MOD_SPOX_PATH = nil
24
24
 
@@ -66,5 +66,7 @@ opts.each do |opt, arg|
66
66
  end
67
67
 
68
68
  initialize_bot
69
+ require 'mod_spox/Bot'
70
+
69
71
  bot = Bot.new
70
72
  bot.run
@@ -28,9 +28,9 @@ class AOLSpeak < ModSpox::Plugin
28
28
  else
29
29
  channel = message.target
30
30
  end
31
- nick = Models::Nick.filter(:nick => params[:nick]).first
31
+ nick = Helpers.find_model(params[:nick], false)
32
32
  if(channel && nick)
33
- @banner.ban(nick, channel, 60, @aolspeak[rand(@aolspeak.size) - 1], invite=false, show_time=false)
33
+ @banner.plugin.ban(nick, channel, 60, @aolspeak[rand(@aolspeak.size) - 1], invite=false, show_time=false)
34
34
  else
35
35
  reply message.replyto, "\2Error:\2 Failed to find channel: #{params[:channel]}" unless channel
36
36
  reply message.replyto, "\2Error:\2 Failed to find nick: #{params[:nick]}" unless nick
@@ -34,17 +34,12 @@ class AutoKick < ModSpox::Plugin
34
34
 
35
35
  def add(message, params)
36
36
  if(params[:channel])
37
- channel = Channel.filter(:name => params[:channel])
37
+ channel = Channel.filter(:name => params[:channel]).first
38
38
  else
39
39
  channel = message.target
40
40
  end
41
41
  if(channel)
42
- record = AutoKickRecord.new
43
- record.channel_id = channel.pk
44
- record.pattern = params[:regex]
45
- record.message = params[:message]
46
- record.bantime = params[:time]
47
- record.save
42
+ record = AutoKickRecord.find_or_create(:pattern => params[:regex], :message => params[:message], :bantime => params[:time].to_i, :channel_id => channel.pk)
48
43
  reply message.replyto, "New autokick rule has been created"
49
44
  do_listen
50
45
  else
@@ -69,7 +64,7 @@ class AutoKick < ModSpox::Plugin
69
64
  reg = Regexp.new(pattern)
70
65
  unless(reg.match(message.message).nil?)
71
66
  record = AutoKickRecord.filter(:pattern => pattern).first
72
- @banner.ban(message.source, message.target, record.bantime, record.message, invite=false, show_time=true)
67
+ @banner.plugin.ban(message.source, message.target, record.bantime, record.message, invite=false, show_time=true)
73
68
  end
74
69
  end
75
70
  end
@@ -0,0 +1,135 @@
1
+ class AutoMode < ModSpox::Plugin
2
+
3
+ include Models
4
+
5
+ def initialize(pipeline)
6
+ super
7
+ @admin = Group.find_or_create(:name => 'moder')
8
+ @user = Group.find_or_create(:name => 'modee')
9
+ Signature.find_or_create(:signature => 'addop (\S+)', :plugin => name, :method => 'addop', :group_id => @admin.pk,
10
+ :description => 'Add a nick to the auto op list', :requirement => 'public').params = [:nick]
11
+ Signature.find_or_create(:signature => 'addvoice (\S+)', :plugin => name, :method => 'addvoice', :group_id => @admin.pk,
12
+ :description => 'Add a nick to the auto voice list', :requirement => 'public').params = [:nick]
13
+ Signature.find_or_create(:signature => 'op', :plugin => name, :method => 'op', :group_id => @user.pk,
14
+ :description => 'Instruct bot to give you operator status', :requirement => 'public')
15
+ Signature.find_or_create(:signature => 'voice', :plugin => name, :method => 'voice', :group_id => @user.pk,
16
+ :description => 'Instruct bot to give you voice status', :requirement => 'public')
17
+ Signature.find_or_create(:signature => 'automode list (\S+)', :plugin => name, :method => 'list', :group_id => @admin.pk,
18
+ :description => 'Show list of current auto-modes for channel').params = [:channel]
19
+ Signature.find_or_create(:signature => 'delmode (\S+)', :plugin => name, :method => 'remove', :group_id => @admin.pk,
20
+ :description => 'Remove nick from any auto-modes in channel', :requirement => 'public').params = [:nick]
21
+ ModeRecord.create_table unless ModeRecord.table_exists?
22
+ @pipeline.hook(self, :check_join, :Incoming_Join)
23
+ end
24
+
25
+ def addop(m, p)
26
+ nick = Helpers.find_model(p[:nick], false)
27
+ if(nick.is_a?(Nick))
28
+ ModeRecord.find_or_create(:nick_id => nick.pk, :channel_id => m.target.pk, :voice => false)
29
+ add_modee(nick)
30
+ reply m.replyto, "#{nick.nick} has been added to the auto-op list"
31
+ else
32
+ reply m.replyto, "\2Error:\2 Failed to find record of: #{p[:nick]}"
33
+ end
34
+ end
35
+
36
+ def addvoice(m, p)
37
+ nick = Helpers.find_model(p[:nick], false)
38
+ if(nick.is_a?(Nick))
39
+ ModeRecord.find_or_create(:nick_id => nick.pk, :channel_id => m.target.pk, :voice => true)
40
+ add_modee(nick)
41
+ reply m.replyto, "#{nick.nick} has been added to the auto-voice list"
42
+ else
43
+ reply m.replyto, "\2Error:\2 Failed to find record of: #{p[:nick]}"
44
+ end
45
+ end
46
+
47
+ def op(m, p)
48
+ record = ModeRecord.filter(:nick_id => m.source.pk, :channel_id => m.target.pk).first
49
+ if(record && !record.voice)
50
+ @pipeline << Messages::Outgoing::ChannelMode.new(m.target, '+o', m.source.nick) if me.is_op?(m.target)
51
+ else
52
+ reply m.replyto, "\2Error:\2 You are not listed on the auto-op list"
53
+ end
54
+ end
55
+
56
+ def voice(m, p)
57
+ record = ModeRecord.filter(:nick_id => m.source.pk, :channel_id => m.target.pk).first
58
+ if(record && record.voice)
59
+ @pipeline << Messages::Outgoing::ChannelMode.new(m.target, '+v', m.source.nick) if me.is_op?(m.target)
60
+ else
61
+ reply m.replyto, "\2Error:\2 You are not listed on the auto-voice list"
62
+ end
63
+ end
64
+
65
+ def list(m, p)
66
+ channel = Helpers.find_model(p[:channel], false)
67
+ if(channel.is_a?(Channel))
68
+ records = ModeRecord.filter(:channel_id => channel.pk)
69
+ if(records.size > 0)
70
+ reply m.replyto, "\2Auto-Mode Listing:\2"
71
+ sleep(0.01)
72
+ records.each do |record|
73
+ reply m.replyto, "#{record.nick.nick} \2->\2 #{record.voice == false ? "op" : "voice"}"
74
+ end
75
+ else
76
+ reply m.replyto, "\2Warning:\2 No users found in auto-mode list"
77
+ end
78
+ else
79
+ reply m.replyto, "\2Error:\2 Failed to find channel: #{p[:channel]}"
80
+ end
81
+ end
82
+
83
+ def remove(m, p)
84
+ nick = Helpers.find_model(p[:nick], false)
85
+ if(nick.is_a?(Nick))
86
+ ModeRecord.filter(:channel_id => m.target.pk, :nick_id => nick.pk).destroy
87
+ remove_modee(nick)
88
+ reply m.replyto, "All auto-modes for user: #{p[:nick]} have been removed"
89
+ else
90
+ reply m.replyto, "\2Error:\2 Failed to find nick: #{p[:nick]}"
91
+ end
92
+ end
93
+
94
+ def check_join(m)
95
+ return unless me.is_op?(m.channel)
96
+ matches = ModeRecord.filter(:nick_id => m.nick.pk, :channel_id => m.channel.pk)
97
+ if(matches.size > 0)
98
+ matches.each do |record|
99
+ mode = record.voice ? '+v' : '+o'
100
+ @pipeline << Messages::Outgoing::ChannelMode.new(m.channel, mode, m.nick.nick)
101
+ end
102
+ end
103
+ end
104
+
105
+ def add_modee(nick)
106
+ modee = Group.find_or_create(:name => 'modee')
107
+ nick.group = modee
108
+ end
109
+
110
+ def remove_modee(nick)
111
+ modee = Group.find_or_create(:name => 'modee')
112
+ if(ModeRecord.filter(:nick_id => nick.pk).size < 1)
113
+ nick.remove_group(modee)
114
+ end
115
+ end
116
+
117
+ class ModeRecord < Sequel::Model
118
+ set_schema do
119
+ primary_key :id
120
+ boolean :voice, :null => false, :default => true
121
+ foreign_key :nick_id, :table => :nicks, :null => false
122
+ foreign_key :channel_id, :table => :channels, :null => false
123
+ index [:nick_id, :channel_id, :voice], :unique => true
124
+ end
125
+
126
+ def channel
127
+ ModSpox::Models::Channel[channel_id]
128
+ end
129
+
130
+ def nick
131
+ ModSpox::Models::Nick[nick_id]
132
+ end
133
+ end
134
+
135
+ end
@@ -25,6 +25,7 @@ class EightBall < ModSpox::Plugin
25
25
 
26
26
  def eightball(message, params)
27
27
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, 'shakes magic 8 ball...', true)
28
+ sleep(1)
28
29
  reply message.replyto, "#{message.source.nick}: #{@responses[rand(@responses.size) - 1]}"
29
30
  end
30
31
 
@@ -36,11 +36,12 @@ class Headers < ModSpox::Plugin
36
36
  con = Net::HTTP.new(location, port)
37
37
  con.use_ssl = secure
38
38
  response = con.get(page, nil)
39
- reply message.replyto, "Response code: #{response.code}"
39
+ output = ["Response code: #{response.code}"]
40
40
  response.each{|key,val|
41
- reply message.replyto, "#{key}: #{val}"
41
+ output << "#{key}: #{val}"
42
42
  }
43
- reply message.replyto, "Header listing complete"
43
+ output << "Header listing complete"
44
+ reply message.replyto, output
44
45
  rescue Object => boom
45
46
  reply message.replyto, "Error retrieving headers: #{boom}"
46
47
  end
@@ -190,11 +190,12 @@ class PhpFuncLookup < ModSpox::Plugin
190
190
  desc.gsub!(/[\r\n]/, ' ')
191
191
  desc.gsub!(/<.+?>/, ' ')
192
192
  desc = CGI::unescapeHTML(desc.gsub(/\s+/, ' '))
193
- reply m.replyto, "\2PHP Superglobal\2"
194
- reply m.replyto, "\2#{name}:\2 #{desc}"
193
+ output = ["\2PHP Superglobal\2"]
194
+ output << "\2#{name}:\2 #{desc}"
195
195
  else
196
- reply m.replyto, "No superglobal found matching: #{name}"
196
+ output = "No superglobal found matching: #{name}"
197
197
  end
198
+ reply m.replyto, output
198
199
  end
199
200
 
200
201
  def parse_wildcard(m, name)
@@ -218,8 +219,9 @@ class PhpFuncLookup < ModSpox::Plugin
218
219
  end
219
220
  end
220
221
  matches.sort!
221
- reply m.replyto, "Lots of matching functions. Truncating list to 20 results."
222
- reply m.replyto, matches.values_at(0..19).join(', ')
222
+ output = ["Lots of matching functions. Truncating list to 20 results."]
223
+ output << matches.values_at(0..19).join(', ')
224
+ reply m.replyto, output
223
225
  end
224
226
 
225
227
  def parse_function(m, name, filename)
@@ -231,19 +233,20 @@ class PhpFuncLookup < ModSpox::Plugin
231
233
  versions = CGI::unescapeHTML(versions)
232
234
  proto = CGI::unescapeHTML(proto.gsub(/<.+?>/, ' ').gsub(/[\s]+/, ' '))
233
235
  desc = CGI::unescapeHTML(desc.gsub(/<.+?>/, ' ').gsub(/[\s]+/, ' '))
234
- reply m.replyto, versions
235
- reply m.replyto, "\2#{proto}\2"
236
- reply m.replyto, desc
237
- reply m.replyto, "http://www.php.net/manual/en/#{filename.gsub(/\.html$/, '.php')}"
236
+ output = [versions]
237
+ output << "\2#{proto}\2"
238
+ output << desc
239
+ output << "http://www.php.net/manual/en/#{filename.gsub(/\.html$/, '.php')}"
240
+ reply m.replyto, output
238
241
  end
239
242
 
240
243
  def parse_operator(m, name)
241
244
  Logger.log "parse_operator name=#{name}"
242
245
  name.downcase!
243
246
  type, title, ejemplo = @ops[name]
244
- reply m.replyto, "\2#{name}\2 is the \2#{title.to_a.join("\2 or \2")}\2 operator"
247
+ output = ["\2#{name}\2 is the \2#{title.to_a.join("\2 or \2")}\2 operator"]
245
248
  type.to_a.each do |t|
246
- reply m.replyto, "http://php.net/manual/en/language.operators.#{t}.php"
249
+ output << "http://php.net/manual/en/language.operators.#{t}.php"
247
250
  end
248
251
  end
249
252
 
@@ -61,7 +61,7 @@ class Roulette < ModSpox::Plugin
61
61
  def shoot(message, params)
62
62
  return unless message.is_public?
63
63
  cur_game = game(message.target)
64
- nick = Nick.filter(:nick => params[:nick])
64
+ nick = Helpers.find_model(params[:nick], false)
65
65
  if(cur_game.shots == 1 && nick && Info.filter(:game_id => cur_game.pk, :nick_id => nick.pk))
66
66
  do_shot(nick, message.target)
67
67
  else
@@ -96,7 +96,7 @@ class Roulette < ModSpox::Plugin
96
96
  def stats(message, params)
97
97
  return unless message.is_public?
98
98
  if(params[:nick])
99
- nick = Nick.filter(:nick => params[:nick]).first
99
+ nick = Helpers.find_model(params[:nick], false)
100
100
  unless(nick)
101
101
  reply(message.replyto, "\2Error:\2 Failed to find record of #{params[:nick]}")
102
102
  return
@@ -183,7 +183,7 @@ class Roulette < ModSpox::Plugin
183
183
  def kill_nick(nick, channel)
184
184
  unless(@banner.nil?)
185
185
  begin
186
- @banner.ban(nick, channel, 30, '*BANG*', true, false)
186
+ @banner.plugin.ban(nick, channel, 30, '*BANG*', true, false)
187
187
  rescue Banner::NotOperator => boom
188
188
  reply(channel, "#{nick.nick}: *BANG*")
189
189
  rescue Object => boom
@@ -22,10 +22,11 @@ class Search < ModSpox::Plugin
22
22
  title = CGI::unescapeHTML(title)
23
23
  results.push [title, url]
24
24
  end
25
- @pipeline << Privmsg.new(message.replyto, "Search results for \2#{params[:terms]}:\2")
25
+ output = ["Search results for \2#{params[:terms]}:\2"]
26
26
  results.slice(0, limit).each do |title, url|
27
- @pipeline << Privmsg.new(message.replyto, "#{title} -> #{Helpers.tinyurl(url)} [#{url.scan(/^http:\/\/.+?\//)[0]}]")
27
+ output << "#{title} -> #{Helpers.tinyurl(url)} [#{url.scan(/^http:\/\/.+?\//)[0]}]"
28
28
  end
29
+ reply message.replyto, output
29
30
  rescue Object => boom
30
31
  @pipeline << Privmsg.new(message.replyto, "Failed to find any results for: #{params[:terms]} Reason: #{boom}")
31
32
  end
@@ -22,20 +22,12 @@ class Talk < ModSpox::Plugin
22
22
  private
23
23
 
24
24
  def send_p(message, params, action=false)
25
- target = find_target(params[:target])
25
+ target = Helpers.find_model(params[:target], false)
26
26
  if(target.nil?)
27
27
  reply message.replyto, "\2Error:\2 Failed to locate target: #{params[:target]}"
28
28
  else
29
29
  @pipeline << Messages::Outgoing::Privmsg.new(target, params[:text], action)
30
30
  end
31
31
  end
32
-
33
- def find_target(string)
34
- result = Channel.filter(:name => string).first
35
- return result if result
36
- result = Nick.filter(:nick => string).first
37
- return result if result
38
- return nil
39
- end
40
32
 
41
33
  end
@@ -16,7 +16,7 @@ class Translate < ModSpox::Plugin
16
16
 
17
17
  def auto_add(message, params)
18
18
  return unless message.is_public?
19
- nick = Nick.filter(:nick => params[:nick]).first
19
+ nick = Helpers.find_model(params[:nick], false)
20
20
  if(nick && nick.channels.include?(message.target))
21
21
  @watchers[message.target.pk] = {} unless @watchers.has_key?(message.target.pk)
22
22
  @watchers[message.target.pk][nick.pk] = params[:lang] unless @watchers[message.target.pk].has_key?(nick.pk)
@@ -29,7 +29,7 @@ class Translate < ModSpox::Plugin
29
29
 
30
30
  def auto_remove(message, params)
31
31
  return unless message.is_public?
32
- nick = Nick.filter(:nick => params[:nick]).first
32
+ nick = Helpers.find_model(params[:nick], false)
33
33
  if(nick)
34
34
  if(@watchers.has_key?(message.target.pk))
35
35
  @watchers[message.target.pk].delete(nick.pk) if @watchers[message.target.pk].has_key?(nick.pk)
@@ -54,7 +54,7 @@ class Translate < ModSpox::Plugin
54
54
  reply message.replyto, "\2Translation (#{message.source.nick}):\2 #{do_translation("#{@watchers[message.target.pk][message.source.pk]}en", message.message)}"
55
55
  elsif(message.message =~ /^(\S+)[:,]/)
56
56
  Logger.log("Matched a nick: #{$1}")
57
- nick = Nick.filter(:nick => $1).first
57
+ nick = Helpers.find_model($1, false)
58
58
  return unless nick
59
59
  if(@watchers[message.target.pk].has_key?(nick.pk))
60
60
  reply message.replyto, "\2(#{do_translation("en|#{@watchers[message.target.pk][nick.pk]}", 'translation')})\2 #{do_translation("en|#{@watchers[message.target.pk][nick.pk]}", message.message)}"
@@ -22,14 +22,16 @@ class UrbanDictionary < ModSpox::Plugin
22
22
  udict = SOAP::RPC::Driver.new(site, 'urn:UrbanSearch')
23
23
  udict.add_method('lookup', 'key', 'term')
24
24
  defs = udict.lookup(key, params[:term])
25
+ output = []
25
26
  if defs.size < result + 1
26
27
  @pipeline << Privmsg.new(message.replyto, "Error: Definition number #{result+1} for term: #{params[:term]} not found.")
27
28
  else
28
29
  defin = defs[result].definition.length > 500 ? defs[result].definition.slice(0..500) + " *[CUT]*" : defs[result].definition
29
30
  exp = defs[result].example.length > 500 ? defs[result].example.slice(0..500) + " *[CUT]*" : defs[result].example
30
- @pipeline << Privmsg.new(message.replyto, "Definition for \2#{defs[result].word}:\2")
31
- @pipeline << Privmsg.new(message.replyto, defin)
32
- @pipeline << Privmsg.new(message.replyto, "\2Example usage:\2 #{exp}") if exp.length > 0
31
+ output << ["Definition for \2#{defs[result].word}:\2"]
32
+ output << defin
33
+ output << "\2Example usage:\2 #{exp}" if exp.length > 0
34
+ reply message.replyto, output
33
35
  end
34
36
  rescue Timeout::Error
35
37
  @pipeline << Privmsg.new(message.replyto, "Failed to establish connection to server.")
@@ -40,10 +40,11 @@ class Weather < ModSpox::Plugin
40
40
  end
41
41
  i += 1
42
42
  end
43
- reply message.replyto, "Weather for: \2#{location}\2"
44
- reply message.replyto, "Current Temp: #{curtemp} - Feels like: #{feeltemp}"
45
- reply message.replyto, "[UV Index: #{uv.gsub(/&.+?;/, '')}][Wind: #{wind.gsub(/&.+?;/, '')}][Humiditiy: #{humid.gsub(/&.+?;/, '')}][Pressure: #{pressure.gsub(/&.+?;/, '')}][Dew Point: #{dewpoint.gsub(/&.+?;/, '')}][Visibility: #{visibility.gsub(/&.+?;/, '')}]"
46
- reply message.replyto, future.values_at(0..2).join(' ')
43
+ output = ["Weather for: \2#{location}\2"]
44
+ output << "Current Temp: #{curtemp} - Feels like: #{feeltemp}"
45
+ output << "[UV Index: #{uv.gsub(/&.+?;/, '')}][Wind: #{wind.gsub(/&.+?;/, '')}][Humiditiy: #{humid.gsub(/&.+?;/, '')}][Pressure: #{pressure.gsub(/&.+?;/, '')}][Dew Point: #{dewpoint.gsub(/&.+?;/, '')}][Visibility: #{visibility.gsub(/&.+?;/, '')}]"
46
+ output << future.values_at(0..2).join(' ')
47
+ reply message.replyto, output
47
48
  else
48
49
  reply message.replyto, "Failed to retrieve weather data."
49
50
  end
@@ -159,7 +159,7 @@ class Authenticator < ModSpox::Plugin
159
159
  # params:: Signature parameters
160
160
  # Display info for given nick
161
161
  def nick_info(message, params)
162
- nick = Models::Nick.filter(:nick => params[:nick]).first
162
+ nick = Helpers.find_model(params[:nick], false)
163
163
  if(nick)
164
164
  info = []
165
165
  info << "\2INFO [#{nick.nick}]:\2"
@@ -204,7 +204,7 @@ class Authenticator < ModSpox::Plugin
204
204
  # Remove given nick from authenticationg group
205
205
  def unset_nick(message, params)
206
206
  group = Models::Group.filter(:name => params[:group]).first
207
- nick = Models::Nick.filter(:nick => params[:nick]).first
207
+ nick = Helpers.find_model(params[:nick], false)
208
208
  if(group && nick)
209
209
  nick.remove_group(group)
210
210
  @pipeline << Messages::Outgoing::Privmsg.new(message.replyto, "Removed #{params[:nick]} from the #{params[:group]} authentication group.")