Sending CTCP action to an IRC server using C#

时间:2015-09-01 22:17:46

标签: c# irc

I have encountered a problem that others seem to have also encountered, but their solutions don't seem to work for me:

Using \x01 send the message as "ACTION wave" with nothing else.

The solutions I've found but haven't worked are:

  • Using \001: message is interpret as "01ACTION waves" but I get a "No text to send" error.
  • Using \0001: same issue. Using \u0001: only sends "ACTION waves" but prints an unknown symbol before action.

Apparently the issue is the '\0' part where it interprets it as an escape character, is there a way to avoid this? I have tried the following three methods already:

writer.WriteLine("PRIVMSG " + CHANNEL + " :" + CONTROL + "ACTION " +
   message.Remove(0, 3) + CONTROL);

writer.WriteLine("PRIVMSG " + CHANNEL + " :" + "\u0001" + "ACTION " +
   message.Remove(0, 3) + "\u0001");

writer.Write(string.Format("PRIVMSG {0} :{1} ACTION {2}{1}", CHANNEL,
   CONTROL, message.Remove(0,3)));

Where CONTROL = either one of the values before mentioned.

1 个答案:

答案 0 :(得分:0)

A better more simple way will be using hex character \x01.

Code:

writer.WriteLine("PRIVMSG {0} :{1}ACTION {2}{1}", CHANNEL, '\x01', message.Remove(0, 3))