kag-gather 1.2.2 → 1.2.3
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/kag/gather.rb +28 -27
- data/lib/kag/team.rb +2 -2
- data/lib/kag/version.rb +1 -1
- metadata +1 -1
data/lib/kag/gather.rb
CHANGED
@@ -8,10 +8,6 @@ module KAG
|
|
8
8
|
class Gather
|
9
9
|
include Cinch::Plugin
|
10
10
|
|
11
|
-
def config
|
12
|
-
KAG::Config.instance
|
13
|
-
end
|
14
|
-
|
15
11
|
attr_accessor :queue,:servers
|
16
12
|
|
17
13
|
def initialize(*args)
|
@@ -33,8 +29,9 @@ module KAG
|
|
33
29
|
#def channel_listen(m)
|
34
30
|
#end
|
35
31
|
|
36
|
-
listen_to :leaving, method
|
32
|
+
listen_to :leaving, :method => :on_leaving
|
37
33
|
def on_leaving(m,nick)
|
34
|
+
nick = nick.to_s
|
38
35
|
match = get_match_in(nick)
|
39
36
|
if match
|
40
37
|
match.remove_player(nick)
|
@@ -43,7 +40,7 @@ module KAG
|
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
46
|
-
listen_to :nick, method
|
43
|
+
listen_to :nick, :method => :on_nick
|
47
44
|
def on_nick(m)
|
48
45
|
match = get_match_in(m.user.last_nick)
|
49
46
|
if match
|
@@ -54,7 +51,7 @@ module KAG
|
|
54
51
|
end
|
55
52
|
end
|
56
53
|
|
57
|
-
match "add", method
|
54
|
+
match "add", :method => :evt_add
|
58
55
|
def evt_add(m)
|
59
56
|
add_user_to_queue(m,m.user.nick)
|
60
57
|
end
|
@@ -72,7 +69,7 @@ module KAG
|
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
75
|
-
match "list", method
|
72
|
+
match "list", :method => :evt_list
|
76
73
|
def evt_list(m)
|
77
74
|
users = []
|
78
75
|
@queue.each do |n,u|
|
@@ -81,12 +78,12 @@ module KAG
|
|
81
78
|
m.user.send "Queue (#{KAG::Match.type_as_string}) [#{@queue.length}] #{users.join(", ")}"
|
82
79
|
end
|
83
80
|
|
84
|
-
match "status", method
|
81
|
+
match "status", :method => :evt_status
|
85
82
|
def evt_status(m)
|
86
83
|
reply m,"Matches in progress: #{@matches.length.to_s}"
|
87
84
|
end
|
88
85
|
|
89
|
-
match "end", method
|
86
|
+
match "end", :method => :evt_end
|
90
87
|
def evt_end(m)
|
91
88
|
match = get_match_in(m.user.nick)
|
92
89
|
if match
|
@@ -104,7 +101,11 @@ module KAG
|
|
104
101
|
end
|
105
102
|
|
106
103
|
def add_user_to_queue(m,nick,send_msg = true)
|
107
|
-
|
104
|
+
if @queue.key?(nick)
|
105
|
+
reply m,"#{nick} is already in the queue!"
|
106
|
+
elsif get_match_in(nick)
|
107
|
+
reply m,"#{nick} is already in a match!"
|
108
|
+
else
|
108
109
|
@queue[nick] = SymbolTable.new({
|
109
110
|
:user => User(nick),
|
110
111
|
:channel => m.channel,
|
@@ -187,10 +188,10 @@ module KAG
|
|
187
188
|
server
|
188
189
|
end
|
189
190
|
|
190
|
-
match "help", method
|
191
|
+
match "help", :method => :evt_help
|
191
192
|
def evt_help(m)
|
192
193
|
msg = "Commands: !add, !rem, !list, !status, !help, !end"
|
193
|
-
msg = msg + ", !rem [nick], !add [nick], !clear, !restart, !quit" if is_admin(m.user)
|
194
|
+
msg = msg + ", !rem [nick], !add [nick], !add_silent, !rem_silent, !clear, !restart, !quit" if is_admin(m.user)
|
194
195
|
User(m.user.nick).send(msg)
|
195
196
|
end
|
196
197
|
|
@@ -208,7 +209,7 @@ module KAG
|
|
208
209
|
o.include?(user.authname)
|
209
210
|
end
|
210
211
|
|
211
|
-
match "clear", method
|
212
|
+
match "clear", :method => :evt_clear
|
212
213
|
def evt_clear(m)
|
213
214
|
if is_admin(m.user)
|
214
215
|
send_channels_msg "Match queue cleared."
|
@@ -216,7 +217,7 @@ module KAG
|
|
216
217
|
end
|
217
218
|
end
|
218
219
|
|
219
|
-
match /rem (.+)/, method
|
220
|
+
match /rem (.+)/, :method => :evt_rem_admin
|
220
221
|
def evt_rem_admin(m, arg)
|
221
222
|
if is_admin(m.user)
|
222
223
|
arg = arg.split(" ")
|
@@ -226,7 +227,7 @@ module KAG
|
|
226
227
|
end
|
227
228
|
end
|
228
229
|
|
229
|
-
match /rem_silent (.+)/, method
|
230
|
+
match /rem_silent (.+)/, :method => :evt_rem_silent_admin
|
230
231
|
def evt_rem_silent_admin(m, arg)
|
231
232
|
if is_admin(m.user)
|
232
233
|
arg = arg.split(" ")
|
@@ -236,7 +237,7 @@ module KAG
|
|
236
237
|
end
|
237
238
|
end
|
238
239
|
|
239
|
-
match /add (.+)/, method
|
240
|
+
match /add (.+)/, :method => :evt_add_admin
|
240
241
|
def evt_add_admin(m, arg)
|
241
242
|
if is_admin(m.user)
|
242
243
|
arg = arg.split(" ")
|
@@ -246,7 +247,7 @@ module KAG
|
|
246
247
|
end
|
247
248
|
end
|
248
249
|
|
249
|
-
match /add_silent (.+)/, method
|
250
|
+
match /add_silent (.+)/, :method => :evt_add_silent_admin
|
250
251
|
def evt_add_silent_admin(m, arg)
|
251
252
|
if is_admin(m.user)
|
252
253
|
arg = arg.split(" ")
|
@@ -256,7 +257,7 @@ module KAG
|
|
256
257
|
end
|
257
258
|
end
|
258
259
|
|
259
|
-
match /is_admin (.+)/, method
|
260
|
+
match /is_admin (.+)/, :method => :evt_am_i_admin
|
260
261
|
def evt_am_i_admin(m,nick)
|
261
262
|
u = User(nick)
|
262
263
|
if is_admin(u)
|
@@ -267,14 +268,14 @@ module KAG
|
|
267
268
|
end
|
268
269
|
|
269
270
|
|
270
|
-
match "quit", method
|
271
|
+
match "quit", :method => :evt_quit
|
271
272
|
def evt_quit(m)
|
272
273
|
if is_admin(m.user)
|
273
274
|
m.bot.quit("Shutting down...")
|
274
275
|
end
|
275
276
|
end
|
276
277
|
|
277
|
-
match "restart", method
|
278
|
+
match "restart", :method => :evt_restart
|
278
279
|
def evt_restart(m)
|
279
280
|
if is_admin(m.user)
|
280
281
|
cmd = (KAG::Config.instance[:restart_method] or "nohup sh gather.sh &")
|
@@ -285,7 +286,7 @@ module KAG
|
|
285
286
|
end
|
286
287
|
end
|
287
288
|
|
288
|
-
match "restart_map", method
|
289
|
+
match "restart_map", :method => :evt_restart_map
|
289
290
|
def evt_restart_map(m)
|
290
291
|
if is_admin(m.user)
|
291
292
|
match = get_match_in(m.user.nick)
|
@@ -295,7 +296,7 @@ module KAG
|
|
295
296
|
end
|
296
297
|
end
|
297
298
|
|
298
|
-
match /restart_map (.+)/, method
|
299
|
+
match /restart_map (.+)/, :method => :evt_restart_map_specify
|
299
300
|
def evt_restart_map_specify(m,arg)
|
300
301
|
if is_admin(m.user)
|
301
302
|
if @servers[key]
|
@@ -306,7 +307,7 @@ module KAG
|
|
306
307
|
end
|
307
308
|
end
|
308
309
|
|
309
|
-
match "next_map", method
|
310
|
+
match "next_map", :method => :evt_next_map
|
310
311
|
def evt_next_map(m)
|
311
312
|
if is_admin(m.user)
|
312
313
|
match = get_match_in(m.user.nick)
|
@@ -316,7 +317,7 @@ module KAG
|
|
316
317
|
end
|
317
318
|
end
|
318
319
|
|
319
|
-
match /next_map (.+)/, method
|
320
|
+
match /next_map (.+)/, :method => :evt_next_map_specify
|
320
321
|
def evt_next_map_specify(m,arg)
|
321
322
|
if is_admin(m.user)
|
322
323
|
if @servers[key]
|
@@ -327,7 +328,7 @@ module KAG
|
|
327
328
|
end
|
328
329
|
end
|
329
330
|
|
330
|
-
match /kick_from_match (.+)/, method
|
331
|
+
match /kick_from_match (.+)/, :method => :evt_kick_from_match
|
331
332
|
def evt_kick_from_match(m,nick)
|
332
333
|
if is_admin(m.user)
|
333
334
|
match = get_match_in(nick)
|
@@ -340,7 +341,7 @@ module KAG
|
|
340
341
|
end
|
341
342
|
end
|
342
343
|
|
343
|
-
match "reload_config", method
|
344
|
+
match "reload_config", :method => :evt_reload_config
|
344
345
|
def evt_reload_config(m)
|
345
346
|
if is_admin(m.user)
|
346
347
|
KAG::Config.instance.reload
|
data/lib/kag/team.rb
CHANGED
@@ -8,7 +8,6 @@ module KAG
|
|
8
8
|
|
9
9
|
def setup
|
10
10
|
setup_classes
|
11
|
-
puts self[:players].inspect
|
12
11
|
self
|
13
12
|
end
|
14
13
|
|
@@ -20,6 +19,7 @@ module KAG
|
|
20
19
|
players.each do |p|
|
21
20
|
self[:players][p.to_sym] = classes.shift
|
22
21
|
end
|
22
|
+
self
|
23
23
|
end
|
24
24
|
|
25
25
|
def notify_of_match_start
|
@@ -31,7 +31,7 @@ module KAG
|
|
31
31
|
self[:players].each do |nick,cls|
|
32
32
|
player_msg = msg.clone
|
33
33
|
player_msg = player_msg+cls if KAG::Config.instance[:pick_classes] and cls and !cls.empty?
|
34
|
-
player_msg = player_msg+"
|
34
|
+
player_msg = player_msg+" #{self[:color]}#{self[:name]} with: #{self[:players].keys.join(", ")}"
|
35
35
|
messages[nick] = player_msg
|
36
36
|
end
|
37
37
|
messages
|
data/lib/kag/version.rb
CHANGED