percy 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +26 -26
- data/VERSION +1 -1
- data/lib/percy.rb +57 -39
- metadata +2 -2
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Percy 0.0.
|
1
|
+
# Percy 0.0.6
|
2
2
|
|
3
3
|
## Configuring and starting the bot
|
4
4
|
|
@@ -36,10 +36,10 @@ No variables.
|
|
36
36
|
end
|
37
37
|
Variables:
|
38
38
|
|
39
|
-
<tt>env[:nick]
|
40
|
-
env[:user]
|
41
|
-
env[:host]
|
42
|
-
env[:channel]
|
39
|
+
<tt>env[:nick]<br />
|
40
|
+
env[:user]<br />
|
41
|
+
env[:host]<br />
|
42
|
+
env[:channel]<br />
|
43
43
|
env[:message]</tt>
|
44
44
|
|
45
45
|
### Query message
|
@@ -48,9 +48,9 @@ env[:message]</tt>
|
|
48
48
|
end
|
49
49
|
Variables:
|
50
50
|
|
51
|
-
<tt>env[:nick]
|
52
|
-
env[:user]
|
53
|
-
env[:host]
|
51
|
+
<tt>env[:nick]<br />
|
52
|
+
env[:user]<br />
|
53
|
+
env[:host]<br />
|
54
54
|
env[:message]</tt>
|
55
55
|
|
56
56
|
### Join
|
@@ -59,9 +59,9 @@ env[:message]</tt>
|
|
59
59
|
end
|
60
60
|
Variables:
|
61
61
|
|
62
|
-
<tt>env[:nick]
|
63
|
-
env[:user]
|
64
|
-
env[:host]
|
62
|
+
<tt>env[:nick]<br />
|
63
|
+
env[:user]<br />
|
64
|
+
env[:host]<br />
|
65
65
|
env[:channel]</tt>
|
66
66
|
|
67
67
|
### Part
|
@@ -70,10 +70,10 @@ env[:channel]</tt>
|
|
70
70
|
end
|
71
71
|
Variables:
|
72
72
|
|
73
|
-
<tt>env[:nick]
|
74
|
-
env[:user]
|
75
|
-
env[:host]
|
76
|
-
env[:channel]
|
73
|
+
<tt>env[:nick]<br />
|
74
|
+
env[:user]<br />
|
75
|
+
env[:host]<br />
|
76
|
+
env[:channel]<br />
|
77
77
|
env[:message]</tt>
|
78
78
|
|
79
79
|
### Quit
|
@@ -82,9 +82,9 @@ env[:message]</tt>
|
|
82
82
|
end
|
83
83
|
Variables:
|
84
84
|
|
85
|
-
<tt>env[:nick]
|
86
|
-
env[:user]
|
87
|
-
env[:host]
|
85
|
+
<tt>env[:nick]<br />
|
86
|
+
env[:user]<br />
|
87
|
+
env[:host]<br />
|
88
88
|
env[:message]</tt>
|
89
89
|
|
90
90
|
### Nickchange
|
@@ -93,9 +93,9 @@ env[:message]</tt>
|
|
93
93
|
end
|
94
94
|
Variables:
|
95
95
|
|
96
|
-
<tt>env[:nick]
|
97
|
-
env[:user]
|
98
|
-
env[:host]
|
96
|
+
<tt>env[:nick]<br />
|
97
|
+
env[:user]<br />
|
98
|
+
env[:host]<br />
|
99
99
|
env[:new_nick]</tt>
|
100
100
|
|
101
101
|
### Kick
|
@@ -104,11 +104,11 @@ env[:new_nick]</tt>
|
|
104
104
|
end
|
105
105
|
Variables:
|
106
106
|
|
107
|
-
<tt>env[:nick]
|
108
|
-
env[:user]
|
109
|
-
env[:host]
|
110
|
-
env[:channel]
|
111
|
-
env[:victim]
|
107
|
+
<tt>env[:nick]<br />
|
108
|
+
env[:user]<br />
|
109
|
+
env[:host]<br />
|
110
|
+
env[:channel]<br />
|
111
|
+
env[:victim]<br />
|
112
112
|
env[:reason]</tt>
|
113
113
|
|
114
114
|
## Availabe Methods
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/lib/percy.rb
CHANGED
@@ -8,7 +8,7 @@ require 'thread'
|
|
8
8
|
Thread.abort_on_exception = true
|
9
9
|
|
10
10
|
class Percy
|
11
|
-
VERSION = 'Percy 0.0.
|
11
|
+
VERSION = 'Percy 0.0.6 (http://github.com/tbuehlmann/percy)'
|
12
12
|
|
13
13
|
Config = Struct.new(:server, :port, :password, :nick, :username, :verbose, :logging)
|
14
14
|
|
@@ -67,6 +67,35 @@ class Percy
|
|
67
67
|
raw "MODE #{recipient} #{option}"
|
68
68
|
end
|
69
69
|
|
70
|
+
# returns all users on a specific channel
|
71
|
+
def users_on(channel)
|
72
|
+
add_observer
|
73
|
+
raw "NAMES #{channel}"
|
74
|
+
|
75
|
+
begin
|
76
|
+
Timeout::timeout(10) do # try 10 seconds to retrieve the users of <channel>
|
77
|
+
start = 0
|
78
|
+
ending = @temp_socket.length
|
79
|
+
|
80
|
+
loop do
|
81
|
+
for line in start..ending do
|
82
|
+
if @temp_socket[line] =~ /^:\S+ 353 \S+ = #{channel} :/
|
83
|
+
return $'.split(' ')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
sleep 0.25
|
88
|
+
start = ending
|
89
|
+
ending = @temp_socket.length
|
90
|
+
end
|
91
|
+
end
|
92
|
+
rescue Timeout::Error
|
93
|
+
return false
|
94
|
+
ensure
|
95
|
+
remove_observer
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
70
99
|
# get the channel limit of a channel
|
71
100
|
def channel_limit(channel)
|
72
101
|
add_observer
|
@@ -74,13 +103,19 @@ class Percy
|
|
74
103
|
|
75
104
|
begin
|
76
105
|
Timeout::timeout(10) do # try 10 seconds to retrieve l mode of <channel>
|
106
|
+
start = 0
|
107
|
+
ending = @temp_socket.length
|
108
|
+
|
77
109
|
loop do
|
78
|
-
|
79
|
-
if line =~ /^:\S+ 324 \S+ #{channel} .*l.* (\d+)/
|
110
|
+
for line in start..ending do
|
111
|
+
if @temp_socket[line] =~ /^:\S+ 324 \S+ #{channel} .*l.* (\d+)/
|
80
112
|
return $1.to_i
|
81
113
|
end
|
82
114
|
end
|
83
|
-
|
115
|
+
|
116
|
+
sleep 0.25
|
117
|
+
start = ending
|
118
|
+
ending = @temp_socket.length
|
84
119
|
end
|
85
120
|
end
|
86
121
|
rescue Timeout::Error
|
@@ -97,15 +132,21 @@ class Percy
|
|
97
132
|
|
98
133
|
begin
|
99
134
|
Timeout::timeout(10) do
|
135
|
+
start = 0
|
136
|
+
ending = @temp_socket.length
|
137
|
+
|
100
138
|
loop do
|
101
|
-
|
102
|
-
if line =~ /^:\S+ 311 \S+ (#{nick}) /i
|
139
|
+
for line in start..ending do
|
140
|
+
if @temp_socket[line] =~ /^:\S+ 311 \S+ (#{nick}) /i
|
103
141
|
return $1
|
104
142
|
elsif line =~ /^:\S+ 401 \S+ #{nick} /i
|
105
143
|
return false
|
106
144
|
end
|
107
145
|
end
|
108
|
-
|
146
|
+
|
147
|
+
sleep 0.25
|
148
|
+
start = ending
|
149
|
+
ending = @temp_socket.length
|
109
150
|
end
|
110
151
|
end
|
111
152
|
rescue Timeout::Error
|
@@ -200,29 +241,6 @@ class Percy
|
|
200
241
|
end
|
201
242
|
end
|
202
243
|
|
203
|
-
# returns all users on a specific channel
|
204
|
-
def users_on(channel)
|
205
|
-
add_observer
|
206
|
-
raw "NAMES #{channel}"
|
207
|
-
|
208
|
-
begin
|
209
|
-
Timeout::timeout(10) do # try 10 seconds to retrieve the users of <channel>
|
210
|
-
loop do
|
211
|
-
@temp_socket.each do |line|
|
212
|
-
if line =~ /^:\S+ 353 \S+ = #{channel} :/
|
213
|
-
return $'.split(' ')
|
214
|
-
end
|
215
|
-
end
|
216
|
-
sleep 0.5
|
217
|
-
end
|
218
|
-
end
|
219
|
-
rescue Timeout::Error
|
220
|
-
return false
|
221
|
-
ensure
|
222
|
-
remove_observer
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
244
|
# parses incoming traffic
|
227
245
|
def parse(type, env = nil)
|
228
246
|
case type
|
@@ -236,7 +254,7 @@ class Percy
|
|
236
254
|
end
|
237
255
|
rescue => e
|
238
256
|
if @error_logger
|
239
|
-
@error_logger.error(e.message)
|
257
|
+
@error_logger.error(e.message)
|
240
258
|
e.backtrace.each do |line|
|
241
259
|
@error_logger.error(line)
|
242
260
|
end
|
@@ -253,7 +271,7 @@ class Percy
|
|
253
271
|
method[:proc].call(env)
|
254
272
|
rescue => e
|
255
273
|
if @error_logger
|
256
|
-
@error_logger.error(e.message)
|
274
|
+
@error_logger.error(e.message)
|
257
275
|
e.backtrace.each do |line|
|
258
276
|
@error_logger.error(line)
|
259
277
|
end
|
@@ -286,7 +304,7 @@ class Percy
|
|
286
304
|
method[:proc].call(env)
|
287
305
|
rescue => e
|
288
306
|
if @error_logger
|
289
|
-
@error_logger.error(e.message)
|
307
|
+
@error_logger.error(e.message)
|
290
308
|
e.backtrace.each do |line|
|
291
309
|
@error_logger.error(line)
|
292
310
|
end
|
@@ -303,7 +321,7 @@ class Percy
|
|
303
321
|
block.call(env)
|
304
322
|
rescue => e
|
305
323
|
if @error_logger
|
306
|
-
@error_logger.error(e.message)
|
324
|
+
@error_logger.error(e.message)
|
307
325
|
e.backtrace.each do |line|
|
308
326
|
@error_logger.error(line)
|
309
327
|
end
|
@@ -319,7 +337,7 @@ class Percy
|
|
319
337
|
block.call(env)
|
320
338
|
rescue => e
|
321
339
|
if @error_logger
|
322
|
-
@error_logger.error(e.message)
|
340
|
+
@error_logger.error(e.message)
|
323
341
|
e.backtrace.each do |line|
|
324
342
|
@error_logger.error(line)
|
325
343
|
end
|
@@ -335,7 +353,7 @@ class Percy
|
|
335
353
|
block.call(env)
|
336
354
|
rescue => e
|
337
355
|
if @error_logger
|
338
|
-
@error_logger.error(e.message)
|
356
|
+
@error_logger.error(e.message)
|
339
357
|
e.backtrace.each do |line|
|
340
358
|
@error_logger.error(line)
|
341
359
|
end
|
@@ -351,7 +369,7 @@ class Percy
|
|
351
369
|
block.call(env)
|
352
370
|
rescue => e
|
353
371
|
if @error_logger
|
354
|
-
@error_logger.error(e.message)
|
372
|
+
@error_logger.error(e.message)
|
355
373
|
e.backtrace.each do |line|
|
356
374
|
@error_logger.error(line)
|
357
375
|
end
|
@@ -367,7 +385,7 @@ class Percy
|
|
367
385
|
block.call(env)
|
368
386
|
rescue => e
|
369
387
|
if @error_logger
|
370
|
-
@error_logger.error(e.message)
|
388
|
+
@error_logger.error(e.message)
|
371
389
|
e.backtrace.each do |line|
|
372
390
|
@error_logger.error(line)
|
373
391
|
end
|
@@ -438,7 +456,7 @@ class Percy
|
|
438
456
|
@connected = false
|
439
457
|
end
|
440
458
|
rescue => e
|
441
|
-
@error_logger.error(e.message)
|
459
|
+
@error_logger.error(e.message)
|
442
460
|
e.backtrace.each do |line|
|
443
461
|
@error_logger.error(line)
|
444
462
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Tobias B\xC3\xBChlmann"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-13 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|