@quenty/chatproviderservice 9.19.0-canary.4db9577.0 → 9.19.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,11 +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.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)
6
+ # [9.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/chatproviderservice@9.18.0...@quenty/chatproviderservice@9.19.0) (2024-11-20)
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))
13
+ * Take encoded message data as parameter + make channel optional ([20071a8](https://github.com/Quenty/NevermoreEngine/commit/20071a874fd7dbe733fdc116789fa8993ef0a405))
7
14
 
8
15
 
9
16
  ### Features
10
17
 
18
+ * Add TextChannelUtils ([49fdd74](https://github.com/Quenty/NevermoreEngine/commit/49fdd7495ee83b23aa8e042f7055d080e50f9687))
11
19
  * Add way to send system messages ([4db9577](https://github.com/Quenty/NevermoreEngine/commit/4db95775860f06b6e4cd9793c6a0e6457a27a0e1))
12
20
 
13
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/chatproviderservice",
3
- "version": "9.19.0-canary.4db9577.0",
3
+ "version": "9.19.0",
4
4
  "description": "Provide wrapper around chat system to allow tags to be set",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -25,35 +25,35 @@
25
25
  "Quenty"
26
26
  ],
27
27
  "dependencies": {
28
- "@quenty/attributeutils": "14.13.0",
29
- "@quenty/baseobject": "10.7.1",
30
- "@quenty/binder": "14.15.0",
31
- "@quenty/brio": "14.13.0",
32
- "@quenty/clienttranslator": "14.14.0",
33
- "@quenty/cmdrservice": "13.16.0",
34
- "@quenty/color3utils": "11.13.0",
35
- "@quenty/datastore": "13.16.0",
36
- "@quenty/instanceutils": "13.13.0",
37
- "@quenty/loader": "10.7.1",
38
- "@quenty/localizedtextutils": "12.13.0",
39
- "@quenty/maid": "3.4.0",
40
- "@quenty/permissionprovider": "14.15.0",
41
- "@quenty/playerbinder": "14.15.0",
42
- "@quenty/playerutils": "8.13.0",
43
- "@quenty/preferredparentutils": "4.3.0",
44
- "@quenty/promise": "10.8.0",
45
- "@quenty/remoting": "12.14.0",
46
- "@quenty/richtext": "1.3.0",
47
- "@quenty/rx": "13.13.0",
48
- "@quenty/rxbinderutils": "14.15.0",
49
- "@quenty/servicebag": "11.10.0",
50
- "@quenty/signal": "7.9.0",
51
- "@quenty/string": "3.3.0",
52
- "@quenty/table": "3.7.0",
53
- "@quenty/valueobject": "13.13.0"
28
+ "@quenty/attributeutils": "^14.13.0",
29
+ "@quenty/baseobject": "^10.7.1",
30
+ "@quenty/binder": "^14.15.0",
31
+ "@quenty/brio": "^14.13.0",
32
+ "@quenty/clienttranslator": "^14.14.0",
33
+ "@quenty/cmdrservice": "^13.16.0",
34
+ "@quenty/color3utils": "^11.13.0",
35
+ "@quenty/datastore": "^13.16.0",
36
+ "@quenty/instanceutils": "^13.13.0",
37
+ "@quenty/loader": "^10.7.1",
38
+ "@quenty/localizedtextutils": "^12.13.0",
39
+ "@quenty/maid": "^3.4.0",
40
+ "@quenty/permissionprovider": "^14.15.0",
41
+ "@quenty/playerbinder": "^14.15.0",
42
+ "@quenty/playerutils": "^8.13.0",
43
+ "@quenty/preferredparentutils": "^4.3.0",
44
+ "@quenty/promise": "^10.8.0",
45
+ "@quenty/remoting": "^12.14.0",
46
+ "@quenty/richtext": "^1.3.0",
47
+ "@quenty/rx": "^13.13.0",
48
+ "@quenty/rxbinderutils": "^14.15.0",
49
+ "@quenty/servicebag": "^11.10.0",
50
+ "@quenty/signal": "^7.9.0",
51
+ "@quenty/string": "^3.3.0",
52
+ "@quenty/table": "^3.7.0",
53
+ "@quenty/valueobject": "^13.13.0"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "gitHead": "4db95775860f06b6e4cd9793c6a0e6457a27a0e1"
58
+ "gitHead": "12355519f67c56c5c2b7679b6e9065c84f7c03c5"
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"
@@ -19,8 +21,6 @@ function ChatProviderServiceClient:Init(serviceBag)
19
21
  self._serviceBag = assert(serviceBag, "No serviceBag")
20
22
  self._maid = Maid.new()
21
23
 
22
- self._systemMessageColors = {}
23
-
24
24
  -- State
25
25
  self.MessageIncoming = self._maid:Add(Signal.new())
26
26
 
@@ -40,12 +40,22 @@ function ChatProviderServiceClient:Start()
40
40
 
41
41
  local metadata = textChatMessage.Metadata
42
42
  if metadata then
43
- local systemColorProperties = self._systemMessageColors[metadata]
44
- if systemColorProperties then
45
- local overrideProperties = Instance.new("TextChatMessageProperties")
46
- overrideProperties.Text = string.format(systemColorProperties.Text, textChatMessage.Text)
47
-
48
- 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
49
59
  end
50
60
  end
51
61
 
@@ -66,26 +76,24 @@ function ChatProviderServiceClient:Start()
66
76
  end
67
77
  end
68
78
 
69
- function ChatProviderServiceClient:SendSystemMessage(channel, message, color)
70
- if not message then
71
- return
72
- end
73
-
74
- assert(typeof(channel) == "Instance" and channel.ClassName == "TextChannel", "[ChatProviderServiceClient.SendSystemMessage] - Bad channel")
75
- assert(typeof(color) == "Color3" or color == nil, "[ChatProviderServiceClient.SendSystemMessage] - Bad color")
76
-
77
- if color then
78
- local hex = color:ToHex()
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?)
85
+ assert(typeof(message) == "string", "[ChatProviderServiceClient.SendSystemMessage] - Bad message")
79
86
 
80
- if not self._systemMessageColors[hex] then
81
- local overrideProperties = Instance.new("TextChatMessageProperties")
82
- overrideProperties.Text = `<font color="#{hex}">%s</font>`
87
+ if not channel then
88
+ channel = TextChannelUtils.getDefaultTextChannel()
89
+ end
83
90
 
84
- self._systemMessageColors[hex] = overrideProperties
85
- end
91
+ if not channel then
92
+ warn("[ChatProviderServiceClient.SendSystemMessage] - Failed to get default channel")
93
+ return
86
94
  end
87
95
 
88
- channel:DisplaySystemMessage(message, color and color:ToHex())
96
+ channel:DisplaySystemMessage(message, encodedMessageData)
89
97
  end
90
98
 
91
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