Search code examples
c#irc

Sending a string message to an IRC channel with C#


So I'm trying to make a simple IRC bot using C#, I have successfully connected to the channel and can receive and send messages, the problem is messages I'm trying to send get cut after the first space. I've already read the IRC Documentation an can't seem to find any reference or note specifying a certain format for message sending, so far this is how I'm doing it:

writer.WriteLine("PRIVMSG " + CHANNEL + " " + "Welcome back!");
                        writer.Flush(); 

Although the actual message comes from a variable, but either way it doesn't work.


Solution

  • You have to use colon (:) before the message, for example, like this (and it would be better to use string.Format):

    writer.WriteLine(string.Format("PRIVMSG {0} :{1}", CHANNEL, "Welcome back!"));
    writer.Flush();