dblista 0.1.5 → 0.2.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.lock +1 -1
- data/lib/dblista.rb +2 -1
- data/lib/dblista/errors.rb +2 -0
- data/lib/dblista/helpers.rb +14 -0
- data/lib/dblista/info.rb +1 -1
- data/lib/dblista/list/bot.rb +1 -1
- data/lib/dblista/user/actions.rb +14 -0
- data/lib/dblista/user/client.rb +3 -1
- data/lib/dblista/user/notifications.rb +29 -0
- data/lib/dblista/user/verification.rb +43 -0
- data/lib/dblista/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa0b18a050a6369352d032a11be2497c207a8f16a4456c11aa2be79695d3738
|
4
|
+
data.tar.gz: c46e76121ccf62a37004db3c867f421d02ce12c4b0516a73e1d37e00f88cdc54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9940f8419b0c118ffb071640481ef77d87479e66cc0a723d9ff8f03a365207d4f419779b2cd77646309ac584b2f8e9ada0147a74bf3b1cd5db613a5839445b33
|
7
|
+
data.tar.gz: 8dea89026931f27610552e00dc2a008ee1a02df08777661964bfb244d90400d7e95b27cce6e7142bd64a3e9cc9258583823fa254e687baa3cb34141a0fd439ee
|
data/Gemfile.lock
CHANGED
data/lib/dblista.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'dblista/errors'
|
|
12
12
|
require_relative 'dblista/list/bot'
|
13
13
|
require_relative 'dblista/list/server'
|
14
14
|
require_relative 'dblista/user/client'
|
15
|
+
require_relative 'dblista/helpers'
|
15
16
|
|
16
17
|
# Main module
|
17
18
|
module DBLista
|
@@ -36,7 +37,7 @@ module DBLista
|
|
36
37
|
response = _https(uri).request(req)
|
37
38
|
result = JSON.parse response.body
|
38
39
|
raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
|
39
|
-
result
|
40
|
+
result['data']
|
40
41
|
end
|
41
42
|
|
42
43
|
# @!visibility private
|
data/lib/dblista/errors.rb
CHANGED
@@ -6,6 +6,8 @@ module DBLista::Errors
|
|
6
6
|
ID_NEEDED = 'You need to enter ID'
|
7
7
|
# Raised when provided page is not an integer
|
8
8
|
PAGE_INTEGER = 'Page must be an integer'
|
9
|
+
# Raised when rank is not an integer
|
10
|
+
RANK_INTEGER = 'Rank must be an integer'
|
9
11
|
# Raised when token is not provided
|
10
12
|
TOKEN_NOT_PROVIDED = 'Token is not provided'
|
11
13
|
# Raised when type symbol is invalid
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper methods
|
4
|
+
module DBLista::Helpers
|
5
|
+
# Crafts avatar url from user ID and avatar hash
|
6
|
+
#
|
7
|
+
# @param id [Integer] user ID
|
8
|
+
# @param hash [String] avatar hash
|
9
|
+
# @param size [Integer] avatar width (defaults to 2048)
|
10
|
+
# @return [Hash] raw data from DBLista
|
11
|
+
def self.get_avatar(id, hash, size = 2048)
|
12
|
+
"https://cdn.discordapp.com/avatars/#{id}/#{hash}?size=#{size}"
|
13
|
+
end
|
14
|
+
end
|
data/lib/dblista/info.rb
CHANGED
data/lib/dblista/list/bot.rb
CHANGED
data/lib/dblista/user/actions.rb
CHANGED
@@ -40,5 +40,19 @@ module DBLista::User
|
|
40
40
|
|
41
41
|
DBLista._delete("/#{type}s/#{id}", nil, @token)
|
42
42
|
end
|
43
|
+
|
44
|
+
# Manages user (bans or adds premium)
|
45
|
+
# Available only for DBLista staff
|
46
|
+
#
|
47
|
+
# @param id [Integer] user ID
|
48
|
+
# @param banned [Boolean] user ban status
|
49
|
+
# @param premium [Integer] days for premium
|
50
|
+
# @return [Hash] raw data from DBLista
|
51
|
+
def manage_user(id, banned = false, premium = 0)
|
52
|
+
DBLista._post("/users/#{id}/manage", {
|
53
|
+
premium: premium,
|
54
|
+
ban: banned
|
55
|
+
}, @token)
|
56
|
+
end
|
43
57
|
end
|
44
58
|
end
|
data/lib/dblista/user/client.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative './boosting'
|
|
5
5
|
require_relative './rating'
|
6
6
|
require_relative './voting'
|
7
7
|
require_relative './notifications'
|
8
|
+
require_relative './verification'
|
8
9
|
|
9
10
|
# User module - client + client modules
|
10
11
|
module DBLista::User
|
@@ -23,6 +24,7 @@ module DBLista::User
|
|
23
24
|
include DBLista::User::Boosting
|
24
25
|
include DBLista::User::Rating
|
25
26
|
include DBLista::User::Notifications
|
27
|
+
include DBLista::User::Verification
|
26
28
|
|
27
29
|
# Allowed entity types to use
|
28
30
|
ALLOWED_TYPES = %i[bot server].freeze
|
@@ -34,7 +36,7 @@ module DBLista::User
|
|
34
36
|
|
35
37
|
@token = token
|
36
38
|
|
37
|
-
|
39
|
+
me
|
38
40
|
end
|
39
41
|
|
40
42
|
# Fetches information about current user
|
@@ -16,5 +16,34 @@ module DBLista::User
|
|
16
16
|
def clear_notifications
|
17
17
|
DBLista._get('/users/me/notifications/clear', @token)
|
18
18
|
end
|
19
|
+
|
20
|
+
# Sends notification to specified user
|
21
|
+
# Available only for DBLista staff
|
22
|
+
#
|
23
|
+
# @param rank [Integer] user ID
|
24
|
+
# @param details [String] details (content)
|
25
|
+
# @param url [String] url to redirect if clicked
|
26
|
+
# @return [Hash] raw data from DBLista
|
27
|
+
def send_notification(id, details, url = '#')
|
28
|
+
DBLista._validate_id id
|
29
|
+
DBLista._post("/users/#{id}/notifications", {
|
30
|
+
text: details,
|
31
|
+
url: url || '#'
|
32
|
+
}, @token)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sends notification to specified group (rank)
|
36
|
+
# Available only for DBLista staff
|
37
|
+
#
|
38
|
+
# @param rank [Integer] rank ID
|
39
|
+
# @param details [String] details (content)
|
40
|
+
# @param url [String] url to redirect if clicked
|
41
|
+
# @return [Hash] raw data from DBLista
|
42
|
+
def send_group_notification(rank, details, url = '#')
|
43
|
+
DBLista._post("/users/group/#{rank}/notifications", {
|
44
|
+
text: details,
|
45
|
+
url: url || '#'
|
46
|
+
}, @token)
|
47
|
+
end
|
19
48
|
end
|
20
49
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module DBLista::User
|
6
|
+
# User client - verification (only for staff)
|
7
|
+
module Verification
|
8
|
+
# Approves specified bot
|
9
|
+
#
|
10
|
+
# @param id [Integer] bot ID
|
11
|
+
# @param reason [String] reason for approving
|
12
|
+
# @return [Boolean] true if operation succeded
|
13
|
+
def approve(id, reason = 'Brak powodu')
|
14
|
+
DBLista._validate_id id
|
15
|
+
|
16
|
+
DBLista._post("/bots/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
# Rejects specified bot
|
21
|
+
#
|
22
|
+
# @param id [Integer] bot ID
|
23
|
+
# @param reason [String] reason for rejecting
|
24
|
+
# @return [Boolean] true if operation succeded
|
25
|
+
def reject(id, reason = 'Brak powodu')
|
26
|
+
DBLista._validate_id id
|
27
|
+
|
28
|
+
DBLista._post("/bots/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
# Sets specified bot verification status to pending
|
33
|
+
#
|
34
|
+
# @param id [Integer] bot ID
|
35
|
+
# @return [Boolean] true if operation succeded
|
36
|
+
def set_pending(id)
|
37
|
+
DBLista._validate_id id
|
38
|
+
|
39
|
+
DBLista._post("/bots/#{id}/set-pending", nil, @token)
|
40
|
+
true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/dblista/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dblista
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- deepivin
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- example/info.rb
|
72
72
|
- lib/dblista.rb
|
73
73
|
- lib/dblista/errors.rb
|
74
|
+
- lib/dblista/helpers.rb
|
74
75
|
- lib/dblista/info.rb
|
75
76
|
- lib/dblista/list/bot.rb
|
76
77
|
- lib/dblista/list/server.rb
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- lib/dblista/user/client.rb
|
81
82
|
- lib/dblista/user/notifications.rb
|
82
83
|
- lib/dblista/user/rating.rb
|
84
|
+
- lib/dblista/user/verification.rb
|
83
85
|
- lib/dblista/user/voting.rb
|
84
86
|
- lib/dblista/version.rb
|
85
87
|
homepage: https://github.com/marek12306/dblista-wrapper-ruby
|