[英]MCCScript only sending the first word of chat message in Discord webhook
我有一個 C# 腳本,每當在給定服務器的聊天中發送消息時,它都會監聽並執行 Python 文件。 但是,它似乎只發送了句子的第一個單詞,並切斷了 rest,我不知道為什么。
我的 C# 文件:
//MCCScript 1.0
MCC.LoadBot(new DiscordBot());
//MCCScript Extensions
public class DiscordBot : ChatBot
{
public override void Initialize()
{
LogToConsole("Sucessfully Initialized!");
}
public override void GetText(string text)
{
text = message
text = GetVerbatim(text)
if (IsChatMessage(text, ref message))
{
System.Diagnostics.Process.Start(
@"C:\Users\Christian\AppData\Local\Programs\Python\Python38\python.exe", // Set path to python here
@"C:\Users\Christian\Desktop\MCC\relay.py" // Set path to your relay.py here
+ " '" + username.Replace("\\", "⧵").Replace("'", "'")
+ "' '" + message.Replace("\\", "⧵").Replace("'", "ꞌ")
+ "'"
);
}
}
}
Python webhook 文件:
from discord_webhook import DiscordWebhook
import sys
username = sys.argv[1]
message = sys.argv[2]
webhook = DiscordWebhook(url='https://discord.com/api/webhooks/XXXXXXXXX', content='<' + sys.argv[1] + '> ' + sys.argv[2])
webhook.execute()
python 文件在 Discord 頻道中發送消息很好,但只發送聊天消息中句子的第一個單詞。
注意:似乎沒有 MCCScript 標簽,所以我認為 Minecraft 標簽是最接近的近似值。 如果這不屬於這里,請告訴我。
看看
message = ' '.join(sys.argv[2:]))
修復了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.