qwtf_discord_bot 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +16 -1
- data/bin/bundle +105 -0
- data/bin/coderay +29 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/pry +29 -0
- data/bin/qwtf_discord_bot +29 -0
- data/bin/restclient +29 -0
- data/bin/rspec +29 -0
- data/bin/thor +29 -0
- data/lib/qstat_request.rb +39 -36
- data/lib/qwtf_discord_bot/qwtf_discord_bot_watcher.rb +1 -1
- data/lib/qwtf_discord_bot/version.rb +1 -1
- data/lib/qwtf_discord_bot.rb +1 -0
- data/lib/roster.rb +19 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ebda1cd0b14e12fbf359e452f7f7874c97be6c8014d68a43d482ca4b347767b
|
4
|
+
data.tar.gz: f1e04bcd5653703d38d455f5d919902e70334d07c04542c2377ea9d06fe542ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95b5c0f1cbe59d2c8f5827d35c16271a8c2ab6f0ea545e7b580d8654df59a05ccea0c23a049b394015044ec93a24d375d3ff60ba0d2a776ccd721db122f354ac
|
7
|
+
data.tar.gz: c058065bb6e627164fdb7ddd3885e3d9a9301978d7ce578e9fe9084eb6732e424a85d4d8e6c7150518e1d554517f3171a8a43b900bc78bc3f9ecda761ba3b9ee
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
qwtf_discord_bot (1.0.
|
4
|
+
qwtf_discord_bot (1.0.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
activesupport (5.2.1)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 0.7, < 2)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
tzinfo (~> 1.1)
|
9
14
|
coderay (1.1.2)
|
15
|
+
concurrent-ruby (1.0.5)
|
10
16
|
diff-lcs (1.3)
|
11
17
|
discordrb (3.2.1)
|
12
18
|
discordrb-webhooks (~> 3.2.0.1)
|
@@ -19,13 +25,18 @@ GEM
|
|
19
25
|
domain_name (0.5.20180417)
|
20
26
|
unf (>= 0.0.5, < 1.0.0)
|
21
27
|
event_emitter (0.2.6)
|
28
|
+
factory_bot (4.11.0)
|
29
|
+
activesupport (>= 3.0.0)
|
22
30
|
ffi (1.9.25)
|
23
31
|
http-cookie (1.0.3)
|
24
32
|
domain_name (~> 0.5)
|
33
|
+
i18n (1.1.0)
|
34
|
+
concurrent-ruby (~> 1.0)
|
25
35
|
method_source (0.9.0)
|
26
36
|
mime-types (3.2.2)
|
27
37
|
mime-types-data (~> 3.2015)
|
28
38
|
mime-types-data (3.2018.0812)
|
39
|
+
minitest (5.11.3)
|
29
40
|
netrc (0.11.0)
|
30
41
|
opus-ruby (1.0.1)
|
31
42
|
ffi
|
@@ -52,6 +63,9 @@ GEM
|
|
52
63
|
rspec-support (~> 3.8.0)
|
53
64
|
rspec-support (3.8.0)
|
54
65
|
thor (0.20.0)
|
66
|
+
thread_safe (0.3.6)
|
67
|
+
tzinfo (1.2.5)
|
68
|
+
thread_safe (~> 0.1)
|
55
69
|
unf (0.1.4)
|
56
70
|
unf_ext
|
57
71
|
unf_ext (0.0.7.5)
|
@@ -66,6 +80,7 @@ PLATFORMS
|
|
66
80
|
DEPENDENCIES
|
67
81
|
bundler
|
68
82
|
discordrb
|
83
|
+
factory_bot
|
69
84
|
pry
|
70
85
|
qwtf_discord_bot!
|
71
86
|
rspec
|
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/coderay
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'coderay' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("coderay", "coderay")
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/pry
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'pry' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("pry", "pry")
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'qwtf_discord_bot' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("qwtf_discord_bot", "qwtf_discord_bot")
|
data/bin/restclient
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'restclient' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rest-client", "restclient")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/thor
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'thor' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("thor", "thor")
|
data/lib/qstat_request.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
class QstatRequest
|
2
|
+
attr_accessor :result
|
3
|
+
|
2
4
|
def initialize(endpoint)
|
3
5
|
@endpoint = endpoint
|
4
|
-
@data = fetch_data
|
5
6
|
end
|
6
7
|
|
7
|
-
def
|
8
|
-
@
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_message
|
12
|
-
return server_summary if is_empty?
|
13
|
-
[server_summary, player_table].join("\n")
|
8
|
+
def result
|
9
|
+
@result ||= execute
|
14
10
|
end
|
15
11
|
|
16
12
|
def to_embed
|
@@ -18,13 +14,18 @@ class QstatRequest
|
|
18
14
|
|
19
15
|
embed = Discordrb::Webhooks::Embed.new
|
20
16
|
|
21
|
-
teams.each do |
|
17
|
+
teams.each do |team|
|
22
18
|
embed.add_field(team.to_embed_field)
|
23
19
|
end
|
24
20
|
|
25
21
|
embed
|
26
22
|
end
|
27
23
|
|
24
|
+
def to_message
|
25
|
+
return server_summary if is_empty?
|
26
|
+
[server_summary, player_table].join("\n")
|
27
|
+
end
|
28
|
+
|
28
29
|
def server_summary
|
29
30
|
return "#{@endpoint} isn't responding" unless game_map
|
30
31
|
return "#{@endpoint} | #{game_map} | #{numplayers}/#{maxplayers}" unless has_spectators?
|
@@ -35,22 +36,30 @@ class QstatRequest
|
|
35
36
|
!has_players? && !has_spectators?
|
36
37
|
end
|
37
38
|
|
38
|
-
def has_spectators?
|
39
|
-
numspectators && numspectators > 0
|
40
|
-
end
|
41
|
-
|
42
|
-
def has_players?
|
43
|
-
numplayers && numplayers > 0
|
44
|
-
end
|
45
|
-
|
46
39
|
def player_names
|
47
40
|
players.map(&:name)
|
48
41
|
end
|
49
42
|
|
50
43
|
private
|
51
44
|
|
52
|
-
def
|
53
|
-
|
45
|
+
def has_spectators?
|
46
|
+
numspectators && numspectators > 0
|
47
|
+
end
|
48
|
+
|
49
|
+
def has_players?
|
50
|
+
numplayers && numplayers > 0
|
51
|
+
end
|
52
|
+
|
53
|
+
def teams
|
54
|
+
@teams ||= build_roster
|
55
|
+
end
|
56
|
+
|
57
|
+
def data
|
58
|
+
@data ||= JSON.parse(result).first
|
59
|
+
end
|
60
|
+
|
61
|
+
def execute
|
62
|
+
%x[qstat -json -P -qws #{@endpoint}]
|
54
63
|
end
|
55
64
|
|
56
65
|
def player_table
|
@@ -58,51 +67,45 @@ class QstatRequest
|
|
58
67
|
end
|
59
68
|
|
60
69
|
def address
|
61
|
-
|
70
|
+
data["address"]
|
62
71
|
end
|
63
72
|
|
64
73
|
def game_map
|
65
|
-
|
74
|
+
data["map"]
|
66
75
|
end
|
67
76
|
|
68
77
|
def numplayers
|
69
|
-
|
78
|
+
data["numplayers"]
|
70
79
|
end
|
71
80
|
|
72
81
|
def maxplayers
|
73
|
-
|
82
|
+
data["maxplayers"]
|
74
83
|
end
|
75
84
|
|
76
85
|
def numspectators
|
77
|
-
|
86
|
+
data["numspectators"]
|
78
87
|
end
|
79
88
|
|
80
89
|
def maxspectators
|
81
|
-
|
90
|
+
data["maxspectators"]
|
82
91
|
end
|
83
92
|
|
84
93
|
def build_roster
|
85
94
|
return nil if is_empty?
|
86
95
|
|
87
|
-
roster =
|
96
|
+
roster = Roster.new
|
88
97
|
|
89
|
-
|
98
|
+
data["players"].map do |player_data|
|
90
99
|
player = Player.new(player_data)
|
91
|
-
|
92
|
-
roster[team_name] ||= Team.new(team_name)
|
93
|
-
roster[team_name].enlist(player)
|
100
|
+
roster.enroll(player)
|
94
101
|
end
|
95
102
|
|
96
|
-
roster
|
103
|
+
roster.teams.sort_by { |team| team.number }
|
97
104
|
end
|
98
105
|
|
99
106
|
def players
|
100
|
-
|
107
|
+
data["players"].map do |player_data|
|
101
108
|
Player.new(player_data)
|
102
109
|
end
|
103
110
|
end
|
104
|
-
|
105
|
-
def players_from_team(team)
|
106
|
-
players.select { |player| player.team_name == team }.map(&:player_name)
|
107
|
-
end
|
108
111
|
end
|
@@ -6,7 +6,7 @@ class QwtfDiscordBotWatcher < QwtfDiscordBot
|
|
6
6
|
every(THIRTY_SECONDS) do
|
7
7
|
request = QstatRequest.new(endpoint)
|
8
8
|
|
9
|
-
|
9
|
+
unless request.is_empty?
|
10
10
|
request.player_names.each do |name|
|
11
11
|
unless seen_recently?(name)
|
12
12
|
report_joined(name: name, server_summary: request.server_summary)
|
data/lib/qwtf_discord_bot.rb
CHANGED
data/lib/roster.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Roster
|
2
|
+
attr_reader :teams
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@teams = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def enroll(player)
|
9
|
+
team_name = player.team
|
10
|
+
team = @teams.find { |team| team.name == team_name }
|
11
|
+
|
12
|
+
unless team
|
13
|
+
team = Team.new(team_name)
|
14
|
+
@teams << team
|
15
|
+
end
|
16
|
+
|
17
|
+
team.enlist(player)
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qwtf_discord_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sheldon Johnson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Discord bot for reporting on QuakeWorld Team Fortress game servers
|
14
14
|
email:
|
@@ -27,8 +27,17 @@ files:
|
|
27
27
|
- LICENSE.txt
|
28
28
|
- README.md
|
29
29
|
- Rakefile
|
30
|
+
- bin/bundle
|
31
|
+
- bin/coderay
|
30
32
|
- bin/console
|
33
|
+
- bin/htmldiff
|
34
|
+
- bin/ldiff
|
35
|
+
- bin/pry
|
36
|
+
- bin/qwtf_discord_bot
|
37
|
+
- bin/restclient
|
38
|
+
- bin/rspec
|
31
39
|
- bin/setup
|
40
|
+
- bin/thor
|
32
41
|
- emoji/blue_demoman.png
|
33
42
|
- emoji/blue_engineer.png
|
34
43
|
- emoji/blue_hwguy.png
|
@@ -55,6 +64,7 @@ files:
|
|
55
64
|
- lib/qwtf_discord_bot/qwtf_discord_bot_server.rb
|
56
65
|
- lib/qwtf_discord_bot/qwtf_discord_bot_watcher.rb
|
57
66
|
- lib/qwtf_discord_bot/version.rb
|
67
|
+
- lib/roster.rb
|
58
68
|
- lib/team.rb
|
59
69
|
- qwtf_discord_bot.gemspec
|
60
70
|
- server_screenshot.png
|