This file holds dictionaries that hold IRC-specific formatting codes for manipulating text sent to the server, as well as methods for safe application of these codes.
The methods found in this file can be safely nested, to apply several different formatting options to your desired text string.
-
format.bold(string)
Returns string prefixed with IRC bold control character\x02and suffixed with IRC reset character\x0F. -
format.italic(string)
Returns string prefixed with IRC italic control character\x1Dand suffixed with IRC reset character\x0F. -
format.underline(string)
Returns string prefixed with IRC underline control character\x1Fand suffixed with IRC reset character\x0F. -
format.invert(string)
Returns string prefixed with IRC reverse format control character\x16and suffixed with IRC reset character\x0F. -
format.color(string[, color[, background]])
Returns string with colored formatting. If color and background unspecified, string will be returned as explicitly black (\x0301).
If color is specified, returns string prefixed with IRC color text control character\x03, the specified color key's dictionary value, and suffixed with IRC reset character\x0F.
If background is specified, returns string prefixed with IRC color text control character\x03, the specified color key's dictionary value (if color not specified, it defaults to'black'), a comma',', the specified background color key's dictionary value, and suffixed with IRC reset character\x0F.
If an a key match cannot be made with the string given to color or background and aKeyErroris raised, string will be returned with no formatting applied.
'white''black''blue''green''red''brown''purple''orange''yellow''light-green''teal''cyan''light-blue''pink''grey''light-grey'
The following examples employ examples of more complicated nesting and usage for format.py's functions. The output is more-or-less indicative of how the text will appear in user's IRC clients.
Due to GitHub's strict HTML filtering, the below representations are provided in image form. Equivalent HTML representations are accompanied as alt-text and can be viewed in the raw markdown file.
src.format.bold(src.format.italic(src.format.underline("foo")))Yeilds:
src.format.underline(src.format.color(src.format.italic("foo"),'light-green'))Yeilds:
src.format.invert(src.format.color("foo", background='white')Yeilds:
src.format.italic(src.format.invert(src.format.color(src.format.bold("foo"),'cyan','pink')))Yeilds:
src.format.italic(src.format.color(src.format.bold("foo"),'cyan','pink'))Yeilds:




