topgg 1.0.5 → 1.1.0
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/Gemfile +0 -1
- data/LICENSE +21 -0
- data/README.md +23 -11
- data/lib/lib.rb +21 -23
- data/lib/topgg/bot.rb +3 -1
- data/lib/topgg/botSearch.rb +5 -1
- data/lib/topgg/stats.rb +4 -1
- data/lib/topgg/user.rb +4 -1
- data/lib/topgg/votes.rb +4 -1
- data/topgg.gemspec +1 -1
- metadata +4 -7
- data/.bundle/config +0 -2
- data/CHANGELOG.md +0 -5
- data/pkg/topgg-1.0.1.gem +0 -0
- data/pkg/topgg-1.0.2.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: efdefad75123d5205da0ca899e47fe4f3c0c3a3269b7dfd7a68697f206bf36ec
|
|
4
|
+
data.tar.gz: 99703e90fe21baa924be88ea389ddf0bfb8a90e2580ef29138e350784feab723
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a31882f04bd664e714198254b4338fe5d8c68503fba6b0ae83f71d0e36dff130052c6f9c06dfd9eeef8c0abd384e750173f359a84746d73819d3083397cfad0b
|
|
7
|
+
data.tar.gz: 3f70900291e2d8fe4f7a574eda247281bb4f7e295286cea11f256f2648348e67c9d48aa7ba4966cef3ccefe6f8bd78c538840cdea4ceac49f509dd3c3ffcf323
|
data/Gemfile
CHANGED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 rhydderchc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
# Top.gg Ruby
|
|
1
|
+
# [Top.gg](https://top.gg) Ruby
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Top.gg Ruby SDK is a lighweight package, that allows you
|
|
4
4
|
to fetch data from the top.gg api and post data such as statistics to the website.
|
|
5
5
|
|
|
6
|
+
It provides you with numerous methods to interact with the API.
|
|
6
7
|
## Dependencies
|
|
7
8
|
|
|
8
9
|
* Ruby
|
|
9
|
-
* Faraday (The client to automate requests)
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
|
+
``` bash
|
|
13
14
|
|
|
15
|
+
gem install topgg
|
|
14
16
|
|
|
17
|
+
```
|
|
18
|
+
## Note
|
|
19
|
+
|
|
20
|
+
You require a Token to interact with the Api.
|
|
21
|
+
The token can be found at `https://top.gg/bot/[YOUR_BOT_ID]/webhooks`
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+

