dsu3 0.6.0 → 0.8.1
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/README.md +8 -0
- data/bin/dsu3 +10 -0
- data/lib/dsu3/api/channel.rb +46 -0
- data/lib/dsu3/api.rb +61 -0
- data/lib/dsu3/net.rb +48 -0
- data/lib/dsu3/props.rb +0 -2
- data/lib/dsu3/version.rb +1 -1
- data/lib/dsu3.rb +6 -1
- metadata +8 -5
- data/lib/dsu3/bot.rb +0 -94
- data/lib/dsu3/core.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6ec54cd04e7f706c33f880b3df0cbff0433174128fbc4862d526a62366c83da
|
4
|
+
data.tar.gz: f417a06ab056fec181a311a1f575e9dbf31fe079cc4a89f9ba6cde44852d6c0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f16652a41755e5497d5b55065decbf82089cfef7d365629340c408d5e433c5d44f309ac50f7924bab8d5d57f9b4dbdb62a0fd53f02a1a00a77b88c62699b5da0
|
7
|
+
data.tar.gz: d74e04336445ff5872bf0214017ed05e0c0ca4f3bf8bf25a4c7539f06a8d6dcbc1f1d95fa1b5dc47f22e7cfd6eeb0502d7ece792641ce65133e7625625e6afde
|
data/README.md
CHANGED
@@ -5,3 +5,11 @@ dsu3 is a simple library for working with discord selfbots
|
|
5
5
|
```sh
|
6
6
|
sudo gem install dsu3
|
7
7
|
```
|
8
|
+
|
9
|
+
# usage
|
10
|
+
execute
|
11
|
+
```sh
|
12
|
+
dsu3 path/to/token/file
|
13
|
+
```
|
14
|
+
to run irb with dsu3 already required and a net instance already initialised
|
15
|
+
more info is available here www.rubydoc.info/gems/dsu3
|
data/bin/dsu3
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DSU3
|
4
|
+
module API
|
5
|
+
# Channels resource
|
6
|
+
module Channel
|
7
|
+
module_function
|
8
|
+
|
9
|
+
# Types text into a particular channel
|
10
|
+
# @param [String] token Discord account token
|
11
|
+
# @param [String, Integer] channel Channel ID
|
12
|
+
def type(token, channel)
|
13
|
+
DSU3::API.request(
|
14
|
+
token, :post, "channels/#{channel}/typing"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Sends a message to a specific channel
|
19
|
+
# @param [String] token Discord account token
|
20
|
+
# @param [String, Integer] channel Channel ID
|
21
|
+
# @param [String, Integer] message Message contents
|
22
|
+
def send(token, channel, message)
|
23
|
+
DSU3::API.request(
|
24
|
+
token, :post, "channels/#{channel}/messages",
|
25
|
+
{}, { content: message }.to_json
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Reacts to a message
|
30
|
+
# @note To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id
|
31
|
+
# @param [String] token Discord account token
|
32
|
+
# @param [String, Integer] channel Channel ID
|
33
|
+
# @param [String, Integer] message Message ID
|
34
|
+
# @param [String] emoji
|
35
|
+
def react(token, channel, message, emoji)
|
36
|
+
emoji = URI.encode_www_form_component(emoji)
|
37
|
+
|
38
|
+
DSU3::API.request(
|
39
|
+
token, :put,
|
40
|
+
"channels/#{channel}/messages/#{message}/reactions/#{emoji}/@me",
|
41
|
+
{ params: { location: 'Message' } }
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/dsu3/api.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'dsu3/props'
|
8
|
+
require 'dsu3/api/channel'
|
9
|
+
|
10
|
+
module DSU3
|
11
|
+
# Namespace for all methods representing Discord API endpoints
|
12
|
+
module API
|
13
|
+
API_BASE = 'https://discord.com/api/v9'
|
14
|
+
|
15
|
+
module_function
|
16
|
+
|
17
|
+
# Makes an API request without any error handling
|
18
|
+
# @param [String] token Discord account token
|
19
|
+
# @param [Symbol, String] method
|
20
|
+
# @param [String] route Discord API route
|
21
|
+
# @param [Hash] headers Additional request headers
|
22
|
+
# @param [String] payload
|
23
|
+
# @return [RestClient::Response] Response object
|
24
|
+
def raw_request(token, method, route, headers = {}, payload = nil)
|
25
|
+
RestClient::Request.execute(
|
26
|
+
method: method,
|
27
|
+
url: URI.join(API_BASE, route).to_s,
|
28
|
+
headers: headers.merge(DSU3::Props::HEADERS, { authorization: token }),
|
29
|
+
payload: payload,
|
30
|
+
proxy: DSU3.proxies.sample
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Makes an API request, includes simple error handling
|
35
|
+
# @param (see #raw_request)
|
36
|
+
# @return (see #raw_request)
|
37
|
+
def request(...)
|
38
|
+
raw_request(...)
|
39
|
+
rescue RestClient::ExceptionWithResponse => e
|
40
|
+
if e.is_a?(RestClient::TooManyRequests)
|
41
|
+
LOGGER.warn('ratelimit exceeded')
|
42
|
+
elsif e.response.headers[:content_type] == 'application/json'
|
43
|
+
LOGGER.error("#{data['code']}: #{data['message']}")
|
44
|
+
else
|
45
|
+
LOGGER.error(e.message)
|
46
|
+
end
|
47
|
+
e.response
|
48
|
+
end
|
49
|
+
|
50
|
+
# Joins guild
|
51
|
+
# @param [String] token Discord account token
|
52
|
+
# @param [String] invite Invite code
|
53
|
+
def join(token, invite)
|
54
|
+
request(
|
55
|
+
token, :post, "invites/#{invite}",
|
56
|
+
{ x_context_properties: 'eyJsb2NhdGlvbiI6Ik1hcmtkb3duIExpbmsifQ==' },
|
57
|
+
'{}'
|
58
|
+
)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/dsu3/net.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dsu3/api'
|
4
|
+
|
5
|
+
module DSU3
|
6
|
+
# Class used to manage multiple bots
|
7
|
+
class Net
|
8
|
+
# @param [Array] tokens List of bot tokens
|
9
|
+
def initialize(*tokens)
|
10
|
+
@tokens = tokens
|
11
|
+
end
|
12
|
+
|
13
|
+
# (see DSU3::API::Channel#type)
|
14
|
+
def typespam(channel)
|
15
|
+
loop do
|
16
|
+
@tokens.each { |token| DSU3::API::Channel.type(token, channel) }
|
17
|
+
sleep 9
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# (see DSU3::API::Channel#send)
|
22
|
+
def send(channel, message)
|
23
|
+
@tokens.each { |token| DSU3::API::Channel.send(token, channel, message) }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Infinitely calls a block and sends the value it returns to a specific channel
|
27
|
+
# @param [String] token Discord account token
|
28
|
+
# @param [String, Integer] channel Channel ID
|
29
|
+
def spam(channel, &block)
|
30
|
+
loop do
|
31
|
+
@tokens.each { |token| DSU3::API::Channel.send(token, channel, block.call) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# (see DSU3::API#join)
|
36
|
+
def join(invite)
|
37
|
+
@tokens.each do |token|
|
38
|
+
DSU3::API.join(token, invite)
|
39
|
+
sleep(0.5)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# (see DSU3::API::Channel#react)
|
44
|
+
def react(channel, message, emoji)
|
45
|
+
@tokens.each { |token| DSU3::API::Channel.react(token, channel, message, emoji) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/dsu3/props.rb
CHANGED
data/lib/dsu3/version.rb
CHANGED
data/lib/dsu3.rb
CHANGED
@@ -3,10 +3,15 @@
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
require 'dsu3/version'
|
6
|
-
require 'dsu3/
|
6
|
+
require 'dsu3/net'
|
7
7
|
|
8
8
|
# Main DSU3 namespace
|
9
9
|
module DSU3
|
10
10
|
LOGGER = Logger.new($stdout)
|
11
11
|
LOGGER.level = Logger::WARN
|
12
|
+
|
13
|
+
@proxies = []
|
14
|
+
class << self
|
15
|
+
attr_accessor :proxies
|
16
|
+
end
|
12
17
|
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
|
+
version: 0.8.1
|
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-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -26,15 +26,18 @@ dependencies:
|
|
26
26
|
version: '2.0'
|
27
27
|
description:
|
28
28
|
email:
|
29
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- dsu3
|
30
31
|
extensions: []
|
31
32
|
extra_rdoc_files:
|
32
33
|
- README.md
|
33
34
|
files:
|
34
35
|
- README.md
|
36
|
+
- bin/dsu3
|
35
37
|
- lib/dsu3.rb
|
36
|
-
- lib/dsu3/
|
37
|
-
- lib/dsu3/
|
38
|
+
- lib/dsu3/api.rb
|
39
|
+
- lib/dsu3/api/channel.rb
|
40
|
+
- lib/dsu3/net.rb
|
38
41
|
- lib/dsu3/props.rb
|
39
42
|
- lib/dsu3/version.rb
|
40
43
|
homepage: https://rubygems.org/gems/dsu3
|
data/lib/dsu3/bot.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rest-client'
|
4
|
-
require 'json'
|
5
|
-
require 'uri'
|
6
|
-
|
7
|
-
module DSU3
|
8
|
-
# Class representing Discord bot
|
9
|
-
class Bot
|
10
|
-
API_BASE = 'https://discord.com/api/v9'
|
11
|
-
|
12
|
-
# @param [String] token Discord account 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 = [])
|
16
|
-
@headers = Props::HEADERS.merge(authorization: token)
|
17
|
-
@proxies = proxies
|
18
|
-
end
|
19
|
-
|
20
|
-
# Makes an API request without any error handling
|
21
|
-
# @param [Symbol, String] method
|
22
|
-
# @param [String] endpoint Discord API endpoint
|
23
|
-
# @param [Hash] headers Additional request headers
|
24
|
-
# @param [String] payload
|
25
|
-
def raw_request(method, endpoint, headers = {}, payload = nil)
|
26
|
-
RestClient::Request.execute(
|
27
|
-
method: method,
|
28
|
-
url: URI.join(API_BASE, endpoint).to_s,
|
29
|
-
headers: @headers.merge(headers),
|
30
|
-
payload: payload,
|
31
|
-
proxy: @proxies.sample
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Makes an API request, includes simple error handling
|
36
|
-
# @param (see #raw_request)
|
37
|
-
def request(...)
|
38
|
-
raw_request(...)
|
39
|
-
rescue RestClient::ExceptionWithResponse => e
|
40
|
-
data = JSON.parse(e.response)
|
41
|
-
|
42
|
-
if e.is_a?(RestClient::TooManyRequests)
|
43
|
-
retry_after = data['retry_after'] / 1000.0
|
44
|
-
|
45
|
-
LOGGER.warn("rate limit exceeded, waiting #{retry_after} seconds")
|
46
|
-
sleep(retry_after)
|
47
|
-
retry
|
48
|
-
else
|
49
|
-
LOGGER.error("#{data['code']}: #{data['message']}")
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Types text into a particular channel
|
54
|
-
# @param [String, Integer] channel Channel ID
|
55
|
-
def type(channel)
|
56
|
-
request(:post, "channels/#{channel}/typing")
|
57
|
-
end
|
58
|
-
|
59
|
-
# Sends a message to a specific channel
|
60
|
-
# @param [String, Integer] channel Channel ID
|
61
|
-
# @param [String] message Message ID
|
62
|
-
def send_message(channel, message)
|
63
|
-
request(
|
64
|
-
:post, "channels/#{channel}/messages",
|
65
|
-
{}, { content: message }.to_json
|
66
|
-
)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Joins guild
|
70
|
-
# @param [String] invite Invite code
|
71
|
-
def join(invite)
|
72
|
-
request(
|
73
|
-
:post, "invites/#{invite}",
|
74
|
-
{ x_context_properties: 'eyJsb2NhdGlvbiI6Ik1hcmtkb3duIExpbmsifQ==' },
|
75
|
-
'{}'
|
76
|
-
)
|
77
|
-
end
|
78
|
-
|
79
|
-
# Reacts to a message
|
80
|
-
# @note To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id
|
81
|
-
# @param [String, Integer] channel Channel ID
|
82
|
-
# @param [String, Integer] message Message ID
|
83
|
-
# @param [String] emoji
|
84
|
-
def react(channel, message, emoji)
|
85
|
-
emoji = URI.encode_www_form_component(emoji)
|
86
|
-
|
87
|
-
request(
|
88
|
-
:put,
|
89
|
-
"channels/#{channel}/messages/#{message}/reactions/#{emoji}/@me",
|
90
|
-
{ params: { location: 'Message' } }
|
91
|
-
)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
data/lib/dsu3/core.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'dsu3/props'
|
4
|
-
require 'dsu3/bot'
|
5
|
-
|
6
|
-
module DSU3
|
7
|
-
# Class used to manage multiple bots
|
8
|
-
class Core
|
9
|
-
# @param [Array] tokens List of bot tokens
|
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) }
|
14
|
-
end
|
15
|
-
|
16
|
-
# (see Bot#type)
|
17
|
-
def typespam(channel)
|
18
|
-
loop do
|
19
|
-
@bots.each { |bot| bot.type(channel) }
|
20
|
-
sleep 9
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# (see Bot#send_message)
|
25
|
-
def send_message(channel, message)
|
26
|
-
@bots.each { |bot| bot.send_message(channel, message) }
|
27
|
-
end
|
28
|
-
|
29
|
-
# Infinitely calls a block and sends the value it returns to a specific channel
|
30
|
-
# @param [String, Integer] channel Channel ID
|
31
|
-
def spam(channel, &block)
|
32
|
-
loop { @bots.each { |bot| bot.send_message(channel, block.call) } }
|
33
|
-
end
|
34
|
-
|
35
|
-
# (see Bot#join)
|
36
|
-
def join(invite)
|
37
|
-
@bots.each do |bot|
|
38
|
-
bot.join(invite)
|
39
|
-
sleep(0.5)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# (see Bot#react)
|
44
|
-
def react(channel, message, emoji)
|
45
|
-
@bots.each { |bot| bot.react(channel, message, emoji) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|