cinch 2.0.4 → 2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cinch/irc.rb +2 -2
- data/lib/cinch/version.rb +1 -1
- metadata +2 -3
- data/lib/cinch/#syncable.rb# +0 -83
data/lib/cinch/irc.rb
CHANGED
@@ -362,11 +362,11 @@ module Cinch
|
|
362
362
|
def on_away(msg, events)
|
363
363
|
if msg.message.to_s.empty?
|
364
364
|
# unaway
|
365
|
-
|
365
|
+
msg.user.sync(:away, nil, true)
|
366
366
|
events << [:unaway]
|
367
367
|
else
|
368
368
|
# away
|
369
|
-
|
369
|
+
msg.user.sync(:away, msg.message, true)
|
370
370
|
events << [:away]
|
371
371
|
end
|
372
372
|
end
|
data/lib/cinch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple, friendly DSL for creating IRC bots
|
15
15
|
email:
|
@@ -47,7 +47,6 @@ files:
|
|
47
47
|
- lib/cinch/isupport.rb
|
48
48
|
- lib/cinch/helpers.rb
|
49
49
|
- lib/cinch/handler.rb
|
50
|
-
- lib/cinch/#syncable.rb#
|
51
50
|
- lib/cinch/handler_list.rb
|
52
51
|
- lib/cinch/rubyext/module.rb
|
53
52
|
- lib/cinch/rubyext/float.rb
|
data/lib/cinch/#syncable.rb#
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
module Cinch
|
2
|
-
# Provide blocking access to user/channel information.
|
3
|
-
module Syncable
|
4
|
-
# Blocks until the object is synced.
|
5
|
-
#
|
6
|
-
# @return [void]
|
7
|
-
# @api private
|
8
|
-
def wait_until_synced(attr)
|
9
|
-
attr = attr.to_sym
|
10
|
-
waited = 0
|
11
|
-
while true
|
12
|
-
return if attribute_synced?(attr)
|
13
|
-
waited += 1
|
14
|
-
|
15
|
-
if waited % 100 == 0
|
16
|
-
bot.loggers.warn "A synced attribute ('%s' for %s) has not been available for %d seconds, still waiting" % [attr, self.inspect, waited / 10]
|
17
|
-
bot.loggers.warn caller.map {|s| " #{s}"}
|
18
|
-
|
19
|
-
if waited / 10 >= 30
|
20
|
-
bot.loggers.warn " Giving up..."
|
21
|
-
raise Exceptions::SyncedAttributeNotAvailable, "'%s' for %s" % [attr, self.inspect]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
sleep 0.1
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# @api private
|
29
|
-
# @return [void]
|
30
|
-
def sync(attribute, value, data = false)
|
31
|
-
if data
|
32
|
-
@data[attribute] = value
|
33
|
-
else
|
34
|
-
instance_variable_set("@#{attribute}", value)
|
35
|
-
end
|
36
|
-
@synced_attributes << attribute
|
37
|
-
end
|
38
|
-
|
39
|
-
# @return [Boolean]
|
40
|
-
# @api private
|
41
|
-
def attribute_synced?(attribute)
|
42
|
-
@synced_attributes.include?(attribute)
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [void]
|
46
|
-
# @api private
|
47
|
-
def unsync(attribute)
|
48
|
-
@synced_attributes.delete(attribute)
|
49
|
-
end
|
50
|
-
|
51
|
-
# @return [void]
|
52
|
-
# @api private
|
53
|
-
# @since 1.0.1
|
54
|
-
def unsync_all
|
55
|
-
@synced_attributes.clear
|
56
|
-
end
|
57
|
-
|
58
|
-
# @param [Symbol] attribute
|
59
|
-
# @param [Boolean] data
|
60
|
-
# @param [Boolean] unsync
|
61
|
-
# @api private
|
62
|
-
def attr(attribute, data = false, unsync = false)
|
63
|
-
unless unsync
|
64
|
-
if @when_requesting_synced_attribute
|
65
|
-
@when_requesting_synced_attribute.call(attribute)
|
66
|
-
end
|
67
|
-
wait_until_synced(attribute)
|
68
|
-
end
|
69
|
-
|
70
|
-
if data
|
71
|
-
return @data[attribute]
|
72
|
-
else
|
73
|
-
return instance_variable_get("@#{attribute}")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# @api private
|
78
|
-
# @return [void]
|
79
|
-
def mark_as_synced(attribute)
|
80
|
-
@synced_attributes << attribute
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|