ThemisToDiscord

插件

· 作者 EarthCow

通过 Webhook 将 Themis 通知发送到 Discord。

0 本站下载 0 关注 更新于 5 个月前

最新 0.3.1 · 26.1.2 · Paper / Purpur

一键开服(送7天)

ThemisToDiscord

此前仅在 GitHub 和 SpigotMC 上提供,ThemisToDiscord 现已在 Modrinth 上发布!

向 Discord Webhook 发送嵌入式的 Themis 通知。

这是一个非官方插件,与 Themis 项目没有任何关联。

安装

依赖 Themis。如果你想在配置文件中使用的 %os% 占位符,你还需要 Floodgate。

  1. 将 ThemisToDiscord.jar 文件放入你的 /plugins 文件夹中。
  2. 启动或重启服务器。
  3. 运行 /ttd url <webhookUrl>(将 <webhookUrl> 替换为你的 webhook URL)。
  4. 如有必要,请通过 /ttd reload 修改来配置你的消息。
  5. 可选:通过运行相应的命令 /ttd msg <message> <player:player_name> <type:detection_type> [score:score] [ping:ping] [tps:tps] 测试你的消息,以确保设置正常运行。

处理机制

你可以创建任意数量你需要的/想要的消息。对于每条消息,你都有定义 处理机制 的选项。

为此,你使用与 Themis 配置中包含的相同阈值和延迟。

  default:
    # 定义 ThemisToDiscord 是否应处理发送此消息
    # 如果将此消息的命令添加到你的 Themis action(s) 中,请禁用处理
    Handling:
      Enabled: true
      # 发送到 Discord 的通知最低分数是多少?
      execution-threshold: 10.0
      # 需要发生多少新违规才会再次发送通知?
      repetition-threshold: 5.0
      # 需要经过多少时间才会再次发送通知?
      repetition-delay: 10.0

如果缺少此选项或被禁用,ThemisToDiscord 将不会处理发送该消息。

这意味着发送消息的唯一方式是通过相应的命令:

/ttd msg <message> <player:player_name> <type:detection_type> [score:score] [ping:ping] [tps:tps]

让 Themis 处理消息的一个简单示例是:在 ThemisToDiscord 配置中禁用处理,然后将该消息的命令放置在类似如下的 Themis action 中:

  actions:
    # 此 action 的名称是什么?此名称必须是唯一的。
    notify:
      # Themis 运行此 action 的最低分数是多少?
      execution-threshold: 10.0
      # 需要发生多少新违规才会重复此 action?
      repetition-threshold: 5.0
      # 需要经过多少时间才会重复此 action?
      repetition-delay: 10.0
      # 应该运行哪些命令?你可以指定任意数量的命令,它们将按照列出的顺序运行。
      # 目前,你可以使用以下占位符:%player_name%, %detection_type%, %score%, %ping%, %tps%
      commands:
        - "themis notify §5[Themis] §4%player_name% §cwas flagged for §4%detection_type% §chacks!\n§c[Score: §4%score% §c| Ping: §4%ping% §c| TPS: §4%tps%§c]"
        - "ttd msg example player:%player_name% type:%detection_type% score:%score% ping:%ping% tps:%tps%"

JSON

你可以指定将通过 webhook URL 发送到 Discord 的实际 JSON 消息。这对于使用 设计消息非常有用。

一个小示例:

    # 定义用于构建消息的 json 数据
    # 如果你想使用 https://discohook.org/ 设计你的消息/嵌入,这很有用
    # 如果提供了 json,则忽略所有其他选项
    Json: >
      {
        "content": "Hello this is an example of including a JSON string!",
        "embeds": [
          {
            "title": "JSON Example",
            "description": "A little example of using JSON in a ThemisToDiscord message.",
            "color": 5055373,
            "fields": [
              {
                "name": "Example Field",
                "value": "Did you know, all placeholders will work inside JSON too!",
                "inline": true
              },
              {
                "name": "Another Field",
                "value": "This is another field!",
                "inline": true
              }
            ],
            "author": {
              "name": "%player_name%",
              "icon_url": "%avatar_url%"
            }
          }
        ],
        "attachments": []
      }

需要注意的是,如果提供了 JSON,所有其他选项(除了 webhook URL)都将被忽略。

默认颜色

所有这些颜色都可以通过配置文件进行修改。

检查类型 十六进制颜色 文本颜色
Boat Movement #875229 Light Brown
Flight / Y-Movement #3276bf Light Blue
Speed #d6e600 Neon Yellow
Spoofed Packets #ff0000 Neon Red
Timer / Blink #d61ad6 Neon Pink
Reach #6f1ad6 Neon Purple
Elytra Flight #afaeb0 Light Gray
Illegal Packets #141414 Black Shade

示例嵌入(完全可修改)

船移动 飞行 / Y轴移动 速度 伪造数据包 计时器 / 闪烁

Reach 鞘翅飞行 非法数据包

替代方案

对于已安装 DiscordSRV 的服务器,本插件可能并非必需。

DiscordSRV 自带命令 /discordsrv broadcast [#频道ID/#频道名称] <消息>,相关文档见此处。

该命令可将消息发送至指定频道;若省略频道参数,则默认发送至主频道。

因此,你可以在 Themis 配置文件的 actions 键中添加以下内容,以接收基本的 Discord 通知。

  actions:
    # 动作的名称是什么?此名称必须是唯一的。
    discord:
      # Themis 运行此动作的最低分数是多少?
      execution-threshold: 10.0
      # 需要发生多少次新的违规才能重复执行此动作?
      repetition-threshold: 5.0
      # 需要经过多长时间才能重复执行此动作?
      repetition-delay: 10.0
      # 应该运行哪些命令?你可以指定任意数量的命令,它们将按列出的顺序依次执行。
      # 目前,你可以使用以下占位符:%player_name%、%detection_type%、%score%、%ping%、%tps%
      commands:
        - "discordsrv broadcast #0000000000000000000 [Themis] **%player_name%** 因 *%detection_type%* 作弊行为被标记![分数: %score% | 延迟: %ping% | TPS: %tps%]"

你也可以简单地将该命令复制到任何现有的 Themis 动作中。

早在该插件创建之前,这种方法就已经广为人知。然而,并非所有服务器都使用 DiscordSRV,而 ThemisToDiscord 提供了更多的样式选项,包括通过 webhook 更改名称和头像,以及发送带有颜色编码的嵌入消息,而不是普通的通用消息。

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源