telegrama 0.3.0 → 0.3.1

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: 3ae6c6b2bb6c3da545107d0f91b63e490fbd6e7e5a6e6be633291346c9f6ebcb
4
- data.tar.gz: 42b7590b77f6497a8b972a97a1bb8cd371f89bf5db322bcd779b7d0a7ae9a331
3
+ metadata.gz: 1d31e0ac18148fac53c29577602d858f326781575376c6fd42c1e984fac1adc2
4
+ data.tar.gz: a41b7301c11863797a284bb4f1284d45e146f4c74126bd3b3e52d334945687d0
5
5
  SHA512:
6
- metadata.gz: 596ad2ca19bb16c3c50d83f0ee7891e4a0ffe44218f34de187497ddb23a58862695564183402abe3b13e290801dc3bcaf033e00330e26b5faf5da2d97eb6e3bd
7
- data.tar.gz: 810fe478ac180741ca83d2210eb179776ad815e647297cb037ad1d33a49cf0a81630bc27ac11a4393309ef4be23b23f330f0b75754c60cacaf37b78668adb658
6
+ metadata.gz: 9284e1584ca9874b51bc63ff968eb01822d9e5ac72fdfe36afaaf0fc995738e7c234f44dc52638216743f068819899fc596c38415efff64775ed21fa4e016f57
7
+ data.tar.gz: 1473e4fabcf750c0491f5a659b500190307f094158984d95b2f97a068ec9c90d60a85653af6efd2a0a6fbee706e48259bf2b61d0838872e094a7cc5b500a1567
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.1] - 2026-07-22
4
+
5
+ - Fixed MarkdownV2 escaping for `-` inside link text: the link-text escape
6
+ class was missing the hyphen, so a label like `[GPS-risk](url)` reached
7
+ Telegram unescaped — the API rejects the entire message ("Character '-' is
8
+ reserved and must be escaped") and delivery fell back to unformatted plain
9
+ text. The escape regex is now derived from `MARKDOWN_SPECIAL_CHARS` so the
10
+ two can never drift apart again.
11
+
3
12
  ## [0.3.0] - 2026-05-22
4
13
 
5
14
  - Added support for sending messages to Telegram forum topics with `message_thread_id`
data/context7.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "url": "https://context7.com/rameerez/telegrama",
3
+ "public_key": "pk_HibNJE5rTFvy1txHHXUot"
4
+ }
@@ -7,6 +7,15 @@ module Telegrama
7
7
  # Characters used for Markdown formatting that need special handling
8
8
  MARKDOWN_FORMAT_CHARS = %w[* _].freeze
9
9
 
10
+ # Escapes every MarkdownV2-reserved character (plus backslash) inside link
11
+ # TEXT. Derived from MARKDOWN_SPECIAL_CHARS so the two can never drift: a
12
+ # hand-typed copy of this class was missing '-', which let hyphenated link
13
+ # labels ("[GPS-risk](url)") reach Telegram unescaped — and the API rejects
14
+ # the ENTIRE message, not just the link, so delivery fell back to raw
15
+ # unformatted text. (URL parts keep their own narrower class below: per the
16
+ # MarkdownV2 spec, inside the (...) part only ')' and '\' MUST be escaped.)
17
+ LINK_TEXT_ESCAPE_REGEX = /([#{Regexp.escape((MARKDOWN_SPECIAL_CHARS + [ "\\" ]).join)}])/
18
+
10
19
  # Error class for Markdown formatting issues
11
20
  class MarkdownError < StandardError; end
12
21
 
@@ -100,7 +109,7 @@ module Telegrama
100
109
  url_part = $2
101
110
 
102
111
  # Handle escaping within link text
103
- text_part = text_part.gsub(/([_*\[\]()~`>#+=|{}.!\\])/) { |m| "\\#{m}" }
112
+ text_part = text_part.gsub(LINK_TEXT_ESCAPE_REGEX) { |m| "\\#{m}" }
104
113
 
105
114
  # Escape special characters in URL (except parentheses which define URL boundaries)
106
115
  url_part = url_part.gsub(/([_*\[\]~`>#+=|{}.!\\])/) { |m| "\\#{m}" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telegrama
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegrama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javi R
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-05-22 00:00:00.000000000 Z
10
+ date: 2026-07-21 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -56,6 +56,7 @@ files:
56
56
  - LICENSE.txt
57
57
  - README.md
58
58
  - Rakefile
59
+ - context7.json
59
60
  - gemfiles/rails_7.2.gemfile
60
61
  - gemfiles/rails_8.0.gemfile
61
62
  - gemfiles/rails_8.1.gemfile