不可更改的数据对象,用于表示文字聊天消信息。
要了解有关使用 TextChatMessages 的更多信息,请参阅 体验内文字聊天 。
概要
属性
TextChatMessage的独一标识符。
用于存储有关 TextChatMessage 的杂项数据的通用领域。
用于添加到用户消信息的前缀。
指示 TextChatMessage 的状态。
用户的过滤文本消息。
对起源的参考 TextChannel .
对起源的参考 TextSource .
消息最初发送时的时戳。
翻译和过滤的文本消信息。
属性
BubbleChatMessageProperties
ChatWindowMessageProperties
Metadata
用于存储有关 TextChatMessage 的杂项数据的通用领域。TextChannel:SendAsync() 和 TextChannel:DisplaySystemMessage() 的第二个参数用于填充此字段。
使用此字段来在 TextChatService.OnIncomingMessage 和 TextChannel.OnIncomingMessage 回调中应用额外的格式化对特殊消息。
local TextChatService = game:GetService("TextChatService")
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
generalChannel:DisplaySystemMessage("This is an error!", "Game.Error.Generic")
generalChannel:DisplaySystemMessage("Could not find save data!", "Game.Error.SaveDataNotFound")
generalChannel:DisplaySystemMessage("You won the game!", "Game.Info.Win")
generalChannel:DisplaySystemMessage("You lost the game!", "Game.Info.Lose")
generalChannel.OnIncomingMessage = function(message: TextChatMessage)
if string.find(message.Metadata, "Error") then
local overrideProperties = Instance.new("TextChatMessageProperties")
overrideProperties.TextColor = Color3.fromRGB(255, 0, 0)
return overrideProperties
elseif string.find(message.Metadata, "Info") then
local overrideProperties = Instance.new("TextChatMessageProperties")
overrideProperties.TextColor = Color3.fromRGB(0, 255, 150)
return overrideProperties
end
return nil
end
如下是聊天系统发出的默认系统消息的参考:
<th>描述</th></tr></thead><tbody><tr><td><code>Roblox.ChatTranslation.ChatWindow.SystemMessage</code></td><td>表示系统可能会为玩家翻译聊天消息。</td></tr><tr><td><code>Roblox.Notification.Friend.加入</code></td><td>当玩家的朋友之一加入体验时显示。</td></tr><tr><td><code>Roblox.MessageStatus.警告arning.Floodchecked</code></td><td>当玩家发送消息时,服务器限制了消息速率时显示。</td></tr><tr><td><code>Roblox.MessageStatus.警告arning.TextFilter失败</code></td><td>当玩家发送的消息由于文本过滤问题无法显示时显示。</td></tr><tr><td><code>Roblox.MessageStatus.警告arning.InvalidPrivacySettings</code></td><td>当玩家的隐私设置阻止他们发送消信息时显示。</td></tr><tr><td><code>Roblox.MessageStatus.警告arning.Message太长</code></td><td>当玩家发送含有过长内容的消息时显示。</td></tr><tr><td><code>Roblox.MessageStatus.警告arning.Unknown</code></td><td>显示系统因未知原因无法发送玩家的消息时。</td></tr><tr><td><code>Roblox.Help.Info</code></td><td>显示来自 <code>RBXHelpCommand</code><code>Class.TextChatCommand</code> 的响应。</td></tr><tr><td><code>Roblox.Version.信息</code></td><td>显示来自 <code>RBXVersionCommand</code><code>Class.TextChatCommand</code> 的响应。</td></tr><tr><td><code>Roblox.Team.Success.NowInTeam</code></td><td>当玩家的团队发生变更时显示。</td></tr><tr><td><code>Roblox.Team.Error.不能团队聊天,如果不在团队中</code></td><td>当玩家触发 <code>RBX团队命令</code><code>Class.TextChatCommand</code> 而不在 <code>Class.Team</code> 上时显示。</td></tr><tr><td><code>Roblox.Whisper.Info.成功</code></td><td>当玩家成功启动悄悄话聊天时显示。</td></tr><tr><td><code>Roblox.Whisper.Welcome.Sent</code></td><td>当输入悄悄话 <code>Class.TextChannel</code> 时显示。</td></tr><tr><td><code>Roblox.Whisper.Error.不能向自己喃喃</code></td><td>来自 <code>RBXWhisperCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Whisper.Error.TargetDoesNotExist</code></td><td>来自 <code>RBXWhisperCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Whisper.Error.TooManyMatches</code></td><td>来自 <code>RBXWhisperCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Whisper.Error.未知</code></td><td>来自 <code>RBXWhisperCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.不存在</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.UserEmotesNotEnabled</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.暂时不可用</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.不支持</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.SwitchToR15</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Emote.Error.动画播放</code></td><td>来自 <code>RBXEmoteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Mute.Error.PlayerNotFound</code></td><td>来自 <code>RBXMuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Mute.Error.MultipleMatches</code></td><td>来自 <code>RBXMuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Mute.Error.不能静音自己</code></td><td>来自 <code>RBXMuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Mute.Info.成功</code></td><td>来自 <code>RBXMuteCommand</code><code>Class.TextChatCommand</code> 的成功回应。</td></tr><tr><td><code>Roblox.Unmute.Error.PlayerNotFound</code></td><td>来自 <code>RBXUnmuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Unmute.Error.MultipleMatches</code></td><td>来自 <code>RBXUnmuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Unmute.Error.CannotMuteSelf</code></td><td>来自 <code>RBXUnmuteCommand</code><code>Class.TextChatCommand</code> 的错误响应。</td></tr><tr><td><code>Roblox.Unmute.Info.成功</code></td><td>来自 <code>RBXUnmuteCommand</code><code>Class.TextChatCommand</code> 的成功回应。</td></tr></tbody>
元数据 |
---|
PrefixText
用于添加到用户的消信息的前缀。这支持富文本,因此开发人员可以为这段文本设置自定义属性,以支持聊天标签。
默认情况下, 是指与 通过 相关的用户的名称,这是 通过 的 。