Moderation SDK
How to use the Moderation SDK in your game.
阅读时间3 分钟最后更新于 4 天前
举报玩家
设置完成后,即可使用玩家的 UAS ID 并提供举报原因来举报玩家。 举报玩家后,您可以导航到 Unity Dashboard(Unity 后台)查看事件以及附加的举报信息。 如果您使用的是 Vivox v16.0.0 或更高版本的包,则举报者和被举报者所在频道的最后 15 分钟对话内容将附加到举报中。 以下是提交的举报示例:using Unity.Services.Moderation;using Unity.Services.Moderation.Models;using Unity.Services.Moderation.Exceptions;public async void Report(string userId){ // userId should be the UAS id of the reported player // eg: the currently logged in user id is accessible with // var MyUserId = AuthenticationService.Instance.PlayerId try { var report = Moderation.Instance.NewReport(userId, new ReportReason(ReportReason.Threat)); await Moderation.Instance.ReportPlayer(report); Debug.Log("Report submitted!"); } catch (ModerationServiceException e){ if (e.Reason == ModerationServiceExceptionReason.SelfReportError) { Debug.Log("Error: you can’t report yourself"); } else { Debug.Log($"Error: {e.Reason}"); } }}
举报原因
原因由 Unity 定义,并以数组的形式显示在游戏中:每个原因的常量可在 Moderation(审核)> Runtime(运行时)> Models(模型)> ReportReasons.cs 中找到。using Unity.Services.Moderation.Models;public ListReasons(){ foreach (var reason in ReportReason.PossibleReasons) { Debug.Log(reason); }}
常量 | 原因 |
|---|---|
| public const string AimSnapping | = "aim snapping"; |
| public const string Boosting | = "boosting"; |
| public const string Exploiting | = "exploiting"; |
| public const string Hacking | = "hacking"; |
| public const string Smurfing | = "smurfing"; |
| public const string UnrealisticMovement | = "unrealistic movement"; |
| public const string CollusionWithOpponent | = "collusion with opponent"; |
| public const string LeftMatch | = "left the match"; |
| public const string Inactive | = "inactive"; |
| public const string Sabotage | = "sabotage"; |
| public const string Spamming | = "spamming"; |
| public const string HateSpeech | = "hate speech"; |
| public const string PredatoryBehavior | = "predatory behavior"; |
| public const string NoiseDisruption | = "noise disruption"; |
| public const string Scamming | = "scamming"; |
| public const string Ads | = "ads"; |
| public const string Threat | = "threat"; |
| public const string VerbalAbuse | = "verbal abuse"; |
| public const string InappropriatePlayerName | = "player name"; |
操作
在审查事件时通过后台执行操作。 当执行操作后,被执行操作的用户登录时,您将从与 Moderation 服务集成的不同 UGS 包收到各种错误消息。错误将遵循错误响应中描述的访问控制约定。这是预期的行为。 一些 SDK 将提供一种机制,将这些错误包装成自己的异常,例如,当策略阻止用户访问通信时,Vivox SDK 将发出MintException包名称 | 异常 | 用例 |
|---|---|---|
| com.unity.services.authentication | RequestFailedException | 当玩家被封禁时,您将收到此异常,并在其 innerException 中显示一条 ACCOUNT_DISABLED 消息。 |
| com.unity.services.vivox | MintException | 如果玩家被阻止访问通信频道,则会抛出此异常并提供 403 状态代码。 |
证据管理
如果项目中安装了 Vivox 16.0.0 或更高版本,SDK 会自动包含举报者和被举报者玩家所在的频道列表。此外,还包括加入了这些频道的额外玩家名单。 为了更好地控制举报上下文,您可以在发送举报之前更改举报中包含的频道和玩家列表。var report = Moderation.Instance.NewReport(userId, new ReportReason(ReportReason.Threat));report.Players = new List<PlayerContext>(); // The list of extra players you want to include in Safe Voice screenings.report.VivoxChannels = new List<VivoxChannel>(); // The list of channels to be screened by Safe Voice.