TextChatMessage

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建

代表文本聊天消息的不可变数据对象。

要了解如何使用 TextChatMessages,请参阅 体验内文本聊天

概要

属性

属性

BubbleChatMessageProperties

读取并联

ChatWindowMessageProperties

读取并联

MessageId

读取并联

TextChatMessage 的唯一标识符。

Metadata

读取并联

用于存储有关 TextChatMessage 的杂项数据的通用字段。TextChannel:SendAsync()TextChannel:DisplaySystemMessage() 的第二个参数用于填充此字段。

使用此字段在 TextChatService.OnIncomingMessageTextChannel.OnIncomingMessage 回调中为特殊消息应用额外格式。


local TextChatService = game:GetService("TextChatService")
local generalChannel: TextChannel = TextChatService:WaitForChild("TextChannels").RBXGeneral
generalChannel:DisplaySystemMessage("这是一个错误!", "Game.Error.Generic")
generalChannel:DisplaySystemMessage("找不到保存数据!", "Game.Error.SaveDataNotFound")
generalChannel:DisplaySystemMessage("你赢得了游戏!", "Game.Info.Win")
generalChannel:DisplaySystemMessage("你输了游戏!", "Game.Info.Lose")
generalChannel.OnIncomingMessage = function(message: TextChatMessage)
if string.find(message.Metadata, "错误") then
local overrideProperties = Instance.new("TextChatMessageProperties")
overrideProperties.TextColor = Color3.fromRGB(255, 0, 0)
return overrideProperties
elseif string.find(message.Metadata, "信息") then
local overrideProperties = Instance.new("TextChatMessageProperties")
overrideProperties.TextColor = Color3.fromRGB(0, 255, 150)
return overrideProperties
end
return nil
end

以下是聊天系统发出的默认系统消息的参考:

元数据描述
Roblox.ChatTranslation.ChatWindow.SystemMessage表示系统可能会为玩家翻译聊天消息。
Roblox.Notification.Friend.Joined当玩家的连接之一加入体验时显示。
Roblox.MessageStatus.Warning.Floodchecked当玩家发送的消息被服务器限速时显示。
Roblox.MessageStatus.Warning.TextFilterFailed当玩家发送的消息因文本过滤问题无法显示时显示。
Roblox.MessageStatus.Warning.InvalidPrivacySettings当玩家的隐私设置阻止他们发送消息时显示。
Roblox.MessageStatus.Warning.MessageTooLong当玩家发送的消息内容过长时显示。
Roblox.MessageStatus.Warning.Unknown当系统因未知原因未能发送玩家的消息时显示。
Roblox.Help.Info显示来自 RBXHelpCommand TextChatCommand 的响应。
Roblox.Version.Info显示来自 RBXVersionCommand TextChatCommand 的响应。
Roblox.Team.Success.NowInTeam当玩家的团队变更时显示。
Roblox.Team.Error.CannotTeamChatIfNotInTeam当玩家在未加入 Team 时触发 RBXTeamCommand TextChatCommand 时显示。
Roblox.Whisper.Info.Success当玩家成功开始耳语对话时显示。
Roblox.Whisper.Welcome.Sent当进入耳语 TextChannel 时显示。
Roblox.Whisper.Error.CannotWhisperToSelf来自 RBXWhisperCommand TextChatCommand 的错误响应。
Roblox.Whisper.Error.TargetDoesNotExist来自 RBXWhisperCommand TextChatCommand 的错误响应。
Roblox.Whisper.Error.TooManyMatches来自 RBXWhisperCommand TextChatCommand 的错误响应。
Roblox.Whisper.Error.Unknown来自 RBXWhisperCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.DoesNotExist来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.UserEmotesNotEnabled来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.TemporarilyUnavailable来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.NotSupported来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.SwitchToR15来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Emote.Error.AnimationPlaying来自 RBXEmoteCommand TextChatCommand 的错误响应。
Roblox.Mute.Error.PlayerNotFound来自 RBXMuteCommand TextChatCommand 的错误响应。
Roblox.Mute.Error.MultipleMatches来自 RBXMuteCommand TextChatCommand 的错误响应。
Roblox.Mute.Error.CannotMuteSelf来自 RBXMuteCommand TextChatCommand 的错误响应。
Roblox.Mute.Info.Success来自 RBXMuteCommand TextChatCommand 的成功响应。
Roblox.Unmute.Error.PlayerNotFound来自 RBXUnmuteCommand TextChatCommand 的错误响应。
Roblox.Unmute.Error.MultipleMatches来自 RBXUnmuteCommand TextChatCommand 的错误响应。
Roblox.Unmute.Error.CannotMuteSelf来自 RBXUnmuteCommand TextChatCommand 的错误响应。
Roblox.Unmute.Info.Success来自 RBXUnmuteCommand TextChatCommand 的成功响应。

PrefixText

读取并联

要添加到用户消息的前缀。支持 Rich Text,因此开发人员可以为此文本设置自定义属性以支持聊天标签。

默认情况下,TextChatMessage.PrefixTextTextSource 的名称,它是通过 TextSource.UserId 与用户的 Player.DisplayName 关联的。

读取并联

表示 TextChatMessage 的状态。

Text

读取并联

用户的过滤文本消息。不同用户可能会根据过滤规则从此属性接收不同的字符串。它可以是一个空字符串。

TextChannel

读取并联

对原始 TextChannel 的引用。

TextSource

读取并联

对原始 TextSource 的引用。

Timestamp

读取并联

消息最初发送的时间戳。

Translation

读取并联

代表根据用户的本地化设置翻译和过滤后的文本消息。系统不会在具有相同本地化设置或使用没有文本过滤支持的语言之间翻译消息,因此如果没有发生翻译,此属性可以是一个空字符串。有关自定义的细节,请参见 自定义翻译的消息

方法

活动