将 mIRC 颜色代码嵌入到 C# 文字中?
我正在用 C# 开发一个简单的 irc 机器人,但我不知道如何将粗体/颜色等的典型 mirc 控制代码嵌入到字符串文字中。
有人能指出我该怎么做吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
此处描述了 mIRC 颜色代码格式。我猜您是在问如何在字符串中嵌入 ^C 。
这称为插入符号。根据 C0 和 C1 控制代码,^C 是:
嵌入在一个字符串:
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:
Embedded in a string:
我创建一个枚举并将控制代码的十六进制值分配给它们。
I create an enum and assign the hex values for the control codes to them.
在我的Python IRC机器人中,我可以使用\x02sometext\x02在irssi中大胆显示,它显示如下:
这是一些文本
至于颜色,我相信你正在寻找\x03AA ,BB,其中 A 是前景色,B 是背景色(您在 Ctrl+K 之后输入的颜色)。但不是 100% 确定。尝试使用 telnet 连接 IRC 客户端,并检查使用 Ctrl+K 时 mIRC 的作用。
你不太可能在 IRC 客户端之间获得标准的内聚行为...ANSI 转义码由更多老式主要 Unix 客户端(如 irssi)处理,而 mIRC 有时会做自己的事情。
In my Python IRC bot, I can get bold to show up in irssi using \x02sometext\x02, which shows up like:
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.
这可能取决于我正在使用的特定聊天库(ChatSharp),但我无法获得当前接受的答案。我最终得到的是:
This might be down to the specific chat library I was using (ChatSharp), but I couldn't get the current accepted answer to work. What I ended up with was: