topgg 1.0.3 → 1.0.4
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.
- checksums.yaml +4 -4
- data/lib/lib.rb +9 -9
- data/topgg.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbdd8160537319a98455be19d2e3ad6d0691d6a3508d56dd6688f356879eb6c0
|
|
4
|
+
data.tar.gz: 077e57202742fc1d871e35fcb2f91ec226d60b8b317d1d10964f17a8a9aa57e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b9e65d4ff9ab1b84d6300a3fea75e941de62496a7cbb1d3030773e1427cd2c77359a1ed141a14aa7b65bed93e12e2b774abc3f629146e9fe0b4737eb4d745c95
|
|
7
|
+
data.tar.gz: ea5d810c1e3a57b781fbefd4f83085484d01f454346135852c5906f0b1984eda9bc9766c958e43ea57be4786998f093094775cb2eb87cbca8a91ebbca2336f14
|
data/lib/lib.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'faraday'
|
|
3
4
|
require 'json'
|
|
4
5
|
require_relative 'topgg/bot'
|
|
@@ -80,23 +81,23 @@ class Topgg
|
|
|
80
81
|
# @param shards [Integer] The amount of servers the bot is in per shard
|
|
81
82
|
# @param shard_count [Integer] The total number of shards.
|
|
82
83
|
def post_stats(server_count, shards: nil, shard_count: nil)
|
|
83
|
-
|
|
84
|
+
json_post = {
|
|
84
85
|
server_count: server_count,
|
|
85
86
|
shards: shards,
|
|
86
87
|
shard_count: shard_count
|
|
87
88
|
}.to_json
|
|
88
|
-
@conn.post("bots/#{@id}/stats",
|
|
89
|
+
@conn.post("bots/#{@id}/stats", json_post, { 'Content-Type' => 'application/json' })
|
|
89
90
|
end
|
|
90
91
|
|
|
91
|
-
#
|
|
92
|
+
# Auto-posts stats on to the top.gg website
|
|
92
93
|
# @param client [Discordrb::Bot] instanceof discordrb client.
|
|
93
94
|
def auto_post_stats(client)
|
|
94
95
|
semaphore = Mutex.new
|
|
95
96
|
Thread.new do
|
|
96
97
|
semaphore.synchronize do
|
|
97
98
|
interval 1800 do
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
server_len = client.servers.length
|
|
100
|
+
post_stats(server_len)
|
|
100
101
|
print("[TOPGG] : \033[31;1;4m Bot statistics has been successfully posted!\033[0m")
|
|
101
102
|
end
|
|
102
103
|
end
|
|
@@ -104,16 +105,15 @@ class Topgg
|
|
|
104
105
|
end
|
|
105
106
|
|
|
106
107
|
# Mini-method to get statistics on self
|
|
107
|
-
# @return [
|
|
108
|
+
# @return [get_bot]
|
|
108
109
|
def self
|
|
109
|
-
|
|
110
|
+
get_bot(@id)
|
|
110
111
|
end
|
|
111
112
|
|
|
112
113
|
def interval(seconds)
|
|
113
114
|
loop do
|
|
114
115
|
yield
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
sleep seconds
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
end
|
data/topgg.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: topgg
|
|
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
|
- Adonis Tremblay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-08-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: This is a ruby library of the top.gg API.
|
|
14
14
|
email:
|