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.
Files changed (145) hide show
  1. data/CHANGELOG +31 -1
  2. data/LICENSE +674 -0
  3. data/README.rdoc +73 -0
  4. data/bin/mod_spox +28 -28
  5. data/data/mod_spox/extras/AOLSpeak.rb +2 -3
  6. data/data/mod_spox/extras/AutoKick.rb +10 -23
  7. data/data/mod_spox/extras/AutoMode.rb +12 -23
  8. data/data/mod_spox/extras/Bash.rb +55 -0
  9. data/data/mod_spox/extras/Bouncer.rb +85 -57
  10. data/data/mod_spox/extras/Bullshit.rb +1 -1
  11. data/data/mod_spox/extras/Bytes.rb +1 -2
  12. data/data/mod_spox/extras/Confess.rb +27 -29
  13. data/data/mod_spox/extras/DCC.rb +11 -20
  14. data/data/mod_spox/extras/DevWatch.rb +21 -23
  15. data/data/mod_spox/extras/DownForEveryoneOrJustMe.rb +47 -0
  16. data/data/mod_spox/extras/EightBall.rb +1 -1
  17. data/data/mod_spox/extras/FML.rb +35 -0
  18. data/data/mod_spox/extras/Headers.rb +31 -50
  19. data/data/mod_spox/extras/Karma.rb +81 -29
  20. data/data/mod_spox/extras/Logger.rb +2 -2
  21. data/data/mod_spox/extras/LolSpeak.rb +1 -2
  22. data/data/mod_spox/extras/PhpCli.rb +138 -8
  23. data/data/mod_spox/extras/PhpFuncLookup.rb +20 -23
  24. data/data/mod_spox/extras/Pinger.rb +1 -1
  25. data/data/mod_spox/extras/Quotes.rb +8 -10
  26. data/data/mod_spox/extras/RegexTracker.rb +2 -4
  27. data/data/mod_spox/extras/Roulette.rb +20 -27
  28. data/data/mod_spox/extras/RubyCli.rb +93 -0
  29. data/data/mod_spox/extras/Search.rb +17 -3
  30. data/data/mod_spox/extras/Seen.rb +150 -0
  31. data/data/mod_spox/extras/SlashdotHeadlineGenerator.rb +500 -0
  32. data/data/mod_spox/extras/Talk.rb +2 -4
  33. data/data/mod_spox/extras/Topten.rb +10 -12
  34. data/data/mod_spox/extras/TracTicket.rb +3 -5
  35. data/data/mod_spox/extras/Translate.rb +20 -22
  36. data/data/mod_spox/extras/Twitter.rb +118 -33
  37. data/data/mod_spox/extras/UrbanDictionary.rb +8 -17
  38. data/data/mod_spox/extras/Weather.rb +1 -2
  39. data/data/mod_spox/plugins/Authenticator.rb +93 -98
  40. data/data/mod_spox/plugins/Banner.rb +26 -56
  41. data/data/mod_spox/plugins/Helper.rb +5 -6
  42. data/data/mod_spox/plugins/Initializer.rb +4 -14
  43. data/data/mod_spox/plugins/Joiner.rb +1 -1
  44. data/data/mod_spox/plugins/Nicker.rb +13 -0
  45. data/data/mod_spox/plugins/Parter.rb +2 -2
  46. data/data/mod_spox/plugins/Permissions.rb +60 -0
  47. data/data/mod_spox/plugins/PluginLoader.rb +7 -12
  48. data/data/mod_spox/plugins/Ponger.rb +51 -0
  49. data/data/mod_spox/plugins/Quitter.rb +1 -2
  50. data/data/mod_spox/plugins/Servers.rb +57 -0
  51. data/data/mod_spox/plugins/Status.rb +3 -2
  52. data/data/mod_spox/plugins/Triggers.rb +9 -9
  53. data/lib/mod_spox/Bot.rb +109 -33
  54. data/lib/mod_spox/BotConfig.rb +2 -2
  55. data/lib/mod_spox/ConfigurationWizard.rb +12 -12
  56. data/lib/mod_spox/Database.rb +1 -4
  57. data/lib/mod_spox/Exceptions.rb +26 -0
  58. data/lib/mod_spox/Helpers.rb +29 -68
  59. data/lib/mod_spox/Loader.rb +23 -24
  60. data/lib/mod_spox/Logger.rb +19 -17
  61. data/lib/mod_spox/MessageFactory.rb +50 -24
  62. data/lib/mod_spox/Pipeline.rb +21 -7
  63. data/lib/mod_spox/Plugin.rb +27 -3
  64. data/lib/mod_spox/PluginManager.rb +28 -15
  65. data/lib/mod_spox/PriorityQueue.rb +69 -0
  66. data/lib/mod_spox/Socket.rb +93 -51
  67. data/lib/mod_spox/Sockets.rb +76 -63
  68. data/lib/mod_spox/Timer.rb +21 -141
  69. data/lib/mod_spox/Version.rb +14 -0
  70. data/lib/mod_spox/handlers/BadNick.rb +1 -1
  71. data/lib/mod_spox/handlers/Bounce.rb +5 -5
  72. data/lib/mod_spox/handlers/Created.rb +13 -5
  73. data/lib/mod_spox/handlers/Handler.rb +12 -3
  74. data/lib/mod_spox/handlers/Invite.rb +14 -8
  75. data/lib/mod_spox/handlers/Join.rb +24 -20
  76. data/lib/mod_spox/handlers/Kick.rb +22 -13
  77. data/lib/mod_spox/handlers/Mode.rb +42 -36
  78. data/lib/mod_spox/handlers/Motd.rb +4 -0
  79. data/lib/mod_spox/handlers/Names.rb +66 -39
  80. data/lib/mod_spox/handlers/Nick.rb +20 -14
  81. data/lib/mod_spox/handlers/Part.rb +25 -8
  82. data/lib/mod_spox/handlers/Ping.rb +11 -5
  83. data/lib/mod_spox/handlers/Pong.rb +9 -5
  84. data/lib/mod_spox/handlers/Privmsg.rb +25 -17
  85. data/lib/mod_spox/handlers/Quit.rb +13 -8
  86. data/lib/mod_spox/handlers/Topic.rb +4 -0
  87. data/lib/mod_spox/handlers/Welcome.rb +16 -24
  88. data/lib/mod_spox/handlers/Who.rb +64 -48
  89. data/lib/mod_spox/handlers/Whois.rb +92 -60
  90. data/lib/mod_spox/messages/incoming/Nick.rb +2 -2
  91. data/lib/mod_spox/messages/incoming/Privmsg.rb +1 -1
  92. data/lib/mod_spox/messages/incoming/Whois.rb +1 -0
  93. data/lib/mod_spox/messages/internal/EstablishConnection.rb +1 -1
  94. data/lib/mod_spox/messages/internal/PluginsReady.rb +10 -0
  95. data/lib/mod_spox/messages/internal/QueueSocket.rb +8 -0
  96. data/lib/mod_spox/messages/internal/Reconnect.rb +8 -0
  97. data/lib/mod_spox/messages/internal/UnqueueSocket.rb +8 -0
  98. data/lib/mod_spox/migrations/002_persistent_sigs.rb +14 -0
  99. data/lib/mod_spox/migrations/003_auth_restructure.rb +31 -0
  100. data/lib/mod_spox/migrations/004_mode_index_fix.rb +18 -0
  101. data/lib/mod_spox/migrations/005_nick_mode_nopark.rb +18 -0
  102. data/lib/mod_spox/models/Auth.rb +16 -46
  103. data/lib/mod_spox/models/AuthMask.rb +13 -0
  104. data/lib/mod_spox/models/Channel.rb +46 -27
  105. data/lib/mod_spox/models/Config.rb +10 -19
  106. data/lib/mod_spox/models/Group.rb +20 -8
  107. data/lib/mod_spox/models/Models.rb +1 -1
  108. data/lib/mod_spox/models/Nick.rb +105 -113
  109. data/lib/mod_spox/models/NickMode.rb +23 -9
  110. data/lib/mod_spox/models/Server.rb +12 -1
  111. data/lib/mod_spox/models/Setting.rb +12 -16
  112. data/lib/mod_spox/models/Signature.rb +28 -8
  113. data/tests/BotHolder.rb +24 -0
  114. data/tests/handlers/tc_BadNick.rb +21 -0
  115. data/tests/handlers/tc_Created.rb +24 -0
  116. data/tests/handlers/tc_Invite.rb +50 -0
  117. data/tests/handlers/tc_Join.rb +33 -0
  118. data/tests/handlers/tc_Kick.rb +32 -0
  119. data/tests/handlers/tc_Mode.rb +85 -0
  120. data/tests/handlers/tc_Names.rb +35 -0
  121. data/tests/handlers/tc_Nick.rb +55 -0
  122. data/tests/handlers/tc_Part.rb +44 -0
  123. data/tests/handlers/tc_Ping.rb +40 -0
  124. data/tests/handlers/tc_Pong.rb +28 -0
  125. data/tests/handlers/tc_Privmsg.rb +85 -0
  126. data/tests/handlers/tc_Quit.rb +40 -0
  127. data/tests/handlers/tc_Who.rb +50 -0
  128. data/tests/handlers/tc_Whois.rb +61 -0
  129. data/tests/models/tc_Auth.rb +34 -0
  130. data/tests/models/tc_Channel.rb +52 -0
  131. data/tests/models/tc_Config.rb +19 -0
  132. data/tests/models/tc_Nick.rb +142 -0
  133. data/tests/models/tc_NickMode.rb +40 -0
  134. data/tests/models/tc_Setting.rb +21 -0
  135. data/tests/models/tc_Signature.rb +14 -0
  136. data/tests/run_tests.rb +4 -0
  137. metadata +284 -212
  138. data/README +0 -36
  139. data/lib/mod_spox/Cache.rb +0 -57
  140. data/lib/mod_spox/Monitors.rb +0 -84
  141. data/lib/mod_spox/Pool.rb +0 -164
  142. data/lib/mod_spox/models/AuthGroup.rb +0 -16
  143. data/lib/mod_spox/models/ChannelMode.rb +0 -14
  144. data/lib/mod_spox/models/NickChannel.rb +0 -45
  145. data/lib/mod_spox/models/NickGroup.rb +0 -16
