Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CTCP raw protocol ACTION command with in c#

Tags:

c#

irc

I was making a bot to connect to an irc for kicks and giggles and i was making it respond to different things, but i would like it to respond with the CTCP ACTION command, this is commonly known to a user as /me used for role playing or displaying action.

according to this great webpage about ctcp http://www.irchelp.org/irchelp/rfc/ctcpspec.html?

the format is \001ACTION barfs on the floor.\001

so i set up my bot to respond with

writer.WriteLine("PRIVMSG " + CHANNEL + " \001ACTION " + message + "\001");

i print out this result in my console as well, all it responds with is "No text to send"

which not really knowing what that is suppose to tell me, i assume the escape character is breaking the line early with the \0 totally ignoring the other 01 after it, so i have the bot print out in the console what ever it reads and i type /me dances and i read in the console

PRIVMSG CHANNEL :(odd symbol)ACTION message(odd symbol) i do not know what the odd symbols are but to me they look like smiley faces ..... after talking to a few people, i understand that the format is correct but the \001 may be different for different languages

so i look up what \001 could mean for c# and i fin \x01 and \0011 and the \0011 doesn't do anything and the \x01 also returns me the same response.... "No text to send"

I print "PRIVMSG " + CHANNEL + " \x01ACTION " + message + "\x01" to my console, and i the \x01 is replaced with the same smiley face character that it shows when i type /me dances and have my bot print out what it reads to the console...

my code for it is simply

 if (type == MessageType.ActionMessage)
            {
                writer.WriteLine("PRIVMSG " + CHANNEL + " \x01ACTION " + message + "\x01");
                Console.WriteLine("PRIVMSG " + CHANNEL + " \x01ACTION " + message + "\x01");
                writer.Flush();
            }

the writer object is not null, and writing it to my console is so i can see what happens

The ultimate question is, is this correct and if it's not what is the correct way to show an action via c# client to client protocol CTCP

like image 667
A'sa Dickens Avatar asked Apr 28 '13 11:04

A'sa Dickens


2 Answers

i finally figured it out \x01 is the proper escape character for \001 , but \x01 is hexadecimal and escape characters are 2 bytes soooo..... \x01AC is a valid escape character .... so i either had to make it \0001 or have the escape character in it's own string "\x01" +"ACTION action struff\x01" that way the compiler, or w/e handles it, doesn't mistake the A and C as part of the escape character

in C escape characters are 1 byte so \001 or \x01 would not cause the A and C to be part of it ....

like image 189
A'sa Dickens Avatar answered Nov 07 '22 16:11

A'sa Dickens


Here is the syntax for the PRIVMSG command:

PRIVMSG target :Here is your message

You probably only forgot the : that is the delimiter for the beginning of the message, which would explain the No text to send error.

like image 27
Jessy Amyot Avatar answered Nov 07 '22 16:11

Jessy Amyot