|
|
15
25
|
## Example
|
|
16
26
|
|
|
17
27
|
Here's a straightforward example of how to request data with the wrapper.
|
|
@@ -21,27 +31,29 @@ require 'topgg'
|
|
|
21
31
|
|
|
22
32
|
client = Topgg.new("AUTH_TOKEN", "BOTID")
|
|
23
33
|
|
|
24
|
-
client.
|
|
34
|
+
client.get_bot("1234").defAvatar
|
|
25
35
|
# returns
|
|
26
36
|
# "6debd47ed13483642cf09e832ed0bc1b"
|
|
27
37
|
|
|
28
38
|
```
|
|
29
|
-
###
|
|
39
|
+
### Auto Posting
|
|
30
40
|
|
|
31
|
-
The
|
|
32
|
-
|
|
33
|
-
Here's how you can enable it
|
|
41
|
+
The library provides you with autoposting functionality, and autoposts at an interval of 30 minutes.
|
|
42
|
+
Here's how you can use it
|
|
34
43
|
|
|
35
44
|
```ruby
|
|
36
45
|
require 'topgg'
|
|
37
46
|
require 'discordrb'
|
|
38
47
|
|
|
39
48
|
bot = Discordrb::Bot.new token: "TOKEN"
|
|
40
|
-
client = Topgg.new("AUTH_TOKEN", "BOTID")
|
|
41
49
|
|
|
42
|
-
client.
|
|
50
|
+
client = Topgg.new("AUTH_TOKEN", "BOTID")
|
|
51
|
+
bot.ready do |event|
|
|
52
|
+
client.auto_post_stats(bot) # The discordrb bot client.
|
|
53
|
+
end
|
|
54
|
+
bot.run
|
|
43
55
|
```
|
|
44
56
|
|
|
45
57
|
# Documentation
|
|
46
58
|
|
|
47
|
-
Check out the
|
|
59
|
+
Check out the api reference [here](https://rubydoc.info/gems/topgg/)
|
data/lib/lib.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require_relative 'topgg/utils/request'
|
|
4
4
|
require 'json'
|
|
5
5
|
require_relative 'topgg/bot'
|
|
6
6
|
require_relative 'topgg/botSearch'
|
|
@@ -16,64 +16,61 @@ class Topgg
|
|
|
16
16
|
def initialize(token, id)
|
|
17
17
|
@id = id
|
|
18
18
|
@token = token
|
|
19
|
-
@
|
|
20
|
-
url: 'https://top.gg/api',
|
|
21
|
-
headers: { 'authorization' => @token }
|
|
22
|
-
)
|
|
19
|
+
@request = Dbl::Utils::Request.new(token)
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
# The method fetches bot statistics from top.gg
|
|
26
23
|
# @param id [String] The id of the bot you want to fetch statistics from.
|
|
27
|
-
# @return [
|
|
24
|
+
# @return [Dbl::Bot] The Bot Object
|
|
28
25
|
def get_bot(id)
|
|
29
|
-
resp = @
|
|
26
|
+
resp = @request.get("bots/#{id}")
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
Dbl::Bot.new(resp)
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
# The method searches bots from top.gg using a keyword query.
|
|
35
32
|
# @param [Object] params The parameters that can be used to query a search
|
|
36
33
|
# To know what the parameters are check it out here
|
|
37
|
-
# @return [
|
|
34
|
+
# @return [Dbl::BotSearch] The BotSearch Object
|
|
38
35
|
def search_bot(params)
|
|
39
|
-
resp = @
|
|
40
|
-
|
|
36
|
+
resp = @request.get('bots/search', params)
|
|
37
|
+
Dbl::BotSearch.new(resp)
|
|
41
38
|
end
|
|
42
39
|
|
|
43
40
|
# Search for a user on top.gg with id
|
|
44
41
|
# @param id [String] The id of the user to search for.
|
|
45
|
-
# @return [
|
|
42
|
+
# @return [Dbl::User]
|
|
46
43
|
def user(id)
|
|
47
|
-
resp = @
|
|
44
|
+
resp = @request.get("users/#{id}")
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
Dbl::User.new(resp)
|
|
50
47
|
end
|
|
51
48
|
|
|
52
49
|
# Get Bot statistics.
|
|
53
50
|
# @param id [String] Id of the bot you want to get statistics of
|
|
54
|
-
# @return [
|
|
51
|
+
# @return [Dbl::Stats]
|
|
55
52
|
def get_stats(id)
|
|
56
|
-
resp = @
|
|
53
|
+
resp = @request.get("bots/#{id}/stats")
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
Dbl::Stats.new(resp)
|
|
59
56
|
end
|
|
60
57
|
|
|
61
58
|
# Mini-method to query if the bot(self) was voted by the user.
|
|
62
59
|
# @param userid [String] The user id.
|
|
63
60
|
# @return [Boolean]
|
|
64
61
|
def voted?(userid)
|
|
65
|
-
resp = @
|
|
62
|
+
resp = @request.get("bots/#{@id}/check", { userId: userid })
|
|
66
63
|
|
|
67
|
-
ret =
|
|
64
|
+
ret = resp
|
|
68
65
|
ret['voted'] == 1
|
|
69
66
|
end
|
|
70
67
|
|
|
71
68
|
# Get the Last 1000 votes of the bot(self)
|
|
72
|
-
# @return [
|
|
69
|
+
# @return [Dbl::Votes]
|
|
73
70
|
def votes
|
|
74
|
-
resp = @
|
|
71
|
+
resp = @request.get("bots/#{@id}/votes")
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
Dbl::Votes.new(resp)
|
|
77
74
|
end
|
|
78
75
|
|
|
79
76
|
# Post Bot Statistics to the website
|
|
@@ -86,7 +83,7 @@ class Topgg
|
|
|
86
83
|
shards: shards,
|
|
87
84
|
shard_count: shard_count
|
|
88
85
|
}.to_json
|
|
89
|
-
@
|
|
86
|
+
@request.post("bots/#{@id}/stats", json_post, { 'Content-Type' => 'application/json' })
|
|
90
87
|
end
|
|
91
88
|
|
|
92
89
|
# Auto-posts stats on to the top.gg website
|
|
@@ -120,3 +117,4 @@ end
|
|
|
120
117
|
|
|
121
118
|
|
|
122
119
|
|
|
120
|
+
|
data/lib/topgg/bot.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Dbl
|
|
2
2
|
# The Bot class spreads the json parsed hash into different methods
|
|
3
3
|
class Bot
|
|
4
4
|
# Initializes the Bot class
|
|
@@ -11,6 +11,8 @@ module Spreader
|
|
|
11
11
|
attr_reader :obj
|
|
12
12
|
|
|
13
13
|
alias :raw :obj
|
|
14
|
+
|
|
15
|
+
alias data obj
|
|
14
16
|
# Returns error message, if there's an error
|
|
15
17
|
# @return [String]
|
|
16
18
|
def error
|
data/lib/topgg/botSearch.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
module
|
|
2
|
+
module Dbl
|
|
3
3
|
# This class spreads the BotSearch Response body into different methods
|
|
4
4
|
class BotSearch
|
|
5
5
|
# Initalizes the BotSearch class
|
|
@@ -10,6 +10,10 @@ module Spreader
|
|
|
10
10
|
# Get raw hash response
|
|
11
11
|
# @return [Hash]
|
|
12
12
|
attr_reader :obj
|
|
13
|
+
|
|
14
|
+
alias raw obj
|
|
15
|
+
|
|
16
|
+
alias data obj
|
|
13
17
|
|
|
14
18
|
# The Total number of results
|
|
15
19
|
# @return [Integer]
|
data/lib/topgg/stats.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Dbl
|
|
2
2
|
# The Stats class spreads the json response into different methods
|
|
3
3
|
class Stats
|
|
4
4
|
# Initializes the Stats class
|
|
@@ -9,7 +9,10 @@ module Spreader
|
|
|
9
9
|
|
|
10
10
|
# Returns raw Hash of the response
|
|
11
11
|
attr_reader :obj
|
|
12
|
+
|
|
13
|
+
alias raw obj
|
|
12
14
|
|
|
15
|
+
alias data obj
|
|
13
16
|
# Returns the server Count of the bot
|
|
14
17
|
# @return [Integer]
|
|
15
18
|
def server_count
|
data/lib/topgg/user.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
module
|
|
2
|
+
module Dbl
|
|
3
3
|
# The User class, used for Spreading the response body into different methods
|
|
4
4
|
class User
|
|
5
5
|
# Instantiates the class variables
|
|
@@ -10,6 +10,9 @@ module Spreader
|
|
|
10
10
|
|
|
11
11
|
attr_reader :obj
|
|
12
12
|
|
|
13
|
+
alias raw obj
|
|
14
|
+
|
|
15
|
+
alias data obj
|
|
13
16
|
# Check for errors, if any
|
|
14
17
|
def error
|
|
15
18
|
@obj['error']
|
data/lib/topgg/votes.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module Dbl
|
|
2
2
|
# This class Spreads the Vote response body into different methods.
|
|
3
3
|
class Votes
|
|
4
4
|
# Initializes the votes class
|
|
@@ -10,7 +10,10 @@ module Spreader
|
|
|
10
10
|
# Get raw hash return of the object
|
|
11
11
|
# @return [Hash]
|
|
12
12
|
attr_reader :obj
|
|
13
|
+
|
|
14
|
+
alias raw obj
|
|
13
15
|
|
|
16
|
+
alias data obj
|
|
14
17
|
# Get the first vote amongst all the other votes.
|
|
15
18
|
# @return [Spreader::User]
|
|
16
19
|
def first
|
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.1.0
|
|
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-10-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: This is a ruby library of the top.gg API.
|
|
14
14
|
email:
|
|
@@ -17,9 +17,8 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
-
- ".bundle/config"
|
|
21
|
-
- CHANGELOG.md
|
|
22
20
|
- Gemfile
|
|
21
|
+
- LICENSE
|
|
23
22
|
- LICENSE.txt
|
|
24
23
|
- README.md
|
|
25
24
|
- Rakefile
|
|
@@ -29,8 +28,6 @@ files:
|
|
|
29
28
|
- lib/topgg/stats.rb
|
|
30
29
|
- lib/topgg/user.rb
|
|
31
30
|
- lib/topgg/votes.rb
|
|
32
|
-
- pkg/topgg-1.0.1.gem
|
|
33
|
-
- pkg/topgg-1.0.2.gem
|
|
34
31
|
- topgg.gemspec
|
|
35
32
|
homepage: https://github.com/rhydderchc/topgg-ruby
|
|
36
33
|
licenses:
|
|
@@ -55,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
52
|
- !ruby/object:Gem::Version
|
|
56
53
|
version: '0'
|
|
57
54
|
requirements: []
|
|
58
|
-
rubygems_version: 3.
|
|
55
|
+
rubygems_version: 3.2.22
|
|
59
56
|
signing_key:
|
|
60
57
|
specification_version: 4
|
|
61
58
|
summary: A top.gg api wrapper for ruby.
|
data/.bundle/config
DELETED
data/CHANGELOG.md
DELETED
data/pkg/topgg-1.0.1.gem
DELETED
|
Binary file
|
data/pkg/topgg-1.0.2.gem
DELETED
|
Binary file
|