kag-gather 1.3.1 → 1.3.2
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/gather.rb +1 -0
- data/lib/kag/config.rb +6 -0
- data/lib/kag/data.rb +41 -0
- data/lib/kag/gather.rb +159 -56
- data/lib/kag/report.rb +146 -0
- data/lib/kag/server.rb +19 -7
- data/lib/kag/team.rb +1 -1
- data/lib/kag/version.rb +1 -1
- data/lib/patches.rb +16 -0
- metadata +48 -47
data/lib/gather.rb
CHANGED
data/lib/kag/config.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
require 'singleton'
|
|
2
2
|
require 'symboltable'
|
|
3
3
|
require 'json'
|
|
4
|
+
require 'kag/data'
|
|
4
5
|
|
|
5
6
|
module KAG
|
|
6
7
|
class Config < SymbolTable
|
|
7
8
|
include Singleton
|
|
9
|
+
@@data = KAG::Data.new
|
|
8
10
|
|
|
9
11
|
def initialize
|
|
10
12
|
super
|
|
@@ -23,5 +25,9 @@ module KAG
|
|
|
23
25
|
puts "Reloading configuration file..."
|
|
24
26
|
self.merge!(self._get_config)
|
|
25
27
|
end
|
|
28
|
+
|
|
29
|
+
def self.data
|
|
30
|
+
@@data
|
|
31
|
+
end
|
|
26
32
|
end
|
|
27
33
|
end
|
data/lib/kag/data.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'singleton'
|
|
2
|
+
require 'symboltable'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
module KAG
|
|
6
|
+
class Data < Hash
|
|
7
|
+
def initialize(hash=nil)
|
|
8
|
+
super
|
|
9
|
+
self.merge!(self._load)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def _load
|
|
13
|
+
unless File.exists?("config/data.json")
|
|
14
|
+
File.open("config/data.json","w") {|f| f.write("{}") }
|
|
15
|
+
end
|
|
16
|
+
f = ::IO.read("config/data.json")
|
|
17
|
+
if f and !f.empty?
|
|
18
|
+
SymbolTable.new(JSON.parse(f))
|
|
19
|
+
else
|
|
20
|
+
SymbolTable.new
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def reload
|
|
25
|
+
puts "Reloading data file..."
|
|
26
|
+
self.merge!(self._load)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Sets the value of the given +key+ to +val+.
|
|
30
|
+
def store(key, val)
|
|
31
|
+
super(key,val)
|
|
32
|
+
self.save
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def save
|
|
36
|
+
File.open("config/data.json","w") do |f|
|
|
37
|
+
f.write(self.to_json)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/kag/gather.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'cinch'
|
|
2
2
|
require 'kag/bot'
|
|
3
3
|
require 'kag/config'
|
|
4
|
+
require 'kag/data'
|
|
5
|
+
require 'kag/report'
|
|
4
6
|
require 'kag/server'
|
|
5
7
|
require 'kag/match'
|
|
6
8
|
|
|
@@ -31,37 +33,43 @@ module KAG
|
|
|
31
33
|
|
|
32
34
|
listen_to :leaving, :method => :on_leaving
|
|
33
35
|
def on_leaving(m,nick)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
unless is_banned?(m.user)
|
|
37
|
+
nick = nick.to_s
|
|
38
|
+
match = get_match_in(nick)
|
|
39
|
+
if match
|
|
40
|
+
sub = match.remove_player(nick)
|
|
41
|
+
if sub
|
|
42
|
+
m.channel.msg sub[:msg]
|
|
43
|
+
end
|
|
44
|
+
elsif @queue.key?(nick)
|
|
45
|
+
remove_user_from_queue(nick)
|
|
40
46
|
end
|
|
41
|
-
elsif @queue.key?(nick)
|
|
42
|
-
remove_user_from_queue(nick)
|
|
43
47
|
end
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
listen_to :nick, :method => :on_nick
|
|
47
51
|
def on_nick(m)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
match
|
|
51
|
-
|
|
52
|
-
@queue
|
|
53
|
-
|
|
52
|
+
unless is_banned?(m.user)
|
|
53
|
+
match = get_match_in(m.user.last_nick)
|
|
54
|
+
if match
|
|
55
|
+
match.rename_player(m.user.last_nick,m.user.nick)
|
|
56
|
+
elsif @queue.key?(m.user.last_nick)
|
|
57
|
+
@queue[m.user.nick] = @queue[m.user.last_nick]
|
|
58
|
+
@queue.delete(m.user.last_nick)
|
|
59
|
+
end
|
|
54
60
|
end
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
match "sub", :method => :evt_sub
|
|
58
64
|
def evt_sub(m)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
unless is_banned?(m.user)
|
|
66
|
+
@matches.each do |k,match|
|
|
67
|
+
if match.needs_sub?
|
|
68
|
+
placement = match.sub_in(m.user.nick)
|
|
69
|
+
if placement
|
|
70
|
+
reply m,placement[:channel_msg]
|
|
71
|
+
User(m.user.nick).send placement[:private_msg]
|
|
72
|
+
end
|
|
65
73
|
end
|
|
66
74
|
end
|
|
67
75
|
end
|
|
@@ -69,50 +77,81 @@ module KAG
|
|
|
69
77
|
|
|
70
78
|
match "add", :method => :evt_add
|
|
71
79
|
def evt_add(m)
|
|
72
|
-
|
|
80
|
+
unless is_banned?(m.user)
|
|
81
|
+
add_user_to_queue(m,m.user.nick)
|
|
82
|
+
end
|
|
73
83
|
end
|
|
74
84
|
|
|
75
85
|
match "rem", method: :evt_rem
|
|
76
86
|
def evt_rem(m)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
match
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
unless is_banned?(m.user)
|
|
88
|
+
match = get_match_in(m.user.nick)
|
|
89
|
+
if match
|
|
90
|
+
match.remove_player(m.user.nick)
|
|
91
|
+
send_channels_msg "#{m.user.nick} has left the match at #{match.server[:key]}! You can sub in by typing !sub"
|
|
92
|
+
elsif @queue.key?(m.user.nick)
|
|
93
|
+
unless remove_user_from_queue(m.user.nick)
|
|
94
|
+
debug "#{nick} is not in the queue."
|
|
95
|
+
end
|
|
84
96
|
end
|
|
85
97
|
end
|
|
86
98
|
end
|
|
87
99
|
|
|
88
100
|
match "list", :method => :evt_list
|
|
89
101
|
def evt_list(m)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
unless is_banned?(m.user)
|
|
103
|
+
users = []
|
|
104
|
+
@queue.each do |n,u|
|
|
105
|
+
users << n
|
|
106
|
+
end
|
|
107
|
+
m.user.send "Queue (#{KAG::Match.type_as_string}) [#{@queue.length}] #{users.join(", ")}"
|
|
93
108
|
end
|
|
94
|
-
m.user.send "Queue (#{KAG::Match.type_as_string}) [#{@queue.length}] #{users.join(", ")}"
|
|
95
109
|
end
|
|
96
110
|
|
|
97
111
|
match "status", :method => :evt_status
|
|
98
112
|
def evt_status(m)
|
|
99
|
-
|
|
113
|
+
unless is_banned?(m.user)
|
|
114
|
+
reply m,"Matches in progress: #{@matches.length.to_s}"
|
|
115
|
+
end
|
|
100
116
|
end
|
|
101
117
|
|
|
102
118
|
match "end", :method => :evt_end
|
|
103
119
|
def evt_end(m)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
match
|
|
107
|
-
|
|
108
|
-
match.
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
unless is_banned?(m.user)
|
|
121
|
+
match = get_match_in(m.user.nick)
|
|
122
|
+
if match
|
|
123
|
+
match.add_end_vote
|
|
124
|
+
if match.voted_to_end?
|
|
125
|
+
match.cease
|
|
126
|
+
@matches.delete(match.server[:key])
|
|
127
|
+
send_channels_msg("Match at #{match.server[:key]} finished!")
|
|
128
|
+
else
|
|
129
|
+
reply m,"End vote started, #{match.get_needed_end_votes_left} more votes to end match at #{match.server[:key]}"
|
|
130
|
+
end
|
|
111
131
|
else
|
|
112
|
-
reply m,"
|
|
132
|
+
reply m,"You're not in a match, silly! Stop trying to hack me."
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
match "help", :method => :evt_help
|
|
138
|
+
def evt_help(m)
|
|
139
|
+
unless is_banned?(m.user)
|
|
140
|
+
msg = "Commands: !add, !rem, !list, !status, !help, !end, !report"
|
|
141
|
+
msg = msg + ", !rem [nick], !add [nick], !add_silent, !rem_silent, !unreport, !clear, !restart, !quit" if is_admin(m.user)
|
|
142
|
+
User(m.user.nick).send(msg)
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
match /report (.+)/,:method => :report
|
|
147
|
+
def report(m,nick)
|
|
148
|
+
unless is_banned?(m.user)
|
|
149
|
+
u = User(nick)
|
|
150
|
+
if u and !u.unknown
|
|
151
|
+
KAG::Report.new(m,u)
|
|
152
|
+
else
|
|
153
|
+
reply m,"User #{nick} not found!"
|
|
113
154
|
end
|
|
114
|
-
else
|
|
115
|
-
reply m,"You're not in a match, silly! Stop trying to hack me."
|
|
116
155
|
end
|
|
117
156
|
end
|
|
118
157
|
|
|
@@ -167,19 +206,20 @@ module KAG
|
|
|
167
206
|
return false
|
|
168
207
|
end
|
|
169
208
|
|
|
209
|
+
# reset queue first to prevent 11-player load
|
|
210
|
+
@queue = {}
|
|
211
|
+
|
|
170
212
|
match = KAG::Match.new(SymbolTable.new({
|
|
171
213
|
:server => server,
|
|
172
214
|
:players => players
|
|
173
215
|
}))
|
|
174
|
-
match.start
|
|
175
|
-
messages = match.notify_teams_of_match_start
|
|
216
|
+
match.start # prepare match data
|
|
217
|
+
messages = match.notify_teams_of_match_start # gather texts for private messages
|
|
218
|
+
send_channels_msg(match.text_for_match_start,false) # send channel-wide first
|
|
176
219
|
messages.each do |nick,msg|
|
|
177
220
|
User(nick.to_s).send(msg) unless nick.to_s.include?("player")
|
|
178
|
-
sleep(2)
|
|
221
|
+
sleep(2) # prevent excess flood stuff
|
|
179
222
|
end
|
|
180
|
-
send_channels_msg(match.text_for_match_start,false)
|
|
181
|
-
|
|
182
|
-
@queue = {}
|
|
183
223
|
@matches[server[:key]] = match
|
|
184
224
|
end
|
|
185
225
|
end
|
|
@@ -198,19 +238,13 @@ module KAG
|
|
|
198
238
|
|
|
199
239
|
def get_unused_server
|
|
200
240
|
server = false
|
|
241
|
+
@servers.shuffle!
|
|
201
242
|
@servers.each do |k,s|
|
|
202
243
|
server = s unless s.in_use?
|
|
203
244
|
end
|
|
204
245
|
server
|
|
205
246
|
end
|
|
206
247
|
|
|
207
|
-
match "help", :method => :evt_help
|
|
208
|
-
def evt_help(m)
|
|
209
|
-
msg = "Commands: !add, !rem, !list, !status, !help, !end"
|
|
210
|
-
msg = msg + ", !rem [nick], !add [nick], !add_silent, !rem_silent, !clear, !restart, !quit" if is_admin(m.user)
|
|
211
|
-
User(m.user.nick).send(msg)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
248
|
# admin methods
|
|
215
249
|
|
|
216
250
|
def debug(msg)
|
|
@@ -399,5 +433,74 @@ module KAG
|
|
|
399
433
|
m.reply "Configuration reloaded."
|
|
400
434
|
end
|
|
401
435
|
end
|
|
436
|
+
|
|
437
|
+
match /unreport (.+)/,:method => :unreport
|
|
438
|
+
def unreport(m,nick)
|
|
439
|
+
if is_admin(m.user)
|
|
440
|
+
user = User(nick)
|
|
441
|
+
if user and !user.unknown
|
|
442
|
+
KAG::Report.remove(user,m,self)
|
|
443
|
+
else
|
|
444
|
+
reply m,"Could not find user #{nick}"
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
match /ignore (.+)/,:method => :ignore
|
|
450
|
+
def ignore(m,nick)
|
|
451
|
+
if is_admin(m.user)
|
|
452
|
+
user = User(nick)
|
|
453
|
+
if user and !user.unknown
|
|
454
|
+
KAG::Report.ignore(user,m,self)
|
|
455
|
+
else
|
|
456
|
+
reply m,"Could not find user #{nick}"
|
|
457
|
+
end
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
match /unignore (.+)/,:method => :unignore
|
|
462
|
+
def unignore(m,nick)
|
|
463
|
+
if is_admin(m.user)
|
|
464
|
+
user = User(nick)
|
|
465
|
+
if user and !user.unknown
|
|
466
|
+
KAG::Report.unignore(user,m,self)
|
|
467
|
+
else
|
|
468
|
+
reply m,"Could not find user #{nick}"
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
match /hostname (.+)/,:method => :hostname
|
|
474
|
+
def hostname(m,nick)
|
|
475
|
+
if is_admin(m.user)
|
|
476
|
+
user = User(nick)
|
|
477
|
+
if user and !user.unknown
|
|
478
|
+
reply m,"Hostname for #{nick} is #{user.host}"
|
|
479
|
+
else
|
|
480
|
+
reply m,"Could not find user #{nick}"
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
match /authname (.+)/,:method => :authname
|
|
486
|
+
def authname(m,nick)
|
|
487
|
+
if is_admin(m.user)
|
|
488
|
+
user = User(nick)
|
|
489
|
+
if user and !user.unknown
|
|
490
|
+
reply m,"Authname for #{nick} is #{user.authname}"
|
|
491
|
+
else
|
|
492
|
+
reply m,"Could not find user #{nick}"
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
def is_banned?(user)
|
|
498
|
+
d = KAG::Config.data
|
|
499
|
+
if d
|
|
500
|
+
d[:ignored].key?(user.host.to_sym)
|
|
501
|
+
else
|
|
502
|
+
false
|
|
503
|
+
end
|
|
504
|
+
end
|
|
402
505
|
end
|
|
403
506
|
end
|
data/lib/kag/report.rb
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
require 'symboltable'
|
|
2
|
+
require 'kag/data'
|
|
3
|
+
require 'kag/config'
|
|
4
|
+
|
|
5
|
+
module KAG
|
|
6
|
+
class Report < SymbolTable
|
|
7
|
+
|
|
8
|
+
def initialize(m,user)
|
|
9
|
+
hash = {
|
|
10
|
+
:nick => user.nick,
|
|
11
|
+
:authname => user.authname,
|
|
12
|
+
:host => user.host,
|
|
13
|
+
:realname => user.realname,
|
|
14
|
+
:gather => self,
|
|
15
|
+
:message => m,
|
|
16
|
+
:count => 1
|
|
17
|
+
}
|
|
18
|
+
super(hash)
|
|
19
|
+
_ensure_data
|
|
20
|
+
if reported?
|
|
21
|
+
if can_report?
|
|
22
|
+
if past_threshold?
|
|
23
|
+
ignore
|
|
24
|
+
else
|
|
25
|
+
up_report_count
|
|
26
|
+
end
|
|
27
|
+
else
|
|
28
|
+
self[:gather].reply self[:message],"You have already reported #{self[:nick]}. You can only report a user once."
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
report
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def can_report?
|
|
36
|
+
r = _report
|
|
37
|
+
if r and r[:reporters]
|
|
38
|
+
!r[:reporters].include?(self[:message].user.authname)
|
|
39
|
+
else
|
|
40
|
+
true
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def _ensure_data
|
|
45
|
+
data[:reported] = {} unless data[:reported]
|
|
46
|
+
data[:ignored] = {} unless data[:ignored]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def reported?
|
|
50
|
+
data[:reported].key?(self[:host].to_sym)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def report
|
|
54
|
+
puts self[:message].inspect
|
|
55
|
+
c = self.dup
|
|
56
|
+
c.delete(:gather)
|
|
57
|
+
c.delete(:message)
|
|
58
|
+
c[:reporters] = [self[:message].user[:authname]]
|
|
59
|
+
data[:reported][self[:host].to_sym] = c
|
|
60
|
+
data.save
|
|
61
|
+
|
|
62
|
+
self[:gather].reply self[:message],"User #{self[:nick]} reported." if self[:gather].class == KAG::Gather
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def ignore
|
|
66
|
+
c = self.clone
|
|
67
|
+
c.delete(:gather)
|
|
68
|
+
c.delete(:message)
|
|
69
|
+
data[:ignored][self[:host].to_sym] = c
|
|
70
|
+
data.save
|
|
71
|
+
self[:gather].reply self[:message],"User #{self[:nick]} ignored." if gather.class == KAG::Gather
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def past_threshold?
|
|
75
|
+
_report[:count].to_i > KAG::Config.instance[:report_threshold].to_i
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def up_report_count
|
|
79
|
+
_report[:count] = _report[:count].to_i + 1
|
|
80
|
+
_report[:reporters] = [] unless _report[:reporters]
|
|
81
|
+
_report[:reporters] << self[:message].user.authname
|
|
82
|
+
data.save
|
|
83
|
+
|
|
84
|
+
gather.reply message,"User #{self[:nick]} reported. #{self[:nick]} has now been reported #{data[:reported][self[:host].to_sym][:count]} times." if gather.class == KAG::Gather
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.ignore(user,message,gather)
|
|
88
|
+
KAG::Config.data[:ignored] = {} unless KAG::Config.data[:ignored]
|
|
89
|
+
if KAG::Config.data[:ignored] and !KAG::Config.data[:ignored].key?(user.host.to_sym)
|
|
90
|
+
c = SymbolTable.new({
|
|
91
|
+
:nick => user.nick,
|
|
92
|
+
:authname => user.authname,
|
|
93
|
+
:host => user.host,
|
|
94
|
+
:realname => user.realname,
|
|
95
|
+
:gather => gather,
|
|
96
|
+
:message => message,
|
|
97
|
+
:reporters => [message.user.authname]
|
|
98
|
+
})
|
|
99
|
+
KAG::Config.data[:ignored][user.host.to_sym] = c
|
|
100
|
+
KAG::Config.data.save
|
|
101
|
+
|
|
102
|
+
gather.reply message,"User #{user.nick} added to ignore list." if gather.class == KAG::Gather
|
|
103
|
+
true
|
|
104
|
+
else
|
|
105
|
+
gather.reply message,"User #{user.nick} already in ignore list!" if gather.class == KAG::Gather
|
|
106
|
+
false
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.remove(user,message,gather)
|
|
111
|
+
if KAG::Config.data[:reported] and KAG::Config.data[:reported].key?(user.host.to_sym)
|
|
112
|
+
KAG::Config.data[:reported].delete(user.host.to_sym)
|
|
113
|
+
KAG::Config.data.save
|
|
114
|
+
|
|
115
|
+
gather.reply message,"User #{user.nick} removed from report list." if gather.class == KAG::Gather
|
|
116
|
+
true
|
|
117
|
+
else
|
|
118
|
+
gather.reply message,"User #{user.nick} not in report list!" if gather.class == KAG::Gather
|
|
119
|
+
false
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.unignore(user,message,gather)
|
|
124
|
+
if KAG::Config.data[:ignored] and KAG::Config.data[:ignored].key?(user.host.to_sym)
|
|
125
|
+
KAG::Config.data[:ignored].delete(user.host.to_sym)
|
|
126
|
+
KAG::Config.data.save
|
|
127
|
+
|
|
128
|
+
gather.reply message,"User #{user.nick} removed from ignore list." if gather.class == KAG::Gather
|
|
129
|
+
true
|
|
130
|
+
else
|
|
131
|
+
gather.reply message,"User #{user.nick} not in ignore list!" if gather.class == KAG::Gather
|
|
132
|
+
false
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
protected
|
|
137
|
+
|
|
138
|
+
def data
|
|
139
|
+
KAG::Config.data
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def _report
|
|
143
|
+
data[:reported][self[:host].to_sym]
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
data/lib/kag/server.rb
CHANGED
|
@@ -21,7 +21,12 @@ module KAG
|
|
|
21
21
|
|
|
22
22
|
def socket
|
|
23
23
|
unless self[:_socket]
|
|
24
|
-
|
|
24
|
+
begin
|
|
25
|
+
self[:_socket] = TCPSocket.new(self[:ip],self[:port])
|
|
26
|
+
rescue Exception => e
|
|
27
|
+
puts e.message
|
|
28
|
+
puts e.backtrace.join("\n")
|
|
29
|
+
end
|
|
25
30
|
end
|
|
26
31
|
puts self[:_]
|
|
27
32
|
self[:_socket]
|
|
@@ -38,12 +43,19 @@ module KAG
|
|
|
38
43
|
puts "[RCON] Could not establish TCP socket to connect"
|
|
39
44
|
return false
|
|
40
45
|
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
success = false
|
|
47
|
+
begin
|
|
48
|
+
self.socket.puts self[:rcon_password]
|
|
49
|
+
z = self.socket.gets
|
|
50
|
+
puts "[RCON] "+z.to_s
|
|
51
|
+
z.include?("now authenticated")
|
|
52
|
+
self[:_connected] = true
|
|
53
|
+
success = true
|
|
54
|
+
rescue Exception => e
|
|
55
|
+
puts e.message
|
|
56
|
+
puts e.backtrace.join("\n")
|
|
57
|
+
end
|
|
58
|
+
success
|
|
47
59
|
end
|
|
48
60
|
|
|
49
61
|
def disconnect
|
data/lib/kag/team.rb
CHANGED
|
@@ -58,7 +58,7 @@ module KAG
|
|
|
58
58
|
sub = {}
|
|
59
59
|
sub[:cls] = self[:players][nick]
|
|
60
60
|
sub[:team] = self.clone
|
|
61
|
-
sub[:msg] = "Sub needed at #{self.match.server[:ip]} for #{sub[:team]}, #{sub[:cls]} Class! Type !sub to claim it!"
|
|
61
|
+
sub[:msg] = "Sub needed at #{self.match.server[:ip]} for #{sub[:team][:name]}, #{sub[:cls]} Class! Type !sub to claim it!"
|
|
62
62
|
sub[:channel_msg] = "#{nick} is now subbing in for #{self[:name]} at #{self.match.server[:key]}. Subs still needed: #{self.match[:subs_needed].length}"
|
|
63
63
|
sub[:private_msg] = "Please #{self.match.server.text_join} | #{sub[:cls]} on the #{self[:name]} Team"
|
|
64
64
|
self[:players].delete(nick)
|
data/lib/kag/version.rb
CHANGED
data/lib/patches.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Hash
|
|
2
|
+
@keys_not_used = nil
|
|
3
|
+
def random_key
|
|
4
|
+
@keys_not_used = self.dup if (!@keys_not_used or @keys_not_used.size == 0)
|
|
5
|
+
key = @keys_not_used.keys[rand(@keys_not_used.size)]
|
|
6
|
+
@keys_not_used.delete(key)
|
|
7
|
+
key
|
|
8
|
+
end
|
|
9
|
+
def shuffle
|
|
10
|
+
self.class[self.to_a.sample(self.length)]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def shuffle!
|
|
14
|
+
self.replace(self.shuffle)
|
|
15
|
+
end
|
|
16
|
+
end
|
metadata
CHANGED
|
@@ -1,128 +1,128 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kag-gather
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
version: 1.3.2
|
|
5
|
+
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Shaun McCormick
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-03-
|
|
12
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: cinch
|
|
16
|
-
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
17
18
|
requirements:
|
|
18
19
|
- - '='
|
|
19
20
|
- !ruby/object:Gem::Version
|
|
20
21
|
version: 2.0.4
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
21
25
|
none: false
|
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
27
|
- - '='
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 2.0.4
|
|
27
|
-
none: false
|
|
28
|
-
prerelease: false
|
|
29
|
-
type: :runtime
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: json
|
|
32
|
-
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
33
34
|
requirements:
|
|
34
35
|
- - ! '>='
|
|
35
36
|
- !ruby/object:Gem::Version
|
|
36
37
|
version: '0'
|
|
38
|
+
type: :runtime
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
41
|
none: false
|
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
|
39
42
|
requirements:
|
|
40
43
|
- - ! '>='
|
|
41
44
|
- !ruby/object:Gem::Version
|
|
42
45
|
version: '0'
|
|
43
|
-
none: false
|
|
44
|
-
prerelease: false
|
|
45
|
-
type: :runtime
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: symboltable
|
|
48
|
-
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
49
50
|
requirements:
|
|
50
51
|
- - '='
|
|
51
52
|
- !ruby/object:Gem::Version
|
|
52
53
|
version: 1.0.2
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
57
|
none: false
|
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
|
55
58
|
requirements:
|
|
56
59
|
- - '='
|
|
57
60
|
- !ruby/object:Gem::Version
|
|
58
61
|
version: 1.0.2
|
|
59
|
-
none: false
|
|
60
|
-
prerelease: false
|
|
61
|
-
type: :runtime
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
|
63
63
|
name: kagerator
|
|
64
|
-
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
65
66
|
requirements:
|
|
66
67
|
- - '='
|
|
67
68
|
- !ruby/object:Gem::Version
|
|
68
69
|
version: 1.0.3
|
|
70
|
+
type: :runtime
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
69
73
|
none: false
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
74
|
requirements:
|
|
72
75
|
- - '='
|
|
73
76
|
- !ruby/object:Gem::Version
|
|
74
77
|
version: 1.0.3
|
|
75
|
-
none: false
|
|
76
|
-
prerelease: false
|
|
77
|
-
type: :runtime
|
|
78
78
|
- !ruby/object:Gem::Dependency
|
|
79
79
|
name: rake
|
|
80
|
-
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
81
82
|
requirements:
|
|
82
83
|
- - ! '>='
|
|
83
84
|
- !ruby/object:Gem::Version
|
|
84
85
|
version: '0'
|
|
86
|
+
type: :development
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
89
|
none: false
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
90
|
requirements:
|
|
88
91
|
- - ! '>='
|
|
89
92
|
- !ruby/object:Gem::Version
|
|
90
93
|
version: '0'
|
|
91
|
-
none: false
|
|
92
|
-
prerelease: false
|
|
93
|
-
type: :development
|
|
94
94
|
- !ruby/object:Gem::Dependency
|
|
95
95
|
name: rspec
|
|
96
|
-
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
97
98
|
requirements:
|
|
98
99
|
- - ! '>='
|
|
99
100
|
- !ruby/object:Gem::Version
|
|
100
101
|
version: '0'
|
|
102
|
+
type: :development
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
101
105
|
none: false
|
|
102
|
-
requirement: !ruby/object:Gem::Requirement
|
|
103
106
|
requirements:
|
|
104
107
|
- - ! '>='
|
|
105
108
|
- !ruby/object:Gem::Version
|
|
106
109
|
version: '0'
|
|
107
|
-
none: false
|
|
108
|
-
prerelease: false
|
|
109
|
-
type: :development
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
111
|
name: guard-rspec
|
|
112
|
-
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
113
114
|
requirements:
|
|
114
115
|
- - ! '>='
|
|
115
116
|
- !ruby/object:Gem::Version
|
|
116
117
|
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
117
121
|
none: false
|
|
118
|
-
requirement: !ruby/object:Gem::Requirement
|
|
119
122
|
requirements:
|
|
120
123
|
- - ! '>='
|
|
121
124
|
- !ruby/object:Gem::Version
|
|
122
125
|
version: '0'
|
|
123
|
-
none: false
|
|
124
|
-
prerelease: false
|
|
125
|
-
type: :development
|
|
126
126
|
description: ''
|
|
127
127
|
email:
|
|
128
128
|
- splittingred@gmail.com
|
|
@@ -134,37 +134,38 @@ files:
|
|
|
134
134
|
- lib/gather.rb
|
|
135
135
|
- lib/kag/bot.rb
|
|
136
136
|
- lib/kag/config.rb
|
|
137
|
+
- lib/kag/data.rb
|
|
137
138
|
- lib/kag/gather.rb
|
|
138
139
|
- lib/kag/match.rb
|
|
140
|
+
- lib/kag/report.rb
|
|
139
141
|
- lib/kag/server.rb
|
|
140
142
|
- lib/kag/team.rb
|
|
141
143
|
- lib/kag/version.rb
|
|
144
|
+
- lib/patches.rb
|
|
142
145
|
- config/config.sample.json
|
|
143
146
|
homepage: https://github.com/splittingred/kag-gather
|
|
144
147
|
licenses:
|
|
145
148
|
- GPLv2
|
|
146
|
-
post_install_message:
|
|
149
|
+
post_install_message:
|
|
147
150
|
rdoc_options: []
|
|
148
151
|
require_paths:
|
|
149
152
|
- lib
|
|
150
153
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
|
+
none: false
|
|
151
155
|
requirements:
|
|
152
156
|
- - ! '>='
|
|
153
157
|
- !ruby/object:Gem::Version
|
|
154
158
|
version: 1.9.2
|
|
155
|
-
none: false
|
|
156
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
|
+
none: false
|
|
157
161
|
requirements:
|
|
158
162
|
- - ! '>='
|
|
159
163
|
- !ruby/object:Gem::Version
|
|
160
164
|
version: 1.3.6
|
|
161
|
-
none: false
|
|
162
165
|
requirements: []
|
|
163
|
-
rubyforge_project:
|
|
164
|
-
rubygems_version: 1.8.
|
|
165
|
-
signing_key:
|
|
166
|
+
rubyforge_project:
|
|
167
|
+
rubygems_version: 1.8.24
|
|
168
|
+
signing_key:
|
|
166
169
|
specification_version: 3
|
|
167
170
|
summary: KAG Gather IRC Bot
|
|
168
171
|
test_files: []
|
|
169
|
-
has_rdoc:
|
|
170
|
-
...
|