dblista 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b662a5b156e72ac37ec051e1bffb77587db382a8ded509544cd0fd67b56242b0
4
- data.tar.gz: 1622b294e66a1977e63b7f60b758643b961907d895ec2884781ab3780a8b9076
3
+ metadata.gz: 64fc43df32a990398b6458027722e311e3a953ff86b8a74c1fcd7b22b56d2e9e
4
+ data.tar.gz: '08742f7663b94d42380230a24970308a08b2ffd5ea568d7ce206a7b38f37358b'
5
5
  SHA512:
6
- metadata.gz: 26852865ee9ac0534f350da349872f5ab6f97329017b0c34eec7779e7aa5a87242829dfba29cb14aff6240f1d779c3051eba962792372f52141c52c99a51dcaa
7
- data.tar.gz: 02cdea3a50877b4f53c112648a40df8b35db33e4a6c5263d7fd9a9bf70b10fdcd8f897caf92c8f170385fe5bc79b485585c6ad3ed89286daeaf2dcfef9743314
6
+ metadata.gz: d3cfacb8fde02926253748c70a464d8adf34173f183865c94065b913168b37a2fe78714b129d6aafa9d7322bf2721b52316c17261be00f1859cd8ff105780c8b
7
+ data.tar.gz: 9097d31284237736b01860e4607af78c4bf60f0accff073f2b8a34dc4e260ba3d260a631ed4179f44f0e3f65dc946ae62dff899e64c996af8160ef8299cc5a1a
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ UWAGA: Gem ten nie jest już rozwijany. Nie odpowiadam za żadne błędy wywołane tym gemem.
2
+ -------------------------------------
1
3
  # DList (kiedyś DBLista) Ruby wrapper [![Gem Version](https://badge.fury.io/rb/dblista.svg)](https://badge.fury.io/rb/dblista)
2
4
 
3
5
  [Dokumentacja](https://www.rubydoc.info/github/marek12306/dblista-wrapper-ruby)
@@ -33,13 +35,13 @@ Automatyczne statystyki:
33
35
 
34
36
  ```ruby
35
37
  bot = Discordrb::Bot.new token: 'TOKEN'
36
- dbl = DBLista::Stats.new 'DBLISTA_TOKEN', bot
38
+ dbl = DList::Stats.new 'DLIST_TOKEN', bot
37
39
  ```
38
40
 
39
41
  Pobieranie topki botów:
40
42
 
41
43
  ```ruby
42
- top = DBLista::List::Bot.top
44
+ top = DList::List::Bot.top
43
45
  puts top
44
46
  ```
45
47
 
File without changes
@@ -5,7 +5,7 @@ require "dblista/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "dblista"
8
- spec.version = DBLista::VERSION
8
+ spec.version = DList::VERSION
9
9
  spec.authors = ["deepivin"]
10
10
  spec.email = ["marek12306@gmail.com"]
11
11
 
@@ -2,7 +2,7 @@ require 'dblista'
2
2
  require 'discordrb'
3
3
 
4
4
  bot = Discordrb::Bot.new token: 'TOKEN'
5
- dbl = DBLista::Stats.new 'DBLISTA_TOKEN', bot
5
+ dbl = DList::Stats.new 'DList_TOKEN', bot
6
6
 
7
7
  bot.message(content: 'Ping!') do |event|
8
8
  event.respond 'Pong!'
@@ -1,14 +1,14 @@
1
1
  require 'dblista'
2
2
 
3
- client = DBLista::User::Client.new('TOKEN')
3
+ client = DList::User::Client.new('TOKEN')
4
4
 
5
5
  client.add({
6
6
  id: 'id',
7
7
  info: {
8
8
  library: 'NiceBot',
9
9
  tags: [
10
- DBLista::Tags::Bot::FUN,
11
- DBLista::Tags::Bot::TOOLS
10
+ DList::Tags::Bot::FUN,
11
+ DList::Tags::Bot::TOOLS
12
12
  ],
13
13
  prefix: '!',
14
14
  fullDescription: 'long description',
@@ -1,5 +1,5 @@
1
1
  require 'dblista'
2
2
 
3
- DBLista::List::Bot.all.each do |server|
3
+ DList::List::Bot.all.each do |server|
4
4
  puts server['name']
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'dblista'
2
2
 
3
- client = DBLista::User::Client.new('TOKEN')
3
+ client = DList::User::Client.new('TOKEN')
4
4
 
5
5
  puts client.notifications
6
6
  client.clear_notifications
@@ -1,5 +1,5 @@
1
1
  require 'dblista'
2
2
 
3
- results = DBLista::List::Bot.search(DBLista::Tags::Bot::MUSIC)
3
+ results = DList::List::Bot.search(DList::Tags::Bot::MUSIC)
4
4
 
5
5
  puts results
@@ -1,5 +1,5 @@
1
1
  require 'dblista'
2
2
 
3
- user = DBLista::Information.user('ID')
3
+ user = DList::Information.user('ID')
4
4
 
5
- puts DBLista::Helpers.get_avatar(user['id'], user['avatar'], 1024)
5
+ puts DList::Helpers.get_avatar(user['id'], user['avatar'], 1024)
@@ -17,8 +17,8 @@ require_relative 'dblista/helpers'
17
17
  require_relative 'dblista/constants'
18
18
 
19
19
  # Main module
20
- module DBLista
21
- # DBLista error class
20
+ module DList
21
+ # DList error class
22
22
  class Error < StandardError; end
23
23
  # API path prefix
24
24
  API_PATH = 'https://api.dlist.top/v1'
@@ -43,55 +43,55 @@ module DBLista
43
43
  req['Authorization'] = token if token
44
44
  response = _https(uri).request(req)
45
45
  result = JSON.parse response.body
46
- raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
46
+ raise DList::Error, result['error'].capitalize unless result['status'] == 'success'
47
47
 
48
48
  result['data']
49
49
  end
50
50
 
51
51
  # @!visibility private
52
52
  def self._get(path, token = nil)
53
- uri = URI("#{DBLista::API_PATH}#{path}")
53
+ uri = URI("#{DList::API_PATH}#{path}")
54
54
  req = Net::HTTP::Get.new(uri)
55
55
  _handle_request(req, uri, token, nil)
56
56
  end
57
57
 
58
58
  # @!visibility private
59
59
  def self._post(path, data = nil, token = nil)
60
- uri = URI("#{DBLista::API_PATH}#{path}")
60
+ uri = URI("#{DList::API_PATH}#{path}")
61
61
  req = Net::HTTP::Post.new(uri)
62
62
  _handle_request(req, uri, token, data)
63
63
  end
64
64
 
65
65
  # @!visibility private
66
66
  def self._delete(path, data = nil, token = nil)
67
- uri = URI("#{DBLista::API_PATH}#{path}")
67
+ uri = URI("#{DList::API_PATH}#{path}")
68
68
  req = Net::HTTP::Delete.new(uri)
69
69
  _handle_request(req, uri, token, data)
70
70
  end
71
71
 
72
72
  # @!visibility private
73
73
  def self._put(path, data = nil, token = nil)
74
- uri = URI("#{DBLista::API_PATH}#{path}")
74
+ uri = URI("#{DList::API_PATH}#{path}")
75
75
  req = Net::HTTP::Put.new(uri)
76
76
  _handle_request(req, uri, token, data)
77
77
  end
78
78
 
79
79
  # @!visibility private
80
80
  def self._validate_id(id)
81
- raise DBLista::Error, DBLista::Errors::ID_NEEDED unless DBLista::IS_NUMBER.match?(id.to_s)
81
+ raise DList::Error, DList::Errors::ID_NEEDED unless DList::IS_NUMBER.match?(id.to_s)
82
82
  end
83
83
 
84
84
  # @!visibility private
85
85
  def self._page_integer(input)
86
- raise DBLista::Error, DBLista::Errors::PAGE_INTEGER unless input.is_a?(Integer)
86
+ raise DList::Error, DList::Errors::PAGE_INTEGER unless input.is_a?(Integer)
87
87
  end
88
88
 
89
89
  # @!visibility private
90
90
  def self._limit_integer(input)
91
- raise DBLista::Error, DBLista::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
91
+ raise DList::Error, DList::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
92
92
  end
93
93
 
94
94
  def self._cache(name)
95
- DBLista::Cache.get(name.to_sym, lifetime: DBLista::CACHE_LIFETIME) { yield }
95
+ DList::Cache.get(name.to_sym, lifetime: DList::CACHE_LIFETIME) { yield }
96
96
  end
97
97
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista
3
+ module DList
4
4
  # Tags
5
5
  module Tags
6
6
  # Bot tags
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Error messages
4
- module DBLista::Errors
4
+ module DList::Errors
5
5
  # Raised when ID is not provided
6
6
  ID_NEEDED = 'You need to enter ID'
7
7
  # Raised when provided page is not an integer
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Helper methods
4
- module DBLista::Helpers
4
+ module DList::Helpers
5
5
  # Crafts avatar url from user ID and avatar hash
6
6
  #
7
7
  # @param id [Integer] user ID
8
8
  # @param hash [String] avatar hash
9
9
  # @param size [Integer] avatar width (defaults to 2048)
10
- # @return [Hash] raw data from DBLista
10
+ # @return [Hash] raw data from DList
11
11
  def self.get_avatar(id, hash, size = 2048)
12
12
  "https://cdn.discordapp.com/avatars/#{id}/#{hash}?size=#{size}"
13
13
  end
@@ -3,43 +3,43 @@
3
3
  require 'open-uri'
4
4
  require 'json'
5
5
 
6
- module DBLista
6
+ module DList
7
7
  # Bot/server/user detailed information
8
8
  #
9
- # @example Checking DBLista user information
10
- # info = DBLista::Information.user 123456789012345678
9
+ # @example Checking DList user information
10
+ # info = DList::Information.user 123456789012345678
11
11
  # puts info
12
12
  module Information
13
- # Fetches DBLista bot information
13
+ # Fetches DList bot information
14
14
  #
15
15
  # @param id [Integer] bot ID
16
- # @return [Hash] raw data from DBLista
16
+ # @return [Hash] raw data from DList
17
17
  def self.bot(id)
18
- DBLista._validate_id id
19
- DBLista._cache(id.to_s.to_sym) do
20
- DBLista._get("/bots/#{id}")
18
+ DList._validate_id id
19
+ DList._cache(id.to_s.to_sym) do
20
+ DList._get("/bots/#{id}")
21
21
  end
22
22
  end
23
23
 
24
- # Fetches DBLista server information
24
+ # Fetches DList server information
25
25
  #
26
26
  # @param id [Integer] server ID
27
- # @return [Hash] raw data from DBLista
27
+ # @return [Hash] raw data from DList
28
28
  def self.server(id)
29
- DBLista._validate_id id
30
- DBLista._cache(id.to_s.to_sym) do
31
- DBLista._get("/servers/#{id}")
29
+ DList._validate_id id
30
+ DList._cache(id.to_s.to_sym) do
31
+ DList._get("/servers/#{id}")
32
32
  end
33
33
  end
34
34
 
35
- # Fetches DBLista user information
35
+ # Fetches DList user information
36
36
  #
37
37
  # @param id [Integer] user ID
38
- # @return [Hash] raw data from DBLista
38
+ # @return [Hash] raw data from DList
39
39
  def self.user(id)
40
- DBLista._validate_id id
41
- DBLista._cache(id.to_s.to_sym) do
42
- DBLista._get("/users/#{id}")
40
+ DList._validate_id id
41
+ DList._cache(id.to_s.to_sym) do
42
+ DList._get("/users/#{id}")
43
43
  end
44
44
  end
45
45
  end
@@ -7,21 +7,21 @@ require 'cgi'
7
7
  # Lists
8
8
  #
9
9
  # @example Fetch top 25 bots
10
- # top = DBLista::List::Bot.top
10
+ # top = DList::List::Bot.top
11
11
  # puts top
12
- module DBLista::List
12
+ module DList::List
13
13
  # Bot lists
14
14
  module Bot
15
15
  # Fetches top bots
16
16
  #
17
17
  # @param page [Integer] page
18
18
  # @param limit [Integer] limit of bots per page
19
- # @return [Hash] raw data from DBLista
19
+ # @return [Hash] raw data from DList
20
20
  def self.top(page = 0, limit = 10)
21
- DBLista._page_integer page
22
- DBLista._limit_integer limit
23
- DBLista._cache("botstop#{page}-#{limit}") do
24
- DBLista._get("/bots/list/top/#{page}?limit=#{limit}")
21
+ DList._page_integer page
22
+ DList._limit_integer limit
23
+ DList._cache("botstop#{page}-#{limit}") do
24
+ DList._get("/bots/list/top/#{page}?limit=#{limit}")
25
25
  end
26
26
  end
27
27
 
@@ -29,51 +29,51 @@ module DBLista::List
29
29
  #
30
30
  # @param page [Integer] page
31
31
  # @param limit [Integer] limit of bots per page
32
- # @return [Hash] raw data from DBLista
32
+ # @return [Hash] raw data from DList
33
33
  def self.premium(page = 0, limit = 10)
34
- DBLista._page_integer page
35
- DBLista._limit_integer limit
36
- DBLista._cache("botspremium#{page}-#{limit}") do
37
- DBLista._get("/bots/list/premium/#{page}?limit=#{limit}")
34
+ DList._page_integer page
35
+ DList._limit_integer limit
36
+ DList._cache("botspremium#{page}-#{limit}") do
37
+ DList._get("/bots/list/premium/#{page}?limit=#{limit}")
38
38
  end
39
39
  end
40
40
 
41
41
  # Fetches unverified bots
42
42
  #
43
- # @return [Hash] raw data from DBLista
43
+ # @return [Hash] raw data from DList
44
44
  def self.unverified
45
- DBLista._cache(:botsunverified) do
46
- DBLista._get('/bots/list/unverified')
45
+ DList._cache(:botsunverified) do
46
+ DList._get('/bots/list/unverified')
47
47
  end
48
48
  end
49
49
 
50
50
  # Fetches rejected bots
51
51
  #
52
- # @return [Hash] raw data from DBLista
52
+ # @return [Hash] raw data from DList
53
53
  def self.rejected
54
- DBLista._cache(:botsrejected) do
55
- DBLista._get('/bots/list/rejected')
54
+ DList._cache(:botsrejected) do
55
+ DList._get('/bots/list/rejected')
56
56
  end
57
57
  end
58
58
 
59
59
  # Fetches all bots
60
60
  #
61
- # @return [Array] array of raw bot data from DBLista
61
+ # @return [Array] array of raw bot data from DList
62
62
  def self.all
63
- DBLista._cache(:botsall) do
64
- DBLista._get('/bots/list/top/0?limit=1000000')
63
+ DList._cache(:botsall) do
64
+ DList._get('/bots/list/top/0?limit=1000000')
65
65
  end
66
66
  end
67
67
 
68
68
  # Bot search
69
69
  #
70
70
  # @param query [String] query search
71
- # @return [Hash] raw data from DBLista
71
+ # @return [Hash] raw data from DList
72
72
  def self.search(query)
73
- raise DBLista::Error, DBLista::Errors::QUERY_NOT_PROVIDED unless query
73
+ raise DList::Error, DList::Errors::QUERY_NOT_PROVIDED unless query
74
74
 
75
- DBLista._cache("botsearch#{query}") do
76
- DBLista._get("/bots/search/#{CGI.escape query.to_s}")
75
+ DList._cache("botsearch#{query}") do
76
+ DList._get("/bots/search/#{CGI.escape query.to_s}")
77
77
  end
78
78
  end
79
79
  end
@@ -2,19 +2,19 @@
2
2
 
3
3
  require 'cgi'
4
4
 
5
- module DBLista::List
5
+ module DList::List
6
6
  # Server lists
7
7
  module Server
8
8
  # Fetches top servers
9
9
  #
10
10
  # @param page [Integer] page
11
11
  # @param limit [Integer] limit of servers per page
12
- # @return [Hash] raw data from DBLista
12
+ # @return [Hash] raw data from DList
13
13
  def self.top(page = 0, limit = 10)
14
- DBLista._page_integer page
15
- DBLista._limit_integer limit
16
- DBLista._cache("serverstop#{page}-#{limit}") do
17
- DBLista._get("/servers/list/top/#{page}?limit=#{limit}")
14
+ DList._page_integer page
15
+ DList._limit_integer limit
16
+ DList._cache("serverstop#{page}-#{limit}") do
17
+ DList._get("/servers/list/top/#{page}?limit=#{limit}")
18
18
  end
19
19
  end
20
20
 
@@ -22,33 +22,33 @@ module DBLista::List
22
22
  #
23
23
  # @param page [Integer] page
24
24
  # @param limit [Integer] limit of servers per page
25
- # @return [Hash] raw data from DBLista
25
+ # @return [Hash] raw data from DList
26
26
  def self.premium(page = 0, limit = 10)
27
- DBLista._page_integer page
28
- DBLista._limit_integer limit
29
- DBLista._cache("serverspremium#{page}-#{limit}") do
30
- DBLista._get("/servers/list/premium/#{page}?limit=#{limit}")
27
+ DList._page_integer page
28
+ DList._limit_integer limit
29
+ DList._cache("serverspremium#{page}-#{limit}") do
30
+ DList._get("/servers/list/premium/#{page}?limit=#{limit}")
31
31
  end
32
32
  end
33
33
 
34
34
  # Fetches all servers
35
35
  #
36
- # @return [Array] array of raw server data from DBLista
36
+ # @return [Array] array of raw server data from DList
37
37
  def self.all
38
- DBLista._cache(:serversall) do
39
- DBLista._get('/servers/list/top/0?limit=1000000')
38
+ DList._cache(:serversall) do
39
+ DList._get('/servers/list/top/0?limit=1000000')
40
40
  end
41
41
  end
42
42
 
43
43
  # Server search
44
44
  #
45
45
  # @param query [String] search query
46
- # @return [Hash] raw data from DBLista
46
+ # @return [Hash] raw data from DList
47
47
  def self.search(query)
48
- raise DBLista::Error, DBLista::Errors::QUERY_NOT_PROVIDED unless query
48
+ raise DList::Error, DList::Errors::QUERY_NOT_PROVIDED unless query
49
49
 
50
- DBLista._cache("serversearch#{query}") do
51
- DBLista._get("/servers/search/#{CGI.escape query.to_s}")
50
+ DList._cache("serversearch#{query}") do
51
+ DList._get("/servers/search/#{CGI.escape query.to_s}")
52
52
  end
53
53
  end
54
54
  end
@@ -3,19 +3,19 @@
3
3
  require 'net/https'
4
4
  require 'json'
5
5
 
6
- module DBLista
6
+ module DList
7
7
  # Class for updating bot statistics
8
8
  #
9
- # @example Hook bot stats to DBLista
9
+ # @example Hook bot stats to DList
10
10
  # bot = Discordrb::Bot.new token: 'TOKEN'
11
- # dbl = DBLista::Stats.new 'DBLISTA_TOKEN', bot
11
+ # dbl = DList::Stats.new 'DList_TOKEN', bot
12
12
  class Stats
13
13
  attr_accessor :token
14
14
 
15
- # @param token [String] DBLista bot token
15
+ # @param token [String] DList bot token
16
16
  # @param bot [Discordrb::Bot] discordrb bot for auto-sending statistics
17
17
  def initialize(token, bot = nil)
18
- raise DBLista::Error, DBLista::Errors::TOKEN_NOT_PROVIDED unless token
18
+ raise DList::Error, DList::Errors::TOKEN_NOT_PROVIDED unless token
19
19
 
20
20
  @token = token
21
21
  if bot&.connected?
@@ -38,13 +38,13 @@ module DBLista
38
38
  @thread
39
39
  end
40
40
 
41
- # Sends statistics to DBLista
41
+ # Sends statistics to DList
42
42
  #
43
43
  # @param members [Integer] member count
44
44
  # @param servers [Integer] server count
45
45
  # @return [Boolean] true if operation succeded
46
46
  def update_stats(members, servers)
47
- DBLista._post('/bots/stats', {
47
+ DList._post('/bots/stats', {
48
48
  'servers' => servers,
49
49
  'members' => members
50
50
  }, @token)
@@ -2,57 +2,57 @@
2
2
 
3
3
  require 'json'
4
4
 
5
- module DBLista::User
5
+ module DList::User
6
6
  # User client - actions
7
7
  module Actions
8
- # Adds bot/server to DBLista
8
+ # Adds bot/server to DList
9
9
  #
10
10
  # @param body [Hash] raw body to send
11
11
  # @param type [Symbol] type of entity (bot/server)
12
12
  # @return [Boolean] true if operation succeded
13
13
  def add(body, type = 'bot')
14
- raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
15
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
14
+ raise DList::Error, DList::Errors::BODY_HASH unless body.is_a?(Hash)
15
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
16
16
 
17
- DBLista._post("/#{type}s", body, @token)
17
+ DList._post("/#{type}s", body, @token)
18
18
  true
19
19
  end
20
20
 
21
- # Edits bot/server in DBLista
21
+ # Edits bot/server in DList
22
22
  #
23
23
  # @param body [Hash] raw body to send
24
24
  # @param type [Symbol] type of entity (bot/server)
25
25
  # @return [Boolean] true if operation succeded
26
26
  def edit(body, type = :bot)
27
- raise DBLista::Error, DBLista::Errors::BODY_HASH unless body.is_a?(Hash)
28
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
27
+ raise DList::Error, DList::Errors::BODY_HASH unless body.is_a?(Hash)
28
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
29
29
 
30
- DBLista._put("/#{type}s", body, @token)
30
+ DList._put("/#{type}s", body, @token)
31
31
  true
32
32
  end
33
33
 
34
- # Deletes bot/server from DBLista
34
+ # Deletes bot/server from DList
35
35
  #
36
36
  # @param id [Integer] entity ID
37
37
  # @param type [Symbol] type of entity (bot/server)
38
38
  # @return [Boolean] true if operation succeded
39
39
  def delete(id, type = :bot)
40
- DBLista._validate_id id
41
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
40
+ DList._validate_id id
41
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
42
42
 
43
- DBLista._delete("/#{type}s/#{id}", nil, @token)
43
+ DList._delete("/#{type}s/#{id}", nil, @token)
44
44
  true
45
45
  end
46
46
 
47
47
  # Manages user (bans or adds premium)
48
- # Available only for DBLista staff
48
+ # Available only for DList staff
49
49
  #
50
50
  # @param id [Integer] user ID
51
51
  # @param banned [Boolean] user ban status
52
52
  # @param premium [Integer] days for premium
53
53
  # @return [Boolean] true if operation succeded
54
54
  def manage_user(id, banned = false, premium = 0)
55
- DBLista._post("/users/#{id}/manage", {
55
+ DList._post("/users/#{id}/manage", {
56
56
  premium: premium,
57
57
  ban: banned
58
58
  }, @token)
@@ -62,19 +62,19 @@ module DBLista::User
62
62
  # Generates token for bot
63
63
  #
64
64
  # @param id [Integer] bot ID
65
- # @return [Hash] raw data from DBLista
65
+ # @return [Hash] raw data from DList
66
66
  def generate_token(id)
67
- DBLista._validate_id id
68
- DBLista._get("/bots/stats/#{id}?token=#{@token}")
67
+ DList._validate_id id
68
+ DList._get("/bots/stats/#{id}?token=#{@token}")
69
69
  end
70
70
 
71
71
  # Resets token for bot
72
72
  #
73
73
  # @param id [Integer] bot ID
74
- # @return [Hash] raw data from DBLista
74
+ # @return [Hash] raw data from DList
75
75
  def reset_token(id)
76
- DBLista._validate_id id
77
- DBLista._post("/bots/stats/#{id}/reset", nil, @token)
76
+ DList._validate_id id
77
+ DList._post("/bots/stats/#{id}/reset", nil, @token)
78
78
  end
79
79
  end
80
80
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista::User
3
+ module DList::User
4
4
  # User client - boosting
5
5
  module Boosting
6
6
  # Boosts selected bot/server
@@ -9,10 +9,10 @@ module DBLista::User
9
9
  # @param type [Symbol] type of entity (bot/server)
10
10
  # @return [Boolean] true if operation succeded
11
11
  def boost(id, type = :bot)
12
- DBLista._validate_id id
13
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
12
+ DList._validate_id id
13
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
14
14
 
15
- DBLista._post("/#{type}s/#{id}/boost", nil, @token)
15
+ DList._post("/#{type}s/#{id}/boost", nil, @token)
16
16
  true
17
17
  end
18
18
 
@@ -22,10 +22,10 @@ module DBLista::User
22
22
  # @param type [Symbol] type of entity (bot/server)
23
23
  # @return [Boolean] true if operation succeded
24
24
  def delete_boost(id, type = :bot)
25
- DBLista._validate_id id
26
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
25
+ DList._validate_id id
26
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
27
27
 
28
- DBLista._delete("/#{type}s/#{id}/boost", nil, @token)
28
+ DList._delete("/#{type}s/#{id}/boost", nil, @token)
29
29
  true
30
30
  end
31
31
  end
@@ -11,24 +11,24 @@ require_relative './verification'
11
11
  require_relative './info'
12
12
 
13
13
  # User module - client + client modules
14
- module DBLista::User
15
- # DBLista user client
14
+ module DList::User
15
+ # DList user client
16
16
  #
17
17
  # @example Server voting
18
- # client = DBLista::User::Client.new "USER_TOKEN"
18
+ # client = DList::User::Client.new "USER_TOKEN"
19
19
  # client.vote(123456789012345678, :server)
20
20
  #
21
21
  # @example Bot rating
22
- # client = DBLista::User::Client.new "USER_TOKEN"
22
+ # client = DList::User::Client.new "USER_TOKEN"
23
23
  # client.rate(123456789012345678, 5, 'Nice bot')
24
24
  class Client
25
- include DBLista::User::Voting
26
- include DBLista::User::Actions
27
- include DBLista::User::Boosting
28
- include DBLista::User::Rating
29
- include DBLista::User::Notifications
30
- include DBLista::User::Verification
31
- include DBLista::User::Information
25
+ include DList::User::Voting
26
+ include DList::User::Actions
27
+ include DList::User::Boosting
28
+ include DList::User::Rating
29
+ include DList::User::Notifications
30
+ include DList::User::Verification
31
+ include DList::User::Information
32
32
 
33
33
  # Allowed entity types to use
34
34
  ALLOWED_TYPES = %i[bot server].freeze
@@ -36,7 +36,7 @@ module DBLista::User
36
36
  attr_accessor :token
37
37
 
38
38
  def initialize(token)
39
- raise DBLista::Error, DBLista::Errors::TOKEN_NOT_PROVIDED unless token
39
+ raise DList::Error, DList::Errors::TOKEN_NOT_PROVIDED unless token
40
40
 
41
41
  @token = token
42
42
  @cache = Zache.new
@@ -46,19 +46,19 @@ module DBLista::User
46
46
 
47
47
  # Fetches information about current user
48
48
  #
49
- # @return [Hash] raw data from DBLista
49
+ # @return [Hash] raw data from DList
50
50
  def me
51
- @cache.get(:guilds, lifetime: DBLista::CACHE_LIFETIME) do
52
- DBLista._get('/users/me', @token)
51
+ @cache.get(:guilds, lifetime: DList::CACHE_LIFETIME) do
52
+ DList._get('/users/me', @token)
53
53
  end
54
54
  end
55
55
 
56
56
  # Fetches current user guilds
57
57
  #
58
- # @return [Hash] raw data from DBLista
58
+ # @return [Hash] raw data from DList
59
59
  def joined_guilds
60
- @cache.get(:guilds, lifetime: DBLista::CACHE_LIFETIME) do
61
- DBLista._get('/users/me/guilds', @token)
60
+ @cache.get(:guilds, lifetime: DList::CACHE_LIFETIME) do
61
+ DList._get('/users/me/guilds', @token)
62
62
  end
63
63
  end
64
64
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista::User
3
+ module DList::User
4
4
  # User client - information
5
5
  module Information
6
6
  # Fetches your servers
7
7
  #
8
- # @return [Hash] raw data from DBLista
8
+ # @return [Hash] raw data from DList
9
9
  def servers
10
- DBLista._get('/servers/user/me', @token)
10
+ DList._get('/servers/user/me', @token)
11
11
  end
12
12
 
13
13
  # Fetches your bots
14
14
  #
15
- # @return [Hash] raw data from DBLista
15
+ # @return [Hash] raw data from DList
16
16
  def bots
17
- DBLista._get('/bots/user/me', @token)
17
+ DList._get('/bots/user/me', @token)
18
18
  end
19
19
  end
20
20
  end
@@ -1,33 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista::User
3
+ module DList::User
4
4
  # User client - notifications
5
5
  module Notifications
6
6
  # Fetches user notifications
7
7
  #
8
- # @return [Hash] raw data from DBLista
8
+ # @return [Hash] raw data from DList
9
9
  def notifications
10
- DBLista._get('/users/me/notifications/read', @token)
10
+ DList._get('/users/me/notifications/read', @token)
11
11
  end
12
12
 
13
13
  # Clears user notifications
14
14
  #
15
15
  # @return [Boolean] true if operation succeded
16
16
  def clear_notifications
17
- DBLista._get('/users/me/notifications/clear', @token)
17
+ DList._get('/users/me/notifications/clear', @token)
18
18
  true
19
19
  end
20
20
 
21
21
  # Sends notification to specified user
22
- # Available only for DBLista staff
22
+ # Available only for DList staff
23
23
  #
24
24
  # @param rank [Integer] user ID
25
25
  # @param details [String] details (content)
26
26
  # @param url [String] url to redirect if clicked
27
27
  # @return [Boolean] true if operation succeded
28
28
  def send_notification(id, details, url = '#')
29
- DBLista._validate_id id
30
- DBLista._post("/users/#{id}/notifications", {
29
+ DList._validate_id id
30
+ DList._post("/users/#{id}/notifications", {
31
31
  text: details,
32
32
  url: url || '#'
33
33
  }, @token)
@@ -35,14 +35,14 @@ module DBLista::User
35
35
  end
36
36
 
37
37
  # Sends notification to specified group (rank)
38
- # Available only for DBLista staff
38
+ # Available only for DList staff
39
39
  #
40
40
  # @param rank [Integer] rank ID
41
41
  # @param details [String] details (content)
42
42
  # @param url [String] url to redirect if clicked
43
43
  # @return [Boolean] true if operation succeded
44
44
  def send_group_notification(rank, details, url = '#')
45
- DBLista._post("/users/group/#{rank}/notifications", {
45
+ DList._post("/users/group/#{rank}/notifications", {
46
46
  text: details,
47
47
  url: url || '#'
48
48
  }, @token)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista::User
3
+ module DList::User
4
4
  # User client - rating
5
5
  module Rating
6
6
  # Sends rate for a selected bot/server
@@ -11,10 +11,10 @@ module DBLista::User
11
11
  # @param type [Symbol] type of entity (bot/server)
12
12
  # @return [Boolean] true if operation succeded
13
13
  def rate(id, rating, details, type = :bot)
14
- DBLista._validate_id id
15
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
14
+ DList._validate_id id
15
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
16
16
 
17
- DBLista._post("/#{type}s/#{id}/rate", {
17
+ DList._post("/#{type}s/#{id}/rate", {
18
18
  rating: rating,
19
19
  details: details
20
20
  }, @token)
@@ -28,10 +28,10 @@ module DBLista::User
28
28
  # @param type [Symbol] type of entity (bot/server)
29
29
  # @return [Boolean] true if operation succeded
30
30
  def delete_rate(id, target_id = nil, type = :bot)
31
- DBLista._validate_id id
32
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
31
+ DList._validate_id id
32
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
33
33
 
34
- DBLista._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
34
+ DList._delete("/#{type}s/#{id}/rate/#{target_id}", nil, @token)
35
35
  true
36
36
  end
37
37
 
@@ -43,10 +43,10 @@ module DBLista::User
43
43
  # @param type [Symbol] type of entity (bot/server)
44
44
  # @return [Boolean] true if operation succeded
45
45
  def report_rate(id, rate_id, report_reason = 'Brak powodu', type = :bot)
46
- DBLista._validate_id id
47
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
46
+ DList._validate_id id
47
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
48
48
 
49
- DBLista._post("/#{type}s/#{id}/ratings/#{rate_id}/report", {
49
+ DList._post("/#{type}s/#{id}/ratings/#{rate_id}/report", {
50
50
  reportReason: report_reason.to_s
51
51
  }, @token)
52
52
  true
@@ -54,19 +54,19 @@ module DBLista::User
54
54
 
55
55
  # Fetches all rate reports
56
56
  #
57
- # @return [Hash] raw data from DBLista
57
+ # @return [Hash] raw data from DList
58
58
  def reports
59
- DBLista._get('/reports')
59
+ DList._get('/reports')
60
60
  end
61
61
 
62
62
  # Deletes rate report
63
63
  #
64
64
  # @param id [Integer] report ID
65
- # @return [Hash] raw data from DBLista
65
+ # @return [Hash] raw data from DList
66
66
  def delete_report(id, type = :bot)
67
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
67
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
68
68
 
69
- DBLista._delete("/reports/#{id}", nil, @token)
69
+ DList._delete("/reports/#{id}", nil, @token)
70
70
  true
71
71
  end
72
72
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'cgi'
4
4
 
5
- module DBLista::User
5
+ module DList::User
6
6
  # User client - verification (only for staff)
7
7
  module Verification
8
8
  # Approves specified bot
@@ -11,9 +11,9 @@ module DBLista::User
11
11
  # @param reason [String] reason for approving
12
12
  # @return [Boolean] true if operation succeded
13
13
  def approve(id, reason = 'Brak powodu')
14
- DBLista._validate_id id
14
+ DList._validate_id id
15
15
 
16
- DBLista._post("/bots/verify/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
16
+ DList._post("/bots/verify/#{id}/approve?reason=#{CGI.escape reason}", nil, @token)
17
17
  true
18
18
  end
19
19
 
@@ -23,9 +23,9 @@ module DBLista::User
23
23
  # @param reason [String] reason for rejecting
24
24
  # @return [Boolean] true if operation succeded
25
25
  def reject(id, reason = 'Brak powodu')
26
- DBLista._validate_id id
26
+ DList._validate_id id
27
27
 
28
- DBLista._post("/bots/verify/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
28
+ DList._post("/bots/verify/#{id}/reject?reason=#{CGI.escape reason}", nil, @token)
29
29
  true
30
30
  end
31
31
 
@@ -34,9 +34,9 @@ module DBLista::User
34
34
  # @param id [Integer] bot ID
35
35
  # @return [Boolean] true if operation succeded
36
36
  def set_pending(id)
37
- DBLista._validate_id id
37
+ DList._validate_id id
38
38
 
39
- DBLista._post("/bots/#{id}/set-pending", nil, @token)
39
+ DList._post("/bots/#{id}/set-pending", nil, @token)
40
40
  true
41
41
  end
42
42
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista::User
3
+ module DList::User
4
4
  # User client - voting
5
5
  module Voting
6
6
  # Votes for a selected bot/server
@@ -9,10 +9,10 @@ module DBLista::User
9
9
  # @param type [Symbol] type of entity (bot/server)
10
10
  # @return [Boolean] true if operation succeded
11
11
  def vote(id, type = :bot)
12
- DBLista._validate_id id
13
- raise DBLista::Error, DBLista::Errors::TYPE_NOT_ALLOWED unless DBLista::User::Client::ALLOWED_TYPES.include?(type)
12
+ DList._validate_id id
13
+ raise DList::Error, DList::Errors::TYPE_NOT_ALLOWED unless DList::User::Client::ALLOWED_TYPES.include?(type)
14
14
 
15
- DBLista._post("/#{type}s/#{id}/vote", nil, @token)
15
+ DList._post("/#{type}s/#{id}/vote", nil, @token)
16
16
  true
17
17
  end
18
18
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module DBLista
3
+ module DList
4
4
  # Wrapper version
5
- VERSION = '0.6.4'
5
+ VERSION = '0.7.0'
6
6
  end
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.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - deepivin