简体   繁体   中英

Python Twisted IRC, sending color messages

I'm fairly new to the twisted event driven programming in Python. I've made a basic bot with some fun functions and now I would like to expand by sending back colored text if a certain event triggers. I understand that some sort of encoding(?) has to take place, but other than that I have no clue where to begin.

How can I encode a string so that it appears as a colored message in most popular IRC clients such as irssi or mIRC?

您可以在Twisted中使用assembleFormattedText API,该API特别提到了mIRC颜色代码。

You just need to send PRIVMSG or notice with the correct formatting.

Sending ASCII \\3 followed by foreground,background colours will have the desired result. There are 15 standard foreground and background colours defined by most clients such as mIRC, HexChat etc.

For example:

PRIVMSG #channel :\35,3

\\2 toggles bold, and \\1 enables and disables underline.

This is partially already answered here: Embed mIRC Color codes into a C# literal? , the basic string format is always the same regardless of programming language.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM