@quenty/chatproviderservice 9.18.1-canary.520.f23602e.0 → 9.19.0-canary.520.49fdd74.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.
package/CHANGELOG.md CHANGED
@@ -3,16 +3,19 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [9.18.1-canary.520.f23602e.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/chatproviderservice@9.18.0...@quenty/chatproviderservice@9.18.1-canary.520.f23602e.0) (2024-11-14)
6
+ # [9.19.0-canary.520.49fdd74.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/chatproviderservice@9.18.0...@quenty/chatproviderservice@9.19.0-canary.520.49fdd74.0) (2024-11-20)
7
7
 
8
8
 
9
9
  ### Bug Fixes
10
10
 
11
11
  * Create properties from metadata instead of caching ([f23602e](https://github.com/Quenty/NevermoreEngine/commit/f23602e73a41ce4135ca18bc4ab7f01e935b2cab))
12
+ * pcall metadata in case it isn't a hex color ([0c6df93](https://github.com/Quenty/NevermoreEngine/commit/0c6df93f4e611dcdcf8c1fde454ee4bf7fa43ef0))
13
+ * Take encoded message data as parameter + make channel optional ([20071a8](https://github.com/Quenty/NevermoreEngine/commit/20071a874fd7dbe733fdc116789fa8993ef0a405))
12
14
 
13
15
 
14
16
  ### Features
15
17
 
18
+ * Add TextChannelUtils ([49fdd74](https://github.com/Quenty/NevermoreEngine/commit/49fdd7495ee83b23aa8e042f7055d080e50f9687))
16
19
  * Add way to send system messages ([4db9577](https://github.com/Quenty/NevermoreEngine/commit/4db95775860f06b6e4cd9793c6a0e6457a27a0e1))
17
20
 
18
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/chatproviderservice",
3
- "version": "9.18.1-canary.520.f23602e.0",
3
+ "version": "9.19.0-canary.520.49fdd74.0",
4
4
  "description": "Provide wrapper around chat system to allow tags to be set",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -55,5 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "gitHead": "f23602e73a41ce4135ca18bc4ab7f01e935b2cab"
58
+ "gitHead": "49fdd7495ee83b23aa8e042f7055d080e50f9687"
59
59
  }
@@ -4,12 +4,14 @@
4
4
 
5
5
  local require = require(script.Parent.loader).load(script)
6
6
 
7
- local TextChatService = game:GetService("TextChatService")
7
+ local HttpService = game:GetService("HttpService")
8
8
  local Players = game:GetService("Players")
9
+ local TextChatService = game:GetService("TextChatService")
9
10
 
10
11
  local Maid = require("Maid")
11
12
  local Signal = require("Signal")
12
13
  local String = require("String")
14
+ local TextChannelUtils = require("TextChannelUtils")
13
15
 
14
16
  local ChatProviderServiceClient = {}
15
17
  ChatProviderServiceClient.ServiceName = "ChatProviderServiceClient"
@@ -38,12 +40,22 @@ function ChatProviderServiceClient:Start()
38
40
 
39
41
  local metadata = textChatMessage.Metadata
40
42
  if metadata then
41
- local isValidColor = Color3.fromHex(metadata)
42
- if isValidColor then
43
- local overrideProperties = Instance.new("TextChatMessageProperties")
44
- overrideProperties.Text = `<font color="#{metadata}">{textChatMessage.Text}</font>`
45
-
46
- return overrideProperties
43
+ local success, decodedMessageData = pcall(function()
44
+ return HttpService:JSONDecode(metadata)
45
+ end)
46
+
47
+ if success and decodedMessageData then
48
+ local color = decodedMessageData.Color or "#ffffff"
49
+ local isValidHex = pcall(function()
50
+ return Color3.fromHex(color)
51
+ end)
52
+
53
+ if isValidHex then
54
+ local overrideProperties = Instance.new("TextChatMessageProperties")
55
+ overrideProperties.Text = `<font color="#{color}">{textChatMessage.Text}</font>`
56
+
57
+ return overrideProperties
58
+ end
47
59
  end
48
60
  end
49
61
 
@@ -64,12 +76,24 @@ function ChatProviderServiceClient:Start()
64
76
  end
65
77
  end
66
78
 
67
- function ChatProviderServiceClient:SendSystemMessage(channel: TextChannel, message: string, color: Color3?)
68
- assert(typeof(channel) == "Instance" and channel.ClassName == "TextChannel", "[ChatProviderServiceClient.SendSystemMessage] - Bad channel")
79
+ --[=[
80
+ Sends a system message to the provided TextChannel.
81
+ @param encodedMessageData string
82
+ @param channel TextChannel?
83
+ ]=]
84
+ function ChatProviderServiceClient:SendSystemMessage(message: string, encodedMessageData: string?, channel: TextChannel?)
69
85
  assert(typeof(message) == "string", "[ChatProviderServiceClient.SendSystemMessage] - Bad message")
70
- assert(typeof(color) == "Color3" or color == nil, "[ChatProviderServiceClient.SendSystemMessage] - Bad color")
71
86
 
72
- channel:DisplaySystemMessage(message, color and color:ToHex())
87
+ if not channel then
88
+ channel = TextChannelUtils.getDefaultTextChannel()
89
+ end
90
+
91
+ if not channel then
92
+ warn("[ChatProviderServiceClient.SendSystemMessage] - Failed to get default channel")
93
+ return
94
+ end
95
+
96
+ channel:DisplaySystemMessage(message, encodedMessageData)
73
97
  end
74
98
 
75
99
  function ChatProviderServiceClient:_renderTags(textSource)
@@ -0,0 +1,29 @@
1
+ --[=[
2
+ Utility functions for querying text channels.
3
+ @class TextChannelUtils
4
+ ]=]
5
+
6
+ local require = require(script.Parent.loader).load(script)
7
+
8
+ local TextChatService = game:GetService("TextChatService")
9
+
10
+ local TextChannelUtils = {}
11
+
12
+ function TextChannelUtils.getDefaultTextChannel()
13
+ return TextChannelUtils.getTextChannel("RBXGeneral")
14
+ end
15
+
16
+ function TextChannelUtils.getTextChannel(channelName: string)
17
+ local channels = TextChannelUtils.getTextChannels()
18
+ if not channels then
19
+ return
20
+ end
21
+
22
+ return channels:FindFirstChild(channelName)
23
+ end
24
+
25
+ function TextChannelUtils.getTextChannels()
26
+ return TextChatService:FindFirstChild("TextChannels")
27
+ end
28
+
29
+ return TextChannelUtils