Hack 21 Format Text

 < Day Day Up > 

figs/moderate.gif figs/hack21.gif

IRC does not limit you to using plain text. Add extra formatting, such as underlining and italics, to your messages .

Even though most IRC clients support color, simpler formatting can sometimes be more effective. Too much use of color tends to annoy people. In such circumstance, channel operators have at their disposal the option of banning the use of color . If this happens, it will still be possible to send messages with simpler formatting. To highlight a particular word in a message, you could underline it. To catch somebody's attention, you could make your message bold. To emphasize something, you could make it italic. All of these options are possible, regardless of channel restrictions.

4.6.1 Formatting Text in mIRC

mIRC lets you view and send formatted text. Many other IRC clients behave in similar ways. Three main types of text formatting are available from mIRC. All of these can be accessed by keyboard shortcuts. These styles are complementary, so you can make text both bold and underlined , for example.

4.6.1.1 Bold

When composing a line or message, the text can be formatted as bold by pressing Ctrl-B. You will see a control character appear in your message. Anything you type after this will appear in bold. You will not see the result of this until you actually send your message to the server.

4.6.1.2 Underline

You can underline part of your message by pressing Ctrl-U. This will cause a control character to be inserted into your message. Everything after this character will be underlined.

4.6.1.3 Italic or reversed

Italic text can also be used. However, because some clients are incapable of rendering italic text, you will find that most clients (including those that can render italic text) display this as normal text with the background and foreground colors swapped. For this reason, it is also known as reversed text formatting and can be achieved in mIRC by pressing Ctrl-R.

4.6.1.4 Normal

To return text to its unformatted state, press Ctrl-O. This removes all formatting, even if more than one style has been applied.

Combinations of these options are illustrated in Figure 4-14.

Figure 4-14. Combinations of formatting rendered by mIRC
figs/irch_0414.gif

4.6.2 Formatting Text with a Bot

Formatting text with the aforementioned attributes is simpler than applying colors, as only one control character is required for each style. There are no parameters to add after each style character.

4.6.2.1 Bold

Bold text can be achieved by prefixing the text with ASCII character 0x02 , which can be represented in Unicode as \u0002 . The following Java code creates a bold IRC message:

 String bold = "\u0002This is bold"; 

4.6.2.2 Underline

Text can be underlined with ASCII character 0x1F , which can be represented in Unicode as \u001F .

 String underlined = "\u001FThis is underlined"; 

4.6.2.3 Italic or reversed

Italic or reversed text is formatted with ASCII character 0x16 , or Unicode character \u0016 .

 String reversed = "\u0016This is reversed"; 

4.6.2.4 Normal

To remove all formatting from a message, use ASCII character 0x0F , or Unicode character \u000F . Any text after this point in the message will return to its normal state, unless other formatting characters are applied again.

 String mixture = "\u0002Bold\u000F and gone"; 

4.6.3 Formatting Text with PircBot

The Colors class in the PircBot Java IRC API [Hack #35] contains useful constants, not only for coloring, but also for formatting text with these styles. Using these is probably easier than remembering the Unicode characters.

 String bold = Colors.BOLD + "This is bold"; String underlined = Colors.UNDERLINE + "This is underlined"; String reversed = Colors.REVERSE + "This is reversed"; String mixture = Colors.BOLD + "Bold" + Colors.NORMAL + " and gone"; 

Just because you can use formatting doesn't mean you have to. Remember to use it sparingly and only when necessary, otherwise you'll start to annoy people and they may start ignoring you!


Some of the bots covered later in this book use bold formatting to make parts of messages stand out more clearly.

 < Day Day Up > 


IRC Hacks
IRC Hacks
ISBN: 059600687X
EAN: 2147483647
Year: 2004
Pages: 175
Authors: Paul Mutton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net