@@ -6,6 +6,8 @@
6
6
  'mod_spox/Socket'
7
7
  ].each{|f| require f}
8
8
 
9
+ require 'spockets'
10
+
9
11
  module ModSpox
10
12
 
11
13
  class Sockets
@@ -17,28 +19,45 @@ module ModSpox
17
19
  @irc_socket = nil
18
20
  @dcc_sockets = []
19
21
  @mapped_sockets = {}
20
- @read_sockets = []
22
+ @spockets = Spockets::Spockets.new(:pool => bot.pool)
21
23
  @listening_dcc = []
22
24
  @dcc_ports = {:start => 49152, :end => 65535}
23
25
  @dcc_wait = 30
24
- @read_thread = nil
25
26
  @pipeline = bot.pipeline
26
27
  @factory = bot.factory
27
28
  @pipeline.hook(self, :check_dcc, :Incoming_Privmsg)
28
29
  @pipeline.hook(self, :return_socket, :Internal_DCCRequest)
29
30
  @pipeline.hook(self, :dcc_listener, :Internal_DCCListener)
30
- @kill = false
31
- @ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
31
+ @pipeline.hook(self, :disconnect_irc, :Internal_Disconnected)
32
+ @pipeline.hook(self, :queue_messages, :Internal_QueueSocket)
33
+ @pipeline.hook(self, :unqueue_messages, :Internal_UnqueueSocket)
34
+ @queues = {:irc => Queue.new, :dcc => Queue.new}
35
+ @queue_messages = false
32
36
  end
33
37
 
34
38
  # server:: IRC server string
35
39
  # port:: IRC port
36
40
  # Connect to the given IRC server
37
- def irc_connect(server, port)
38
- @irc_socket = Socket.new(@bot, server, port)
39
- @irc_socket.connect
40
- @read_sockets << @irc_socket.socket
41
- restart_reader
41
+ def irc_connect(server=nil, port=nil)
42
+ if(@irc_socket.nil?)
43
+ @irc_socket = Socket.new(@bot, server, port)
44
+ @irc_socket.connect
45
+ @spockets.add(@irc_socket.socket){|string| process_irc_string(string)}
46
+ @spockets.on_close(@irc_socket.socket){ irc_reconnect }
47
+ else
48
+ irc_reconnect
49
+ end
50
+ end
51
+
52
+ def irc_reconnect
53
+ unless(@irc_socket.nil?)
54
+ disconnect_irc
55
+ @spockets.remove(@irc_socket.socket) if @spockets.include?(@irc_socket)
56
+ @irc_socket.shutdown(true)
57
+ @spockets.add(@irc_socket.socket){|string| process_irc_string(string)}
58
+ else
59
+ irc_connect
60
+ end
42
61
  end
43
62
 
44
63
  def <<(message)
@@ -46,11 +65,14 @@ module ModSpox
46
65
  id = $1.to_i
47
66
  message = $2 + "\r\n"
48
67
  sock_info = @mapped_sockets[id]
49
- socket = sock_info[:socket]
68
+ sock_info[:socket] << message
50
69
  else
51
- socket = @irc_socket
70
+ @irc_socket << message
52
71
  end
53
- socket << message
72
+ end
73
+
74
+ def prioritize_message(target, message)
75
+ @irc_socket.prioritize_message(target, message)
54
76
  end
55
77
 
56
78
  # message:: ModSpox::Messages::Incoming::Privmsg
@@ -105,11 +127,9 @@ module ModSpox
105
127
  cport, cip = Object::Socket.unpack_sockaddr_in(addrinfo)
106
128
  end
107
129
  Logger.info("New DCC socket created for #{message.nick.nick} has connected from: #{cip}:#{cport}")
108
- stop_reader
109
130
  @dcc_sockets << client
110
131
  @mapped_sockets[client.object_id] = {:socket => client, :nick => message.nick}
111
- @read_sockets << client
112
- start_reader
132
+ @spockets.add(socket){|string| process_dcc_string(string, socket)}
113
133
  rescue Timeout::Error => boom
114
134
  Logger.warn("Timeout reached waiting for #{message.nick.nick} to connect to DCC socket. Closing.")
115
135
  client.close
@@ -124,13 +144,26 @@ module ModSpox
124
144
 
125
145
  # Shuts down all active sockets
126
146
  def shutdown
127
- stop_reader
147
+ @spockets.clear
128
148
  @irc_socket.shutdown
129
149
  @dcc_sockets.each do |sock|
130
150
  close_dcc(sock)
131
151
  end
132
152
  end
133
153
 
154
+ def disconnect_irc(m=nil)
155
+ @spockets.remove(@irc_socket.socket) if @spockets.include?(@irc_socket.socket)
156
+ end
157
+
158
+ def unqueue_messages(m)
159
+ @queue_messages = false
160
+ flush_queues
161
+ end
162
+
163
+ def queue_messages(m)
164
+ @queue_messages = true
165
+ end
166
+
134
167
  private
135
168
 
136
169
  # ip:: IP address to connect to
@@ -140,11 +173,9 @@ module ModSpox
140
173
  def build_connection(ip, port, nick)
141
174
  begin
142
175
  socket = TCPSocket.new(ip, port)
143
- stop_reader
144
- @read_sockets << socket
176
+ @spockets.add(socket){|string| process_dcc_string(string, socket)}
145
177
  @mapped_sockets[socket.object_id] = {:socket => socket, :nick => nick}
146
178
  @dcc_sockets << socket
147
- start_reader
148
179
  Logger.info("New DCC connection established to #{nick.nick} on #{ip}:#{port}")
149
180
  rescue Object => boom
150
181
  Logger.warn("DCC connection to #{nick.nick} on #{ip}:#{port} failed. #{boom}")
@@ -152,58 +183,40 @@ module ModSpox
152
183
  end
153
184
 
154
185
  def close_dcc(sock)
155
- @read_sockets.delete(sock)
186
+ @spockets.remove(sock)
156
187
  @dcc_sockets.delete(sock)
