onyxcord 3.2.5 → 3.2.7
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/onyxcord/core/version.rb +1 -1
- data/lib/onyxcord/internal/http.rb +25 -8
- data/lib/onyxcord/models/component.rb +0 -27
- data/lib/onyxcord/rest/client.rb +1 -0
- data/lib/onyxcord/webhooks/modal.rb +0 -44
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11790e2e347a44d298323d5f3fe9d01bda9a0c087a53452440d2bcaa80e141ec
|
|
4
|
+
data.tar.gz: aced6ea00fc6a5909654524c0c24c8ba9e50200a90528d4efdb20cd238ac4a98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a920b096a309c8ffd55af075dcd1e65321e107556d4559855f6cc3663c35a2f90c38baab65add1f623fc0bbdfd59e7f8f1d5574ac08c4dfeaad3218b0a34410d
|
|
7
|
+
data.tar.gz: 458f16d158eddb9b038ef2f3b03fe08e6477e49832508a3328d560d09664fd3081f33fca923119173d0824019e700c84702f15546303936e989247fdd235d569
|
|
@@ -54,19 +54,36 @@ module OnyxCord
|
|
|
54
54
|
|
|
55
55
|
module_function
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
POOL_OPTIONS = {
|
|
58
|
+
max_connections: 50,
|
|
59
|
+
max_connections_per_origin: 20,
|
|
60
|
+
pool_timeout: 10
|
|
61
|
+
}.freeze
|
|
62
|
+
|
|
63
|
+
# The shared HTTPX session with persistent, pooled connections.
|
|
58
64
|
def session
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
session_mutex.synchronize do
|
|
66
|
+
@session ||= HTTPX.plugin(:persistent)
|
|
67
|
+
.plugin(:follow_redirects)
|
|
68
|
+
.with(
|
|
69
|
+
fallback_protocol: 'http/1.1',
|
|
70
|
+
ssl: { alpn_protocols: ['http/1.1'] },
|
|
71
|
+
pool_options: POOL_OPTIONS
|
|
72
|
+
)
|
|
73
|
+
end
|
|
65
74
|
end
|
|
66
75
|
|
|
67
76
|
# Reset the HTTP session (useful for tests).
|
|
68
77
|
def reset!
|
|
69
|
-
|
|
78
|
+
session_mutex.synchronize do
|
|
79
|
+
@session&.close if @session.respond_to?(:close)
|
|
80
|
+
ensure
|
|
81
|
+
@session = nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def session_mutex
|
|
86
|
+
@session_mutex ||= Mutex.new
|
|
70
87
|
end
|
|
71
88
|
|
|
72
89
|
# Perform a raw HTTP request and return a {Response}.
|
|
@@ -49,12 +49,6 @@ module OnyxCord
|
|
|
49
49
|
class ActionRow
|
|
50
50
|
include Enumerable
|
|
51
51
|
|
|
52
|
-
DELEGATED_COMPONENT_METHODS = %i[
|
|
53
|
-
custom_id
|
|
54
|
-
value
|
|
55
|
-
values
|
|
56
|
-
].freeze
|
|
57
|
-
|
|
58
52
|
# @return [Integer] the numeric identifier of the action row.
|
|
59
53
|
attr_reader :id
|
|
60
54
|
|
|
@@ -90,13 +84,6 @@ module OnyxCord
|
|
|
90
84
|
def to_a
|
|
91
85
|
@components
|
|
92
86
|
end
|
|
93
|
-
|
|
94
|
-
DELEGATED_COMPONENT_METHODS.each do |name|
|
|
95
|
-
define_method(name) do
|
|
96
|
-
component = @components.first
|
|
97
|
-
component.public_send(name) if @components.one? && component.respond_to?(name)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
87
|
end
|
|
101
88
|
|
|
102
89
|
# An interactable button component.
|
|
@@ -498,14 +485,6 @@ module OnyxCord
|
|
|
498
485
|
|
|
499
486
|
# A parent component for interactive modal components.
|
|
500
487
|
class Label
|
|
501
|
-
# Methods from the wrapped interactive component that should remain
|
|
502
|
-
# available for legacy modal code that iterates over event.components.
|
|
503
|
-
DELEGATED_COMPONENT_METHODS = %i[
|
|
504
|
-
custom_id
|
|
505
|
-
value
|
|
506
|
-
values
|
|
507
|
-
].freeze
|
|
508
|
-
|
|
509
488
|
# @return [Integer] the numeric identifier of the label.
|
|
510
489
|
attr_reader :id
|
|
511
490
|
|
|
@@ -526,12 +505,6 @@ module OnyxCord
|
|
|
526
505
|
@description = data['description']
|
|
527
506
|
@component = Components.from_data(data['component'], @bot)
|
|
528
507
|
end
|
|
529
|
-
|
|
530
|
-
DELEGATED_COMPONENT_METHODS.each do |name|
|
|
531
|
-
define_method(name) do
|
|
532
|
-
@component.public_send(name) if @component.respond_to?(name)
|
|
533
|
-
end
|
|
534
|
-
end
|
|
535
508
|
end
|
|
536
509
|
|
|
537
510
|
# A surface that allows users to upload files in a modal.
|
data/lib/onyxcord/rest/client.rb
CHANGED
|
@@ -172,6 +172,7 @@ module OnyxCord::REST
|
|
|
172
172
|
retries += 1
|
|
173
173
|
raise unless retries < max_retries
|
|
174
174
|
|
|
175
|
+
::OnyxCord::Internal::HTTP.reset!
|
|
175
176
|
OnyxCord::LOGGER.warn("Temporary HTTP failure while sending request (#{e.class}), retrying")
|
|
176
177
|
OnyxCord::Internal::AsyncRuntime.sleep(retries * 0.5)
|
|
177
178
|
next
|
|
@@ -39,53 +39,9 @@ class OnyxCord::Webhooks::Modal
|
|
|
39
39
|
@components << LabelBuilder.new(...)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
# Add a legacy action row to the modal.
|
|
43
|
-
def row(id: nil)
|
|
44
|
-
@components << LegacyRowBuilder.new(id: id) { |row| yield row }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
42
|
# Add a text display component to the view.
|
|
48
43
|
# @see Webhooks::View::TextDisplayBuilder#initialize
|
|
49
44
|
def text_display(...)
|
|
50
45
|
@components << OnyxCord::Webhooks::View::TextDisplayBuilder.new(...)
|
|
51
46
|
end
|
|
52
|
-
|
|
53
|
-
class LegacyRowBuilder
|
|
54
|
-
def initialize(id: nil)
|
|
55
|
-
@id = id
|
|
56
|
-
@components = []
|
|
57
|
-
|
|
58
|
-
yield self if block_given?
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def text_input(style:, custom_id:, id: nil, min_length: nil, max_length: nil, required: nil, value: nil, placeholder: nil, label: nil)
|
|
62
|
-
@components << {
|
|
63
|
-
type: COMPONENT_TYPES[:text_input],
|
|
64
|
-
custom_id: custom_id,
|
|
65
|
-
id: id,
|
|
66
|
-
label: label,
|
|
67
|
-
style: LabelBuilder::TEXT_INPUT_STYLES[style] || style,
|
|
68
|
-
min_length: min_length,
|
|
69
|
-
max_length: max_length,
|
|
70
|
-
required: required,
|
|
71
|
-
value: value,
|
|
72
|
-
placeholder: placeholder
|
|
73
|
-
}.compact
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def file_upload(custom_id:, id: nil, min_values: nil, max_values: nil, required: nil)
|
|
77
|
-
@components << {
|
|
78
|
-
type: COMPONENT_TYPES[:file_upload],
|
|
79
|
-
custom_id: custom_id,
|
|
80
|
-
id: id,
|
|
81
|
-
min_values: min_values,
|
|
82
|
-
max_values: max_values,
|
|
83
|
-
required: required
|
|
84
|
-
}.compact
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def to_h
|
|
88
|
-
{ type: COMPONENT_TYPES[:action_row], id: @id, components: @components }.compact
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
47
|
end
|