dsu3 0.2.0 → 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 +4 -4
- data/lib/dsu3/bot.rb +33 -4
- data/lib/dsu3/core.rb +7 -3
- data/lib/dsu3/props.rb +2 -1
- data/lib/dsu3.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bdb56aba1f99a4481ab5f9f77ca5b0ce9225018bc63e9ee6d2c6328293b4bd4
|
4
|
+
data.tar.gz: 4e21edf7b3a559d2df17051d80afabf2ddfc2092173a0c21ad3799790cd3e866
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23353ec18dc576ed7013887bf3807b8c9c180271de19ffaa6e064785fe587175cd44d70ef7096a162b342032bcc8395914e6bc54c03bf252ffec21c888545bde
|
7
|
+
data.tar.gz: 41d794a77c78de9dac650012f841c3ddb921ef38080dda5d3e654c1e0a8974b5fc9f80a2964e91fc642c5fe168a351e1202357cec6aa2fc0072283068aea25a0
|
data/lib/dsu3/bot.rb
CHANGED
@@ -29,13 +29,27 @@ module DSU3
|
|
29
29
|
|
30
30
|
begin
|
31
31
|
RestClient::Request.execute(args)
|
32
|
-
rescue RestClient::
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
36
44
|
end
|
37
45
|
end
|
38
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
|
+
|
39
53
|
# Sends a message to a specific channel
|
40
54
|
# @param [String, Integer] channel Channel ID
|
41
55
|
# @param [String] message
|
@@ -55,5 +69,20 @@ module DSU3
|
|
55
69
|
'{}'
|
56
70
|
)
|
57
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
|
58
87
|
end
|
59
88
|
end
|
data/lib/dsu3/core.rb
CHANGED
@@ -12,11 +12,10 @@ module DSU3
|
|
12
12
|
@bots = tokens.map { |token| Bot.new(headers.merge(authorization: token)) }
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
16
|
-
# @param [String, Integer] channel Channel ID
|
15
|
+
# (see Bot#type)
|
17
16
|
def typespam(channel)
|
18
17
|
loop do
|
19
|
-
@bots.each
|
18
|
+
@bots.each(&:type)
|
20
19
|
sleep 9
|
21
20
|
end
|
22
21
|
end
|
@@ -39,5 +38,10 @@ module DSU3
|
|
39
38
|
sleep(0.5)
|
40
39
|
end
|
41
40
|
end
|
41
|
+
|
42
|
+
# (see Bot#react)
|
43
|
+
def react(channel, message, emoji)
|
44
|
+
@bots.each { |bot| bot.react(channel, message, emoji) }
|
45
|
+
end
|
42
46
|
end
|
43
47
|
end
|
data/lib/dsu3/props.rb
CHANGED
@@ -40,7 +40,8 @@ module DSU3
|
|
40
40
|
x_debug_options: 'bugReporterEnabled',
|
41
41
|
x_discord_locale: 'en-US',
|
42
42
|
x_super_properties: Base64.strict_encode64(SUPER_PROPERTIES.to_json),
|
43
|
-
content_type: 'application/json'
|
43
|
+
content_type: 'application/json',
|
44
|
+
origin: 'https://discord.com'
|
44
45
|
}.freeze
|
45
46
|
|
46
47
|
# Gets the headers necessary for normal interaction with the Discord API
|
data/lib/dsu3.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsu3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artur Sheremetjev IV
|
@@ -42,6 +42,7 @@ licenses:
|
|
42
42
|
metadata:
|
43
43
|
source_code_uri: https://github.com/hackers-pr/dsu3
|
44
44
|
bug_tracker_uri: https://github.com/hackers-pr/dsu3/issues
|
45
|
+
wiki_uri: https://www.rubydoc.info/gems/dsu3
|
45
46
|
post_install_message:
|
46
47
|
rdoc_options: []
|
47
48
|
require_paths:
|