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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc097e8e7e42bd943e3b030b01f532ecfdd8473eaaa93dac0e7e26f72a1722ac
4
- data.tar.gz: 9dfcbd1f8adcd76b419c8d451a39896d0dc6d267ce0d3fb76951cfd81cff4ab9
3
+ metadata.gz: 8f9ecde6c8836bfd46cea02acf33258d6671f59ec283917ce4cb50adbb78cedd
4
+ data.tar.gz: bf5e546ca7985a2892ddf02859c3cb18ee12e90919542d780742972816b0c58a
5
5
  SHA512:
6
- metadata.gz: 60a2fca24755bd820a3f11cea0ecb51f9596d544c1b293e173c200bc1d1b2f8a1ba473e6834b79bbdd3d0a421a07ad0e2ae4940c9a571c82f51a2fd957f19bfa
7
- data.tar.gz: de05850f251b1b3c2726624733a6cac04c19829dd56e1f469450b409eb91ba203a65738f1b569a284e270c706d72a999cd2574d3df15ce7e937e4c7975718d18
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
 
@@ -50,6 +50,7 @@ module Bot
50
50
  # bot.execute
51
51
  #
52
52
  class ReviewMedia < Bot::Base
53
+ DETAIL = "low"
53
54
  # read function to execute the PostgresDB Read component
54
55
  #
55
56
  def read
@@ -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.write_media_text(params)
63
+ response = Utils::Discord::Request.split_paragraphs(params)
64
64
 
65
- if response.code == 200
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: response.parsed_response, status_code: response.code } }
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
- HTTParty.post(url_message, { body: message_body.to_json, headers: })
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bas
4
4
  # Gem version
5
- VERSION = "1.5.1"
5
+ VERSION = "1.5.3"
6
6
  end
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gmail_xoauth