157
188
  @mapped_sockets.delete(sock.object_id)
158
189
  end
159
190
 
160
- def stop_reader
161
- Logger.info('Stopping reader thread for sockets')
162
- if(!@thread_read.nil? && @thread_read.alive?)
163
- @kill = true
164
- @thread_read.join(0.2)
165
- @thread_read.kill if @thread_read.alive?
166
- @kill = false
191
+ def process_irc_string(string)
192
+ if(@queue_messages)
193
+ @queues[:irc] << string
194
+ else
195
+ @irc_socket.process(string)
167
196
  end
168
- Logger.info('Reader thread for sockets has been stopped')
169
- end
170
-
171
- def restart_reader
172
- stop_reader
173
- start_reader
174
197
  end
175
-
176
-
177
- def start_reader
178
- Logger.info('Starting reader thread for sockets')
179
- if(!@thread_read.nil? && @thread_read.alive?)
180
- Logger.warn('ERROR: Cannot start reader. Already running.')
198
+
199
+ def process_dcc_string(string, socket)
200
+ if(@queue_messages)
201
+ @queues[:dcc] = {:string => string, :socket => socket}
181
202
  else
182
- @thread_read = Thread.new do
183
- until @kill do
184
- begin
185
- result = Kernel.select(@read_sockets, nil, nil, nil)
186
- for sock in result[0] do
187
- unless(sock == @irc_socket.socket)
188
- tainted_string = sock.gets
189
- string = @ic.iconv(tainted_string + ' ')[0..-2]
190
- Logger.info("DCC >> #{string}", false)
191
- if(sock.closed? || string.nil?)
192
- sock.close
193
- close_dcc(sock)
194
- else
195
- @pipeline << Messages::Incoming::Privmsg.new(string, @mapped_sockets[sock.object_id][:nick], "::#{sock.object_id}::", string)
196
- end
197
- else
198
- @irc_socket.read
199
- end
200
- end
201
- rescue Object => boom
202
- Logger.warn("Socket error detected: #{boom}\n#{boom.backtrace}", false)
203
- end
204
- end
203
+ Logger.info("DCC >> #{string}")
204
+ if(socket.closed? || string.nil?)
205
+ socket.close
206
+ close_dcc(socket)
207
+ else
208
+ @pipeline << Messages::Incoming::Privmsg.new(string, @mapped_sockets[socket.object_id][:nick], "::#{sock.object_id}::", string)
205
209
  end
206
- Logger.info('Reader thread for sockets has been started')
210
+ end
211
+ end
212
+
213
+ def flush_queues
214
+ until(@queues[:irc].empty?)
215
+ process_irc_string(@queues[:irc].pop)
216
+ end
217
+ until(@queues[:dcc].empty?)
218
+ con = @queues[:dcc].pop
219
+ process_dcc_string(con[:string], con[:socket])
207
220
  end
208
221
  end
209
222
 
@@ -1,23 +1,17 @@
1
1
  ['mod_spox/Logger',
2
- 'mod_spox/Pipeline',
3
- 'mod_spox/Pool',
4
- 'mod_spox/Action',
5
- 'mod_spox/Exceptions'].each{|f|require f}
2
+ 'mod_spox/Pipeline'].each{|f|require f}
6
3
 
7
4
  module ModSpox
8
5
 
9
6
  class Timer
10
7
 
11
- # pipeline:: message pipeline
12
- # Create a new Timer
13
- def initialize(pipeline)
8
+ # timer:: ActionTimer to use
9
+ # pipeline:: Message pipeline
10
+ # Creates a timer handler for interactions
11
+ # with the ActionTimer
12
+ def initialize(timer, pipeline)
14
13
  @pipeline = pipeline
15
- @timers = Array.new
16
- @timer_thread = nil
17
- @stop_timer = false
18
- @awake_lock = Mutex.new
19
- @add_lock = Mutex.new
20
- @new_actions = Queue.new
14
+ @timer = timer
21
15
  {:Internal_TimerAdd => :add_message,
22
16
  :Internal_TimerRemove => :remove_message,
23
17
  :Internal_TimerClear => :clear}.each_pair do |type,method|
