chat_sdk-discord 0.7.0 → 0.8.0

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: 7c564873850d8fbf2fceb8ea472cca9a2b9bcad9a104d43c24daef348d98bb48
4
- data.tar.gz: 1cda95c4f066d1be9d84dfd1ea11951679d8363dc65ebfe7640118eed1eefca8
3
+ metadata.gz: 3fd28694400d17ed002d3ea0f10ecda942af1d7876e3aae7d8c597bee6c2efc3
4
+ data.tar.gz: d499bedd48317531a060bc98ba84903adbaa7f5a6bdc36f7390aa8ed71887e92
5
5
  SHA512:
6
- metadata.gz: 229ccb06fb2c36c9d36777942bb2f23a6ec79bc9762d0bdc9a7f1a3ae8e619f4b23a19281a380e5f7d2aeab5c92f11378e239b2f409dceed34edf29c5e113c51
7
- data.tar.gz: 0154ab9559ec3acd28663cc2f6ba2358e59a08ee07946bc0555ecddc45ca66d1bbd1b2b5f97f36d982c96d94a4470ad4f5590130eaab5e4e019da657340b7191
6
+ metadata.gz: f7961d7d7132594e22a6190a688d1fe2c0a6d1a10af57a8d73005d108c4f2c3de796ccb8f4aa2c6cd6c3d99ef330185f16d02983ab6da4652a32983cf7f0334b
7
+ data.tar.gz: cd8ff652419fee58920f4d54464aa3a04e25012f5cbb5cdca45d3d3d541d1de37faed54bbe23df878d07484fddb3edbf70a78a5817c49a263aa09c36806f3e32
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChatSDK
4
+ module Discord
5
+ class FormatConverter < ChatSDK::Format::Converter
6
+ # Discord → Markdown
7
+ def to_markdown(platform_text)
8
+ text = platform_text.to_s
9
+ return "" if text.empty?
10
+
11
+ # Convert user mentions: <@123456> → @123456
12
+ text = text.gsub(/<@!?(\d+)>/, '@\1')
13
+
14
+ # Convert channel mentions: <#123456> → #123456
15
+ text = text.gsub(/<#(\d+)>/, '#\1')
16
+
17
+ # Convert animated custom emoji: <a:name:id> → :name:
18
+ text = text.gsub(/<a:(\w+):\d+>/, ':\1:')
19
+
20
+ # Convert custom emoji: <:name:id> → :name:
21
+ text = text.gsub(/<:(\w+):\d+>/, ':\1:')
22
+
23
+ # Strip spoiler markers: ||text|| → text
24
+ text.gsub(/\|\|(.+?)\|\|/m, '\1')
25
+ end
26
+
27
+ # Markdown → Discord (mostly pass-through since Discord uses standard markdown)
28
+ def from_markdown(markdown)
29
+ text = markdown.to_s
30
+ return "" if text.empty?
31
+
32
+ text
33
+ end
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_sdk-discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quentin Rousseau
@@ -63,6 +63,7 @@ files:
63
63
  - lib/chat_sdk/discord/api_client.rb
64
64
  - lib/chat_sdk/discord/embed_renderer.rb
65
65
  - lib/chat_sdk/discord/event_parser.rb
66
+ - lib/chat_sdk/discord/format_converter.rb
66
67
  - lib/chat_sdk/discord/signature.rb
67
68
  homepage: https://github.com/rootlyhq/chat-sdk
68
69
  licenses: