dsu3 0.3 → 0.5.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/lib/dsu3/bot.rb +23 -18
- data/lib/dsu3/core.rb +4 -5
- data/lib/dsu3/props.rb +31 -26
- data/lib/dsu3.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9572203f08a6ce1f65c4a33b613b51a116c0fc935c6f26c8d0e5b2f0600740b6
|
4
|
+
data.tar.gz: 89b125202ba866c62599f69fa7f9321b82d4edf3773fdebcbe0dfe6771f1f724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fd28581d81eeead4c8295818ef4f1484218e7771b42709a47991696da2b0eb9c9b936aa0fbaa36b800b5f798d55271e3b5acf333a59895658d1b4c87acdb312
|
7
|
+
data.tar.gz: 2857ce644817ba1f2965de5d82585322ecd889fa4eb87f5a7980119a22654d623f1e1af84c174c3a029bbbf04bd5e3f82e3b7e1fea1848ffea96ab1dc360ed66
|
data/lib/dsu3/bot.rb
CHANGED
@@ -5,20 +5,21 @@ require 'json'
|
|
5
5
|
require 'uri'
|
6
6
|
|
7
7
|
module DSU3
|
8
|
+
# Class representing Discord bot
|
8
9
|
class Bot
|
9
10
|
API_BASE = 'https://discord.com/api/v9'
|
10
11
|
|
11
|
-
# @param [
|
12
|
-
def initialize(
|
13
|
-
@headers =
|
12
|
+
# @param [String] token Discord account token
|
13
|
+
def initialize(token)
|
14
|
+
@headers = Props::HEADERS.merge(authorization: token)
|
14
15
|
end
|
15
16
|
|
16
|
-
# Makes an API request
|
17
|
+
# Makes an API request without any error handling
|
17
18
|
# @param [Symbol, String] method
|
18
19
|
# @param [String] endpoint Discord API endpoint
|
19
20
|
# @param [Hash] headers Additional request headers
|
20
21
|
# @param [String] payload
|
21
|
-
def
|
22
|
+
def raw_request(method, endpoint, headers = {}, payload = nil)
|
22
23
|
args = {
|
23
24
|
method: method,
|
24
25
|
url: URI.join(API_BASE, endpoint).to_s,
|
@@ -27,20 +28,24 @@ module DSU3
|
|
27
28
|
|
28
29
|
args[:payload] = payload if payload
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
RestClient::Request.execute(args)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Makes an API request, includes simple error handling
|
35
|
+
# @param (see #raw_request)
|
36
|
+
def request(...)
|
37
|
+
raw_request(...)
|
38
|
+
rescue RestClient::ExceptionWithResponse => e
|
39
|
+
data = JSON.parse(e.response)
|
34
40
|
|
35
|
-
|
36
|
-
|
41
|
+
if e.is_a?(RestClient::TooManyRequests)
|
42
|
+
retry_after = data['retry_after'] / 1000.0
|
37
43
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
+
LOGGER.warn("rate limit exceeded, waiting #{retry_after} seconds")
|
45
|
+
sleep(retry_after)
|
46
|
+
retry
|
47
|
+
else
|
48
|
+
LOGGER.error("#{data['code']}: #{data['message']}")
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
@@ -81,7 +86,7 @@ module DSU3
|
|
81
86
|
request(
|
82
87
|
:put,
|
83
88
|
"channels/#{channel}/messages/#{message}/reactions/#{emoji}/@me",
|
84
|
-
{params: {location: 'Message'}}
|
89
|
+
{ params: { location: 'Message' } }
|
85
90
|
)
|
86
91
|
end
|
87
92
|
end
|
data/lib/dsu3/core.rb
CHANGED
@@ -4,18 +4,17 @@ require 'dsu3/props'
|
|
4
4
|
require 'dsu3/bot'
|
5
5
|
|
6
6
|
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
|
-
|
12
|
-
@bots = tokens.map { |token| Bot.new(headers.merge(authorization: token)) }
|
10
|
+
def initialize(*tokens)
|
11
|
+
@bots = tokens.map(&Bot.method(:new))
|
13
12
|
end
|
14
13
|
|
15
14
|
# (see Bot#type)
|
16
15
|
def typespam(channel)
|
17
16
|
loop do
|
18
|
-
@bots.each(
|
17
|
+
@bots.each { |bot| bot.type(channel) }
|
19
18
|
sleep 9
|
20
19
|
end
|
21
20
|
end
|
data/lib/dsu3/props.rb
CHANGED
@@ -5,53 +5,58 @@ 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
|
9
|
+
# pretty bad code in this module rests by the way
|
8
10
|
module Props
|
9
|
-
module_function
|
10
|
-
|
11
11
|
# user-agent header
|
12
|
-
USER_AGENT =
|
13
|
-
|
14
|
-
|
12
|
+
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0'
|
13
|
+
|
14
|
+
DATAMINING_COMMITS_URL = 'https://api.github.com/repos/Discord-Datamining/Discord-Datamining/commits/master'
|
15
|
+
|
16
|
+
# Fetches Discord client build number
|
17
|
+
def fetch_build_number
|
18
|
+
JSON.parse(RestClient.get(DATAMINING_COMMITS_URL))['commit']['message'].match(/Build (\d+)/)[1]
|
19
|
+
end
|
15
20
|
|
16
21
|
# Decoded x-super-properties header
|
17
22
|
SUPER_PROPERTIES = {
|
18
23
|
os: 'Linux',
|
19
|
-
browser: '
|
24
|
+
browser: 'Firefox',
|
25
|
+
device: '',
|
26
|
+
system_locale: 'en',
|
27
|
+
browser_user_agent: USER_AGENT,
|
28
|
+
browser_version: '91.0',
|
29
|
+
os_version: '',
|
30
|
+
referrer: '',
|
31
|
+
referring_domain: '',
|
32
|
+
referrer_current: '',
|
33
|
+
referring_domain_current: '',
|
20
34
|
release_channel: 'stable',
|
21
|
-
|
22
|
-
os_version: '5.10.0-14-amd64',
|
23
|
-
os_arch: 'x64',
|
24
|
-
system_locale: 'en-US',
|
25
|
-
window_manager: 'XFCE,xfce',
|
26
|
-
distro: 'Debian GNU/Linux 11 (bullseye)',
|
27
|
-
client_build_number: 136_921,
|
35
|
+
client_build_number: fetch_build_number,
|
28
36
|
client_event_source: nil
|
29
37
|
}.freeze
|
30
38
|
|
31
|
-
|
39
|
+
resp = RestClient.get('https://discord.com/api/v9/experiments')
|
40
|
+
|
41
|
+
# Headers necessary for normal interaction with the Discord API
|
32
42
|
HEADERS = {
|
33
43
|
accept: '*/*',
|
34
44
|
accept_encoding: 'gzip, deflate, br',
|
35
|
-
accept_language: 'en
|
45
|
+
accept_language: 'en',
|
46
|
+
alt_used: 'discord.com',
|
47
|
+
connection: 'keep-alive',
|
48
|
+
host: 'discord.com',
|
36
49
|
sec_fetch_dest: 'empty',
|
37
50
|
sec_fetch_mode: 'cors',
|
38
51
|
sec_fetch_site: 'same-origin',
|
52
|
+
te: 'trailers',
|
39
53
|
user_agent: USER_AGENT,
|
40
54
|
x_debug_options: 'bugReporterEnabled',
|
41
55
|
x_discord_locale: 'en-US',
|
42
56
|
x_super_properties: Base64.strict_encode64(SUPER_PROPERTIES.to_json),
|
43
57
|
content_type: 'application/json',
|
44
|
-
|
58
|
+
cookie: HTTP::Cookie.cookie_value(resp.cookie_jar.cookies),
|
59
|
+
x_fingerprint: JSON.parse(resp.body)['fingerprint']
|
45
60
|
}.freeze
|
46
|
-
|
47
|
-
# Gets the headers necessary for normal interaction with the Discord API
|
48
|
-
def headers
|
49
|
-
resp = RestClient.get('https://discord.com/api/v9/experiments')
|
50
|
-
|
51
|
-
{
|
52
|
-
cookie: HTTP::Cookie.cookie_value(resp.cookie_jar.cookies),
|
53
|
-
x_fingerprint: JSON.parse(resp.body)['fingerprint']
|
54
|
-
}.merge(HEADERS)
|
55
|
-
end
|
56
61
|
end
|
57
62
|
end
|
data/lib/dsu3.rb
CHANGED
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:
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.7.0
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - ">="
|