|
|
Text FormattingIn order to add text formating to strings either printed by XChat or sent to the server, you can't simply add %C or %B, instead you need to use another form, like \003 or \cB. List of Codes
Using Perc Colors (%O, %B) in scriptsYou can use Perc Colors (%O, %B) in scripts if you use an extra function inside the script to convert the %B into \002. Following are two functions, one for Perl and one for Python that you can use, in each, obtain the value returned by colordecode("string"): In Perlsub colordecode { $_[0] =~ s/%(.)/macro_sub $1/eg; return ($_[0]); } sub macro_sub ($) { if ($_[0] eq 'U') { return "\c_"; } elsif ($_[0] eq 'B') { return "\cB"; } elsif ($_[0] eq 'C') { return "\cC"; } elsif ($_[0] eq 'O') { return "\cO"; } elsif ($_[0] eq 'R') { return "\cV"; } elsif ($_[0] eq '%') { return '%'; } return '%'.$_[0]; } In Pythondef colordecode(word): _B = re.compile('%B', re.IGNORECASE) _C = re.compile('%C', re.IGNORECASE) _R = re.compile('%R', re.IGNORECASE) _O = re.compile('%O', re.IGNORECASE) _U = re.compile('%U', re.IGNORECASE) return _B.sub('\002', _C.sub('\003', _R.sub('\026', _O.sub('\017', _U.sub('\037', word))))) Python code thanks to nexu |
