rumpy 0.9.19 → 0.9.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rumpy.rb +19 -19
- metadata +4 -4
data/lib/rumpy.rb
CHANGED
|
@@ -48,7 +48,7 @@ module Rumpy
|
|
|
48
48
|
# Determine the name of file where thid pid will stored to
|
|
49
49
|
def self.pid_file(bot)
|
|
50
50
|
pid_file = bot.pid_file
|
|
51
|
-
pid_file = bot.class.to_s.downcase + '.pid'
|
|
51
|
+
pid_file = bot.class.to_s.downcase + '.pid' unless pid_file
|
|
52
52
|
pid_file
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -86,15 +86,15 @@ module Rumpy
|
|
|
86
86
|
add_signal_trap
|
|
87
87
|
|
|
88
88
|
Thread.stop
|
|
89
|
-
rescue =>
|
|
90
|
-
general_error
|
|
89
|
+
rescue => ex
|
|
90
|
+
general_error ex
|
|
91
91
|
exit
|
|
92
92
|
end # def start
|
|
93
93
|
|
|
94
94
|
private
|
|
95
95
|
|
|
96
96
|
def logger_init
|
|
97
|
-
|
|
97
|
+
unless @logger
|
|
98
98
|
@log_file ||= STDERR
|
|
99
99
|
@log_level ||= Logger::INFO
|
|
100
100
|
@logger = Logger.new @log_file, @log_shift_age, @log_shift_size
|
|
@@ -124,7 +124,7 @@ module Rumpy
|
|
|
124
124
|
@client = Jabber::Client.new @jid
|
|
125
125
|
Jabber::Version::SimpleResponder.new(@client, @bot_name || self.class.to_s, @bot_version || '1.0.0', RUBY_PLATFORM)
|
|
126
126
|
|
|
127
|
-
if @models_files
|
|
127
|
+
if @models_files
|
|
128
128
|
dbconfig = YAML::load_file @config_path + '/database.yml'
|
|
129
129
|
@logger.info 'loaded database.yml'
|
|
130
130
|
@logger.debug "database.yml: #{dbconfig.inspect}"
|
|
@@ -160,9 +160,9 @@ module Rumpy
|
|
|
160
160
|
def set_iq_callback
|
|
161
161
|
@client.add_iq_callback do |iq|
|
|
162
162
|
@logger.debug "got iq #{iq}"
|
|
163
|
-
if iq.type == :get
|
|
163
|
+
if iq.type == :get # hack for pidgin (STOP USING IT)
|
|
164
164
|
response = iq.answer true
|
|
165
|
-
if iq.elements['time'] == "<time xmlns='urn:xmpp:time'/>"
|
|
165
|
+
if iq.elements['time'] == "<time xmlns='urn:xmpp:time'/>"
|
|
166
166
|
@logger.debug 'this is time request, okay'
|
|
167
167
|
response.set_type :result
|
|
168
168
|
tm = Time.now
|
|
@@ -209,16 +209,16 @@ module Rumpy
|
|
|
209
209
|
rescue ActiveRecord::ConnectionTimeoutError
|
|
210
210
|
connection_timeout_error
|
|
211
211
|
retry
|
|
212
|
-
rescue =>
|
|
213
|
-
general_error
|
|
212
|
+
rescue => ex
|
|
213
|
+
general_error ex
|
|
214
214
|
end
|
|
215
215
|
end
|
|
216
216
|
end # def set_subscription_callback
|
|
217
217
|
|
|
218
218
|
def set_message_callback
|
|
219
219
|
@client.add_message_callback do |msg|
|
|
220
|
-
if msg.type != :error
|
|
221
|
-
if @roster[msg.from]
|
|
220
|
+
if msg.type != :error && msg.body && msg.from
|
|
221
|
+
if @roster[msg.from] && @roster[msg.from].subscription == :both
|
|
222
222
|
@logger.debug "got normal message #{msg}"
|
|
223
223
|
|
|
224
224
|
@queues[msg.from.strip.to_s].enq msg
|
|
@@ -237,7 +237,7 @@ module Rumpy
|
|
|
237
237
|
loop do
|
|
238
238
|
backend_func().each do |result|
|
|
239
239
|
message = Jabber::Message.new(*result).set_type :chat
|
|
240
|
-
@output_queue.enq message if message.body
|
|
240
|
+
@output_queue.enq message if message.body && message.to
|
|
241
241
|
end
|
|
242
242
|
end
|
|
243
243
|
rescue ActiveRecord::StatementInvalid
|
|
@@ -246,8 +246,8 @@ module Rumpy
|
|
|
246
246
|
rescue ActiveRecord::ConnectionTimeoutError
|
|
247
247
|
connection_timeout_error
|
|
248
248
|
retry
|
|
249
|
-
rescue =>
|
|
250
|
-
general_error
|
|
249
|
+
rescue => ex
|
|
250
|
+
general_error ex
|
|
251
251
|
end # begin
|
|
252
252
|
end if self.respond_to? :backend_func
|
|
253
253
|
end # def start_backend_thread
|
|
@@ -256,7 +256,7 @@ module Rumpy
|
|
|
256
256
|
Thread.new do
|
|
257
257
|
@logger.info "Output queue initialized"
|
|
258
258
|
until (msg = @output_queue.deq) == :halt do
|
|
259
|
-
if msg.nil?
|
|
259
|
+
if msg.nil?
|
|
260
260
|
@logger.debug "got nil message. wtf?"
|
|
261
261
|
else
|
|
262
262
|
@logger.debug "sending message #{msg}"
|
|
@@ -293,14 +293,14 @@ module Rumpy
|
|
|
293
293
|
|
|
294
294
|
@roster.items.each do |jid, item|
|
|
295
295
|
user = @main_model.find_by_jid jid.strip.to_s
|
|
296
|
-
if user.nil?
|
|
296
|
+
if user.nil? || item.subscription != :both
|
|
297
297
|
@logger.info "deleting from roster user with jid #{jid}"
|
|
298
298
|
item.remove
|
|
299
299
|
end
|
|
300
300
|
end
|
|
301
301
|
@main_model.find_each do |user|
|
|
302
302
|
items = @roster.find user.jid
|
|
303
|
-
if items.empty?
|
|
303
|
+
if items.empty?
|
|
304
304
|
@logger.info "deleting from database user with jid #{user.jid}"
|
|
305
305
|
user.destroy
|
|
306
306
|
else
|
|
@@ -327,8 +327,8 @@ module Rumpy
|
|
|
327
327
|
rescue ActiveRecord::ConnectionTimeoutError
|
|
328
328
|
connection_timeout_error
|
|
329
329
|
retry
|
|
330
|
-
rescue =>
|
|
331
|
-
general_error
|
|
330
|
+
rescue => ex
|
|
331
|
+
general_error ex
|
|
332
332
|
end # begin
|
|
333
333
|
|
|
334
334
|
@main_model.connection_pool.release_connection
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rumpy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 17
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
9
|
+
- 21
|
|
10
|
+
version: 0.9.21
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Tsokurov A.G.
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2011-
|
|
19
|
+
date: 2011-09-19 00:00:00 +03:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|