@quenty/chatproviderservice 9.18.1-canary.520.d3b0387.0 → 9.19.0-canary.4db9577.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,13 +3,7 @@
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.d3b0387.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/chatproviderservice@9.18.0...@quenty/chatproviderservice@9.18.1-canary.520.d3b0387.0) (2024-11-14)
7
-
8
-
9
- ### Bug Fixes
10
-
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))
6
+ # [9.19.0-canary.4db9577.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/chatproviderservice@9.18.0...@quenty/chatproviderservice@9.19.0-canary.4db9577.0) (2024-11-14)
13
7
 
14
8
 
15
9
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/chatproviderservice",
3
- "version": "9.18.1-canary.520.d3b0387.0",
3
+ "version": "9.19.0-canary.4db9577.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": "d3b0387eb1eb87f8edf968cea0253fbd745ded62"
58
+ "gitHead": "4db95775860f06b6e4cd9793c6a0e6457a27a0e1"
59
59
  }
@@ -19,6 +19,8 @@ function ChatProviderServiceClient:Init(serviceBag)
19
19
  self._serviceBag = assert(serviceBag, "No serviceBag")
20
20
  self._maid = Maid.new()
21
21
 
22
+ self._systemMessageColors = {}
23
+
22
24
  -- State
23
25
  self.MessageIncoming = self._maid:Add(Signal.new())
24
26
 
@@ -38,13 +40,10 @@ function ChatProviderServiceClient:Start()
38
40
 
39
41
  local metadata = textChatMessage.Metadata
40
42
  if metadata then
41
- local isValidColor = pcall(function()
42
- return Color3.fromHex(metadata)
43
- end)
44
-
45
- if isValidColor then
43
+ local systemColorProperties = self._systemMessageColors[metadata]
44
+ if systemColorProperties then
46
45
  local overrideProperties = Instance.new("TextChatMessageProperties")
47
- overrideProperties.Text = `<font color="#{metadata}">{textChatMessage.Text}</font>`
46
+ overrideProperties.Text = string.format(systemColorProperties.Text, textChatMessage.Text)
48
47
 
49
48
  return overrideProperties
50
49
  end
@@ -67,17 +66,25 @@ function ChatProviderServiceClient:Start()
67
66
  end
68
67
  end
69
68
 
70
- --[=[
71
- Sends a system message to the provided TextChannel.
72
- @param channel TextChannel
73
- @param message string
74
- @param color Color3?
75
- ]=]
76
- function ChatProviderServiceClient:SendSystemMessage(channel: TextChannel, message: string, color: Color3?)
69
+ function ChatProviderServiceClient:SendSystemMessage(channel, message, color)
70
+ if not message then
71
+ return
72
+ end
73
+
77
74
  assert(typeof(channel) == "Instance" and channel.ClassName == "TextChannel", "[ChatProviderServiceClient.SendSystemMessage] - Bad channel")
78
- assert(typeof(message) == "string", "[ChatProviderServiceClient.SendSystemMessage] - Bad message")
79
75
  assert(typeof(color) == "Color3" or color == nil, "[ChatProviderServiceClient.SendSystemMessage] - Bad color")
80
76
 
77
+ if color then
78
+ local hex = color:ToHex()
79
+
80
+ if not self._systemMessageColors[hex] then
81
+ local overrideProperties = Instance.new("TextChatMessageProperties")
82
+ overrideProperties.Text = `<font color="#{hex}">%s</font>`
83
+
84
+ self._systemMessageColors[hex] = overrideProperties
85
+ end
86
+ end
87
+
81
88
  channel:DisplaySystemMessage(message, color and color:ToHex())
82
89
  end
83
90