@@ -25,153 +19,39 @@ module ModSpox
25
19
  end
26
20
  end
27
21
 
28
- # Wakes the timer up early
29
- def wakeup
30
- @awake_lock.synchronize do
31
- if(@timer_thread.status == 'sleep')
32
- Logger.info('Timer has been explicitly told to wakeup')
33
- @timer_thread.wakeup
34
- end
35
- end
36
- end
37
-
38
22
  # message:: TimerAdd message
39
23
  # Add a recurring code block
40
24
  def add_message(message)
41
25
  Logger.info("New block is being added to the timer")
42
- action = nil
43
- @new_actions << {:period => message.period, :once => message.once, :data => message.data,
44
- :block => message.block, :requester => message.requester, :m_id => message.id}
45
- wakeup
26
+ begin
27
+ action = @timer.add(message.period, message.once, message.data, message.requester, &message.block)
28
+ @pipeline << Messages::Internal::TimerResponse.new(message.requester, action, true, message.id)
29
+ rescue Object => boom
30
+ Logger.error("Failed to add new block to timer: #{boom}")
31
+ @pipeline << Messages::Internal::TimerResponse.new(message.requester, nil, false, message.id)
32
+ end
46
33
  end
47
34
 
48
35
  # message:: TimerRemove message
49
36
  # Remove an action from the timer
50
37
  def remove_message(message)
51
- remove(message.action)
38
+ @timer.remove(message.action)
52
39
  Logger.info("Action has been removed from the Timer")
53
40
  @pipeline << Messages::Internal::TimerResponse.new(nil, message.action, false, message.id)
54
41
  end
55
42
 
56
- # period:: seconds between running action
57
- # once:: only run action once
58
- # data:: data to be available
59
- # &func:: data block to run
60
- # Adds a new action to the timer
61
- def add(period, once=false, data=nil, &func)
62
- action = Action.new(self, period, data, once, &func)
63
- @timers << action
64
- return action
65
- end
66
-
67
- # action:: Action to add to timer's queue
68
- # Adds a new action to the timer
69
- def add_action(action)
70
- raise Exceptions::InvalidType.new('An Action object must be supplied') unless action.is_a?(Action)
71
- @timers << action
72
- wakeup
73
- end
74
-
75
- # action:: Action to remove from timer's queue
76
- # Removes and action from the timer
77
- def remove(action)
78
- raise Exceptions::InvalidType.new('An Action object must be supplied') unless action.is_a?(Action)
79
- @timers.delete(action)
80
- wakeup
81
- end
82
-
83
- # Starts the timer
84
- def start
85
- raise Exceptions::AlreadyRunning.new('Timer is already running') unless @timer_thread.nil?
86
- @timer_thread = Thread.new do
87
- begin
88
- until @stop_timer do
89
- to_sleep = get_min_sleep
90
- Logger.info("Timer is set to sleep for #{to_sleep.nil? ? 'forever' : "#{to_sleep} seconds"}")
91
- if((to_sleep.nil? || to_sleep > 0) && @new_actions.empty?)
92
- actual_sleep = to_sleep.nil? ? sleep : sleep(to_sleep)
93
- else
94
- actual_sleep = 0
95
- end
96
- Logger.info("Timer was set to sleep for #{to_sleep.nil? ? 'forever' : "#{to_sleep} seconds"}. Actual sleep: #{actual_sleep} seconds")
97
- tick(actual_sleep)
98
- add_waiting_actions
99
- end
100
- rescue Object => boom
101
- Logger.warn("Timer error encountered: #{boom}")
102
- end
103
- Logger.warn("Timer has completed running.")
104
- end
105
- end
106
-
107
- # Stops the timer
108
- def stop
109
- raise Exceptions::NotRunning.new('Timer is not running') if @timer_thread.nil?
110
- @stop_timer = true
111
- wakeup
112
- @timer_thread.join
113
- end
114
-
115
43
  # Clears all actions in the timer's queue
116
44
  def clear(message=nil)
117
45
  if(message.nil? || message.plugin.nil?)
118
- @timers.clear
119
- @new_actions.clear
120
- wakeup
46
+ @timer.clear
121
47
  else
122
- @timers.each{ |action| @timers.delete(action) if action.owner == message.plugin}
123
- wakeup
124
- end
125
- end
126
-
127
- private
128
-
129
- def get_min_sleep
130
- min = @timers.map{|t| t.remaining}.sort[0]
131
- unless(min.nil? || min > 0)
132
- @timers.each{|t| @timers.delete(t) if t.remaining == 0} # kill stuck actions
133
- min = get_min_sleep
134
- end
135
- Logger.info("Total number of actions in timer: #{@timers.size}")
136
- Logger.info("Actions belong to: #{@timers.map{|a| a.owner}.join(', ')}")
137
- return min
138
- end
139
-
140
- def add_waiting_actions
141
- until(@new_actions.empty?) do
142
- a = @new_actions.pop
143
- action = add(a[:period], a[:once], a[:data], &a[:block])
144
- action.owner = a[:requester]
145
- begin
146
- @pipeline << Messages::Internal::TimerResponse.new(a[:requester], action, true, a[:m_id])
147
- Logger.info("New block was successfully added to the timer")
148
- rescue Object => boom
149
- Logger.warn("Failed to add block to timer: #{boom}")
150
- @pipeline << Messages::Internal::TimerResponse.new(a[:requester], action, false, a[:m_id])
151
- end
48
+ @timer.clear(message.plugin)
152
49
  end
153
50
  end
154
-
155
- # time_passed:: time passed since last tick
156
- # Decrements all Actions the given amount of time
157
- def tick(time_passed)
158
- for action in @timers do
159
- action.tick(time_passed)
160
- if(action.due?)
161
- remove(action) if action.is_complete?
162
- block = action.schedule
163
- Pool << lambda{processor(block)}
164
- end
165
- end
166
- end
167
-
168
- # Process the actions
169
- def processor(action)
170
- begin
171
- action.run
172
- rescue Object => boom
173
- Logger.warn("Timer block generated an exception: #{boom}\n#{boom.backtrace.join("\n")}")
174
- end
51
+
52
+ # stop the timer
53
+ def stop
54
+ @timer.stop
175
55
  end
176
56
 
177
57
  end
@@ -0,0 +1,14 @@
1
+ module ModSpox
2
+ @botversion='0.3.0'
3
+ @botcodename='potato flamer'
4
+ @verbosity = 0
5
+ @mod_spox_path = nil
6
+ @daemon_bot = false
7
+ @logto = nil
8
+ @loglevel = :fatal
9
+ @jdbc = false
10
+ class << self
11
+ attr_reader :botversion, :botcodename
12
+ attr_accessor :verbosity, :mod_spox_path, :daemon_bot, :logto, :loglevel, :jdbc
13
+ end
14
+ end
@@ -6,7 +6,7 @@ module ModSpox
6
6
  handlers[ERR_ERRONEOUSNICKNAME] = self
7
7
  end
8
8
  def process(string)
9
- if(string =~ /#{RPL_ERRORNEOUSNICK}\s\S+\s(\S+)\s:/)
9
+ if(string =~ /#{ERR_ERRONEOUSNICKNAME}\s\S+\s(\S+)\s:/)
10
10
  return Messages::Incoming::BadNick.new(string, $1)
11
11
  else
12
12
  Logger.warn('Failed to process RPL_ERRORONEOUSNICK message')
@@ -7,11 +7,11 @@ module ModSpox
7
7
  end
8
8
 
9
9
  def process(string)
10
- if(string =~ /:Try server (\S+), port (.+)$/)
11
- return Messages::Incoming::Bounce.new(string, $1, $2)
12
- else
13
- return nil
14
- end
10
+ orig = string.dup
11
+ 2.times{string.slice!(0..string.index(' '))}
12
+ server = string.slice!(0..string.index(',')-1)
13
+ string.slice!(0..string.index(' ',4))
14
+ return Messages::Incoming::Bounce.new(orig, server, string)
15
15
  end
16
16
  end
17
17
  end