MCCTeam / Minecraft-Console-Client

Lightweight console for Minecraft chat and automated scripts
https://mccteam.github.io
Other
1.64k stars 397 forks source link

Is it possible to control a bot using messengers? #1685

Closed iwixw closed 2 years ago

iwixw commented 3 years ago

Is it possible to control a bot using Telegram / VKontakte?

Daenges commented 3 years ago

Here is a script that can foreward messages between the client and VKontakte. But at the moment there is no way to control the bot directly through it. You could maybe get a second account on the server and activate this script on it. Then you could control the first account through remote control through minecraft chat messages.

Edit: If you only want to send server commands, you could try the script. It looks like this should work.

iwixw commented 3 years ago

Вот скрипт, который может обмениваться сообщениями между клиентом и ВКонтакте. Но на данный момент нет возможности управлять ботом непосредственно через него. Возможно, вы могли бы получить вторую учетную запись на сервере и активировать на ней этот скрипт. Затем вы можете управлять первой учетной записью через удаленное управление через сообщения чата minecraft.

Изменить: Если вы хотите только отправлять команды сервера, вы можете попробовать сценарий. Похоже, это должно сработать.

Can I use commands like: /msg, /ban, /mute, /tp With this script

Daenges commented 3 years ago

I am not sure, you should be able to do so. I would suggest to try it out.

iwixw commented 3 years ago

Я не уверен, что вы сможете это сделать. Я бы посоветовал вам попробовать это сделать.

Can you help with customizing the script?

Daenges commented 3 years ago

I am sorry, but I am neither the author, nor very familliar with VKontakte. It depends on what you want to do with it.

iwixw commented 3 years ago

image Where to get it from?

Daenges commented 3 years ago

Maybe @Nekiplay can help here?

iwixw commented 3 years ago

@Daenges friend, I was able to launch the bot. But there, to send a message to the server, it must start with a dot (.Hello) But the problem is that the message is sent to the server in the same way with a dot. Here's an example: I am sending a message: .Hello The server receives: .Hello image

How can you fix this? To send a message to the server without a dot

Daenges commented 3 years ago

You could replace this line SendText(text); with SendText(text.Remove(0,1));. Just open the .cs file with any text editor and replace it. This command should delete the first Character in the string (which is always the dot). Another way could be, that you remove the whole if (text.StartsWith(".")) { } bracket and replace it with only SendText(text); then all incoming text will be send to the chat.

iwixw commented 3 years ago

Вы можете заменить эту строку SendText(text); на SendText(text.Remove(0,1));. Просто откройте файл .cs в любом текстовом редакторе и замените его. Эта команда должна удалить первый символ в строке (который всегда является точкой). Другой способ может заключаться в том, что вы снимаете всю if (text.StartsWith(".")) { }скобку и заменяете ее только SendText(text);тогда, когда весь входящий текст будет отправлен в чат.

Thank you, now the next question is: D

How to display messages from chat in VK?

Daenges commented 3 years ago

Again, I am not familiar with this script, but the comment says: "// Example below: Forward a message to VKonrakte if it starts with a dot".

Hookw commented 3 years ago

@Daenges I found a script that can exchange messages between VK and the server. But there was a problem, the commands of the client itself by type: /move, /useitem, /script cannot be used. Do you know how to fix this?

Daenges commented 3 years ago

So there is a function to execute an internal command. You could make an if-statement in the script function, which receives the messages from vk and call an internal command if the message starts with a certain character.

Hookw commented 3 years ago

Таким образом, существует функция для выполнения внутренней команды. Вы можете сделать if-оператор в функции скрипта, которая получает сообщения от vk, и вызвать внутреннюю команду, если сообщение начинается с определенного символа.

Can you help me, please? Since I do not really understand this. I can give you the code

Daenges commented 3 years ago

I thought you would work with the script that is already integrated. It has all the functionality you want.

Hookw commented 3 years ago

@Daenges I tried to use the script that was in CONSOLE\config\ChatBots\VKMessager.cs (I still can't send MCC commands and I don't receive messages from the server to VK)

image

Daenges commented 3 years ago

Yeah. You need to configure the script. In the standard configuration this script only sends textmessages which start with a dot from Minacraft to VK and backwards. If you want to execute internal commands you need to program this into the script. (which is a one line change)

Hookw commented 3 years ago

Да. Вам нужно настроить скрипт. В стандартной конфигурации этот скрипт отправляет только текстовые сообщения, которые начинаются с точки от Minacraft до VK и обратно. Если вы хотите выполнять внутренние команды, вам нужно запрограммировать это в сценарий. (что является изменением в одну строку)

Can you help do this?

Daenges commented 3 years ago
private void ProcessMsgFromVk(string senderId, string peer_id, string text, string conversation_message_id, string id, string event_id)
    {
        // Here you can process a message coming from VKonrakte
        // Example below: Forward a message to Minecraft if it starts wit a dot

        if (text.StartsWith("."))
        {
            string response = "";
            PerformInternalCommand(text.Remove(0,1), ref response);
            LogToConsole(GetVerbatim(response));
        }
        else
        {
            SendText(text);
        }
    }

This should forward every command that starts with a dot to the client instead of the server.

Hookw commented 3 years ago
private void ProcessMsgFromVk(string senderId, string peer_id, string text, string conversation_message_id, string id, string event_id)
    {
        // Here you can process a message coming from VKonrakte
        // Example below: Forward a message to Minecraft if it starts wit a dot

        if (text.StartsWith("."))
        {
            string response = "";
            PerformInternalCommand(text.Remove(0,1), ref response);
            LogToConsole(GetVerbatim(response));
        }
        else
        {
            SendText(text);
        }
    }

This should forward every command that starts with a dot to the client instead of the server.

Where should it be inserted? image

Daenges commented 3 years ago

It should replace the whole function.

Hookw commented 3 years ago

https://pastebin.com/Smcr6HZp

Can you replace it please? Because I don't quite understand

Daenges commented 3 years ago

https://pastebin.com/4vYVj1eM

Hookw commented 3 years ago

thanks a lot

Hookw commented 3 years ago

@Daenges Can you try adding this function to a similar script? If you have free time Script: https://pastebin.com/hJbLiXbA

Daenges commented 3 years ago

Not really sure what the peer id exactly is, but I am assuming this is something like a channel ID on discord.. https://pastebin.com/2c7NBtG7

Hookw commented 3 years ago

Не совсем уверен, что именно такое peer id, но я предполагаю, что это что-то вроде идентификатора канала в discord.. https://pastebin.com/2c7NBtG7

Everything is working. Thank you very much for such a great help! I hope not so much nerves were spent on me :D

If anyone wants to use this script, here's what they can do: