简体   繁体   中英

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. However, it only seems to send the first word of the sentence, and cuts the rest off, and I'm not sure why.

My C# file:

//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:

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.

Note: There doesn't seem to be a MCCScript tag, so I figured that the Minecraft tag was the closest approximation. If this does not belong here, please let me know.

see if

message = ' '.join(sys.argv[2:]))

fixes this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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