dsu3 0.4 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9a0705c6d460fe073239d8637574b0fa3e8abfb618064aca5d79271f34a0d70
4
- data.tar.gz: c622c03008ec604396abf1309d7fc87155bc9dca09650c7486305ec05214d6cb
3
+ metadata.gz: a92e3f9bf4157fec1930cdafec45c21f0f59a5dfab718f96d4f65faea24f082b
4
+ data.tar.gz: 620704fcb30b1c8ef6d7572a0e41592aacef2db0c91278259a1667a239cb5e40
5
5
  SHA512:
6
- metadata.gz: db0f31beb357f9e01751305fa00c0e914c0b2e9a51664afdbf88a2940e8b23fef2488e84597eb44c1e155d4bb6f6641f51ba86067dc7ca3fa537f86da13088b5
7
- data.tar.gz: 9a9c5288a110b35e13db5b5879c8d79ab9ba2b26f952b91b203a87ed628c1b100f0f69cfb8c27a267d1cbcd50cff43e770e3f80e5f50161492c051b2039d314d
6
+ metadata.gz: 99219d879efce343e1b550d7b50c23b886b506ee5c9e74229602fb347bca870a0c015fc5da8a0e5f9e747a22ff26fc4e96b098ecd9a3139d6e7253eed0df10d0
7
+ data.tar.gz: 91af4ac8bf517185a8efefa5ed4dccc945a6a5275959b0870b4584446623a634c6bf04e0cb1ab575ff0d23c104efebbf6754d00d5e9ca77bca314dc4a6cb3e84
data/lib/dsu3/bot.rb CHANGED
@@ -10,8 +10,11 @@ module DSU3
10
10
  API_BASE = 'https://discord.com/api/v9'
11
11
 
12
12
  # @param [String] token Discord account token
13
- def initialize(token)
13
+ # @param [Array] proxies List of proxy servers
14
+ # If the list of proxy servers is empty, the proxy will not be used
15
+ def initialize(token, proxies = [])
14
16
  @headers = Props::HEADERS.merge(authorization: token)
17
+ @proxies = proxies
15
18
  end
16
19
 
17
20
  # Makes an API request without any error handling
@@ -20,15 +23,13 @@ module DSU3
20
23
  # @param [Hash] headers Additional request headers
21
24
  # @param [String] payload
22
25
  def raw_request(method, endpoint, headers = {}, payload = nil)
23
- args = {
26
+ RestClient::Request.execute(
24
27
  method: method,
25
28
  url: URI.join(API_BASE, endpoint).to_s,
26
- headers: @headers.merge(headers)
27
- }
28
-
29
- args[:payload] = payload if payload
30
-
31
- RestClient::Request.execute(args)
29
+ headers: @headers.merge(headers),
30
+ payload: payload,
31
+ proxy: @proxies.sample
32
+ )
32
33
  end
33
34
 
34
35
  # Makes an API request, includes simple error handling
@@ -57,7 +58,7 @@ module DSU3
57
58
 
58
59
  # Sends a message to a specific channel
59
60
  # @param [String, Integer] channel Channel ID
60
- # @param [String] message
61
+ # @param [String] message Message ID
61
62
  def send_message(channel, message)
62
63
  request(
63
64
  :post, "channels/#{channel}/messages",
data/lib/dsu3/core.rb CHANGED
@@ -7,8 +7,10 @@ module DSU3
7
7
  # Class used to manage multiple bots
8
8
  class Core
9
9
  # @param [Array] tokens List of bot tokens
10
- def initialize(*tokens)
11
- @bots = tokens.map(&Bot.method(:new))
10
+ # @param [Array] proxies List of proxy servers
11
+ # If the list of proxy servers is empty, the proxy will not be used
12
+ def initialize(*tokens, proxies = [])
13
+ @bots = tokens.map { |token| Bot.new(token, proxies) }
12
14
  end
13
15
 
14
16
  # (see Bot#type)
data/lib/dsu3/props.rb CHANGED
@@ -5,24 +5,33 @@ require 'json'
5
5
  require 'base64'
6
6
 
7
7
  module DSU3
8
+ # The fundamental class in this vast system, on which all the other parts of the structure depend
8
9
  module Props
9
10
  # user-agent header
10
- USER_AGENT =
11
- 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) '\
12
- 'discord/0.0.18 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36'
11
+ USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0'
12
+
13
+ DATAMINING_COMMITS_URL = 'https://api.github.com/repos/Discord-Datamining/Discord-Datamining/commits/master'
14
+
15
+ # Fetches Discord client build number
16
+ def self.fetch_build_number
17
+ JSON.parse(RestClient.get(DATAMINING_COMMITS_URL))['commit']['message'].match(/Build (\d+)/)[1]
18
+ end
13
19
 
14
20
  # Decoded x-super-properties header
15
21
  SUPER_PROPERTIES = {
16
22
  os: 'Linux',
17
- browser: 'Discord Client',
23
+ browser: 'Firefox',
24
+ device: '',
25
+ system_locale: 'en',
26
+ browser_user_agent: USER_AGENT,
27
+ browser_version: '91.0',
28
+ os_version: '',
29
+ referrer: '',
30
+ referring_domain: '',
31
+ referrer_current: '',
32
+ referring_domain_current: '',
18
33
  release_channel: 'stable',
19
- client_version: '0.0.18',
20
- os_version: '5.10.0-14-amd64',
21
- os_arch: 'x64',
22
- system_locale: 'en-US',
23
- window_manager: 'XFCE,xfce',
24
- distro: 'Debian GNU/Linux 11 (bullseye)',
25
- client_build_number: 136_921,
34
+ client_build_number: fetch_build_number,
26
35
  client_event_source: nil
27
36
  }.freeze
28
37
 
@@ -32,16 +41,19 @@ module DSU3
32
41
  HEADERS = {
33
42
  accept: '*/*',
34
43
  accept_encoding: 'gzip, deflate, br',
35
- accept_language: 'en-US',
44
+ accept_language: 'en',
45
+ alt_used: 'discord.com',
46
+ connection: 'keep-alive',
47
+ host: 'discord.com',
36
48
  sec_fetch_dest: 'empty',
37
49
  sec_fetch_mode: 'cors',
38
50
  sec_fetch_site: 'same-origin',
51
+ te: 'trailers',
39
52
  user_agent: USER_AGENT,
40
53
  x_debug_options: 'bugReporterEnabled',
41
54
  x_discord_locale: 'en-US',
42
55
  x_super_properties: Base64.strict_encode64(SUPER_PROPERTIES.to_json),
43
56
  content_type: 'application/json',
44
- origin: 'https://discord.com',
45
57
  cookie: HTTP::Cookie.cookie_value(resp.cookie_jar.cookies),
46
58
  x_fingerprint: JSON.parse(resp.body)['fingerprint']
47
59
  }.freeze
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DSU3
4
+ VERSION = '0.6.0'
5
+ end
data/lib/dsu3.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
+
5
+ require 'dsu3/version'
4
6
  require 'dsu3/core'
5
7
 
6
8
  # Main DSU3 namespace
7
9
  module DSU3
8
- VERSION = '0.4'
9
-
10
10
  LOGGER = Logger.new($stdout)
11
11
  LOGGER.level = Logger::WARN
12
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dsu3
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Sheremetjev IV
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -36,6 +36,7 @@ files:
36
36
  - lib/dsu3/bot.rb
37
37
  - lib/dsu3/core.rb
38
38
  - lib/dsu3/props.rb
39
+ - lib/dsu3/version.rb
39
40
  homepage: https://rubygems.org/gems/dsu3
40
41
  licenses:
41
42
  - MIT