[英]MCCScript only sending the first word of chat message in Discord webhook
I have a C# script that listens for and executes a Python file whenever a message is sent in chat in a given server.我有一个 C# 脚本,每当在给定服务器的聊天中发送消息时,它都会监听并执行 Python 文件。 However, it only seems to send the first word of the sentence, and cuts the rest off, and I'm not sure why.但是,它似乎只发送了句子的第一个单词,并切断了 rest,我不知道为什么。
My C# file:我的 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("'", "ꞌ")
+ "'"
);
}
}
}
The Python webhook file: 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()
The python file sends the messages just fine in the Discord channel, but only sends the first word of the sentence in a chat message. python 文件在 Discord 频道中发送消息很好,但只发送聊天消息中句子的第一个单词。
Note: There doesn't seem to be a MCCScript tag, so I figured that the Minecraft tag was the closest approximation.注意:似乎没有 MCCScript 标签,所以我认为 Minecraft 标签是最接近的近似值。 If this does not belong here, please let me know.如果这不属于这里,请告诉我。
see if看看
message = ' '.join(sys.argv[2:]))
fixes this issue.修复了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.