Hello, I am writing an IRC client , to communicate with the internal IRC server of the twitch and I encountered the following problem: the request to the server does not work with a multi-line message (command list), because StreamWriter, when using the Flush () method, sends the Tcp data to the client without a packet, and in pieces OR tcpClient itself sends a request in pieces, not the essence. In general, the request is divided into pieces: (. As a result, in the case of line-by-line writing of the list of commands to the stream, the message is not displayed at all.

Tried to send a request with a message in one line with "\ n" in the right places - it cuts off everything after the first line of the command (displays the first line of the list of commands in the chat)

Question : Is it possible to send a request with a multi-line message to the irc server or not? If so, how? I attach the code:

public void sendChatMessage(string message) { sendIrcMessage(":" + userName + "!" + userName + "@" + userName + "twi.twitch.tv PRIVMSG #" + channel + " :@" + senderName + " " + message); } public void sendChatBroadcastChatMessage(string message) { sendIrcMessage(":" + userName + "!" + userName + "@" + userName + "twi.twitch.tv PRIVMSG #" + channel + " : " + message); } public void sendChatBroadcastChatMessage(List<string> messages) { messages.Insert(0, ":" + userName + "!" + userName + "@" + userName + "twi.twitch.tv PRIVMSG #" + channel + " : "); sendIrcMessage(messages); } 

userName - bot name, channel - channel name

  private void sendIrcMessage(List<string> messages) { try { if (outputStream == null) throw new Exception("Output stream is empty..."); foreach (var item in messages) { outputStream.WriteLine(item); } outputStream.Flush(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); return; } } 

messages in this case is a list of commands:

  "!hi - приветствие", "!date - дата и время сервера", "!commands - список команд" 

So, sendChatBroadcastChatMessage (messages) is called. In it, a request is added to the beginning of the message and the sendIrcMessage (messages) method is called with the updated list. I hope I told you in enough detail

Server response:

enter image description here Thank!

    1 answer 1

    En-so is said that the IRC protocol prohibits multi-line messages, referring to RFC 1459.

    See here: https://stackoverflow.com/questions/13898584/insert-line-breaks-into-an-irc-message

    Open the RFC: https://rfc2.ru/1459.rfc/print

    IRC messages always look like strings of characters ending in a pair of CR-LF characters (Carriage Return - Line Feed. Carriage Return - Translation of Strings) and a line length not exceeding 512 characters (CR-LF also includes 512). So, the maximum string length for commands and parameters is 510 characters. The line break is not possible. See section 7 for more details.

    So, alas, apparently not:

    Can I send a request with a multi-line message to the irc server or not? If so, how?

    We still have to look at it, there haven't been any new standards since then, redefining this RFC.

    Here is a list of standards to start watching: enter image description here

    • Hmm ... sad, thanks for pointing out what to work with) - Xambey