繁体   English   中英

MCCScript 仅在 Discord webhook 中发送聊天消息的第一个字

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM