bas 1.5.1 → 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 +6 -0
- data/lib/bas/bot/review_media.rb +1 -0
- data/lib/bas/bot/write_media_review_in_discord.rb +4 -20
- data/lib/bas/utils/discord/request.rb +15 -3
- 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
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
# 1.5.3 (28.10.2024)
|
4
|
+
- [Fix response length limitations](https://github.com/kommitters/bas/issues/112)
|
5
|
+
|
6
|
+
# 1.5.2 (08.10.2024)
|
7
|
+
- [Change some details in Discord utils and review media](https://github.com/kommitters/bas/issues/108)
|
8
|
+
|
3
9
|
# 1.5.1 (08.10.2024)
|
4
10
|
- [Refactor Discord Bots Logic to conform with discord_bot implementation](https://github.com/kommitters/bas/issues/105)
|
5
11
|
|
data/lib/bas/bot/review_media.rb
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,11 +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
|
-
message_body = { content: params[:body] }
|
45
44
|
headers = headers(params[:secret_token])
|
46
|
-
|
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
|
47
59
|
end
|
48
60
|
|
49
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
|