如何让不和谐机器人使用 webhook 从 shell 终端发送彩色文本

问题描述 投票:0回答:2
webhook=https://discord.com/api/webhooks/abc123
curl -H "Content-Type: application/json" -X POST -d '{"content":"'"some message"'"}' $webhook

这只是一个简单的 bash 脚本,用于使用 Webhook 向 Discord 发送消息。但是有没有办法发送彩色文本来不和谐呢?我知道我们可以在不和谐上输入彩色文本,但如何从终端发送它?更清楚地说,如何让不和谐机器人发送彩色文本?

bash discord webhooks
2个回答
1
投票

一个黑客解决方案从这里 - https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51#syntax-highlighting

基于语法突出显示颜色。

您可以在 Discord UI 中尝试。

如果您发布这样的消息:

```diff
+ line 1 asdasd
+ line 2 qwqwe
```

它应该是绿色的(每行开头必须包含“+”)

如果您发布这样的消息:

```diff
- line 3 asdasd
- line 4 qwqwe
```

它将是红色的(每行开头必须包含“-”)

在 shell 中,您需要在消息两边使用双引号 (

-d "..."
),使用反斜杠(如
\"
)转义引号和反引号,并使用
\n
来分隔行:

-d "{\"content\": \"\`\`\`diff\n+ green\n\`\`\`\"}"

0
投票

以上对我不起作用。

发送 DiscordNotification -消息“

diff -Your text here.

为我工作。但我通过 powershell 使用 webhook。

我在网上找不到任何相关信息,chatGPT 也无法破解这个问题,也说 webhook 无法处理不和谐的颜色代码。希望有人找到这个并帮助他们。和平。

© www.soinside.com 2019 - 2024. All rights reserved.