Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Tutorial: Colorizing IRC messages

RISCfuture edited this page Sep 13, 2010 · 2 revisions

Autumn has a utility module called Autumn::Formatting that allows you to colorize and stylize your IRC messages. Within Autumn::Formatting are sub-modules for different kinds of IRC formatting. The methods of one of these sub-modules are added to your leaf. A sample use might look like this:

<pre> if system_is_working then stem.message "The system is currently: #{color :green}up#{uncolor}!" else stem.message "The system is currently: #{color :red}down#{uncolor}!" end </pre>

This will colorize the words “up” or “down” to make them more visible.

What goes on behind the scenes is a bit more tricky, however, and actually the result of much drama, trials, tribulations, and conspiracy. You can read more about it at ircle’s color FAQ if you wish.

To make a long story short, IRC does not have any defined standard on how to do formatting. Various IRC clients have had their own ways of doing formatting, and each one is different. Autumn supports a couple of different formatting standards. mIRC’s standard is the most popular, and is the default for new leaves. Unfortunately, this doesn’t mean it’s the best. The mIRC standard only allows for sixteen colors and can sometimes screw up your formatting.

You also have the option of using ircle’s formatting standard, which is more robust but supported by fewer clients. To customize which standard to use, set your leaf’s formatter option to the name of a module within Autumn::Formatting. For instance, to use ircle formatting, which is handled by the Autumn::Formatting::Ircle module, set your leaf’s formatter option to “Ircle”.