bas 1.5.2 → 1.5.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/CHANGELOG.md +3 -0
- data/lib/bas/bot/write_media_review_in_discord.rb +4 -20
- data/lib/bas/utils/discord/request.rb +15 -2
- data/lib/bas/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f9ecde6c8836bfd46cea02acf33258d6671f59ec283917ce4cb50adbb78cedd
|
4
|
+
data.tar.gz: bf5e546ca7985a2892ddf02859c3cb18ee12e90919542d780742972816b0c58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cf193eb6e6460aa0a5670d04655b8ea9b51eb012721d3e1749dd70fede86150fa9ef17f45b355eae5b3233f5c448647b3ecf5cd16e78a19ad6a696a45bf4e56
|
7
|
+
data.tar.gz: 6ffca4b33a7dc68721a73230e64b86175f34df1b30abaf14346b7415bc60c81b8bca1afc4f1d8585c93e424d1e7334610b2d7340ea7032708a83546fab18a6f3
|
data/CHANGELOG.md
CHANGED
@@ -60,12 +60,12 @@ module Bot
|
|
60
60
|
def process
|
61
61
|
return { success: { review_added: nil } } if unprocessable_response
|
62
62
|
|
63
|
-
response = Utils::Discord::Request.
|
63
|
+
response = Utils::Discord::Request.split_paragraphs(params)
|
64
64
|
|
65
|
-
if response.
|
65
|
+
if !response.empty?
|
66
66
|
{ success: { message_id: read_response.data["message_id"], property: read_response.data["property"] } }
|
67
67
|
else
|
68
|
-
{ error: { message:
|
68
|
+
{ error: { message: "Response is empty" } }
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -88,27 +88,11 @@ module Bot
|
|
88
88
|
|
89
89
|
def params
|
90
90
|
{
|
91
|
-
body
|
91
|
+
body: read_response.data["review"],
|
92
92
|
secret_token: process_options[:secret_token],
|
93
93
|
message_id: read_response.data["message_id"],
|
94
94
|
channel_id: read_response.data["channel_id"]
|
95
95
|
}
|
96
96
|
end
|
97
|
-
|
98
|
-
def body
|
99
|
-
{ content: "#{toggle_title}\n\n#{read_response.data["review"]}\n\n#{mention_content}" }
|
100
|
-
end
|
101
|
-
|
102
|
-
def mention_content
|
103
|
-
author_name = read_response.data["author"]
|
104
|
-
"<@#{author_name}>"
|
105
|
-
end
|
106
|
-
|
107
|
-
def toggle_title
|
108
|
-
case read_response.data["media_type"]
|
109
|
-
when "images" then "Image review results"
|
110
|
-
when "paragraph" then "Text review results"
|
111
|
-
end
|
112
|
-
end
|
113
97
|
end
|
114
98
|
end
|
@@ -39,10 +39,23 @@ module Utils
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.write_media_text(params)
|
42
|
+
def self.write_media_text(params, combined_paragraphs)
|
43
43
|
url_message = URI.parse("#{DISCORD_BASE_URL}/channels/#{params[:channel_id]}/messages")
|
44
44
|
headers = headers(params[:secret_token])
|
45
|
-
|
45
|
+
body = { content: combined_paragraphs }.to_json
|
46
|
+
|
47
|
+
HTTParty.post(url_message, { body:, headers: })
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.split_paragraphs(params)
|
51
|
+
paragraphs = params[:body].split("--DIVISION--").map(&:strip).reject(&:empty?)
|
52
|
+
|
53
|
+
paragraphs.each_slice(2) do |paragraph|
|
54
|
+
next if paragraph.empty?
|
55
|
+
|
56
|
+
combined_paragraphs = paragraph.join("\n\n")
|
57
|
+
write_media_text(params, combined_paragraphs)
|
58
|
+
end
|
46
59
|
end
|
47
60
|
|
48
61
|
def self.headers(secret_token)
|
data/lib/bas/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kommitters Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gmail_xoauth
|