CTCP raw protocol ACTION command with in c#
Asked Answered
B

3

6

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

Bandore answered 28/4, 2013 at 11:25 Comment(0)
B
12

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 ....

Bandore answered 1/5, 2013 at 1:40 Comment(0)
T
2

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.

Theresiatheresina answered 29/4, 2013 at 7:1 Comment(1)
i posted my results for the answer, thank you for responding thoughChassepot
V
0

Use \u0001 instead of \x01 to avoid subsequent hex letters being treated as part of the escape sequence.

Vedavedalia answered 3/3, 2023 at 15:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.