tags:

views:

1431

answers:

3

I'm working on a simple irc bot in C#, and I can't figure out how to embed the typical mirc control codes for bold/color etc into string literals.

Can someone point me towards how to do this?

+3  A: 

In my Python IRC bot, I can get bold to show up in irssi using \x02sometext\x02, which shows up like:

this is \x02some text\x02

this is some text

As for colors, I believe you're looking for \x03AA,BB where A is the foreground color and B the background color (what you'd type in after Ctrl+K). Not 100% for sure, though. Try connecting an IRC client using telnet, and check what mIRC does when you use Ctrl+K.

You're not likely to get a standard cohesive behavior across IRC clients...ANSI escape codes are processed by more of the old-fare staple Unix clients like irssi, and mIRC sometimes does its own thing.

Jed Smith
+1 for mentioning ANSI escape codes!
Anton Tykhyy
mIRC has it's own colour codes (denoted by \x03), and I believe this is well supported across atleast GUI clients these days. I'd probably take this route for an IRC client. Also, I doubt irssi and similar commandline clients parse the ANSI codes, they just parse them through to the console and let it worry about them.
Matthew Scharley
+8  A: 

The mIRC color code format is described here. I guess you're asking how to embed a ^C in a string.

This is known as Caret notation. According to C0 and C1 control codes, ^C is:

'\x03'

Embedded in a string:

"blabla \x035,12to be colored text and background\x03 blabla"
dtb
Or you might even write `"♥5,12to be colored♥ "`, the compiler shouldn't choke on this.
Anton Tykhyy
@Anton: Never mind, reread answer. I confuse them.
Jed Smith
This is not ANSI colour code. ANSI colour codes are: "\x1B[32,42m" etc
Matthew Scharley
A: 
char funnyChar = '\u0998';

string x = String.Format("Code here '{0}'",funnyChar);
Preet Sangha