| View previous topic :: View next topic |
| Author |
Message |
ShadowMetis
Joined: 05 Feb 2005 Posts: 2
|
Posted: Sat Feb 12, 2005 10:45 pm Post subject: Text formatting doesn't work through scripts? |
|
|
| Whenever I use %B or any of the other things to format messages in such from inside one of my perl scripts, it shows up as %B in the message instead of just making it bold. |
|
| Back to top |
|
 |
Khisanth
Joined: 10 Jun 2004 Posts: 1557
|
Posted: Sun Feb 13, 2005 8:54 am Post subject: |
|
|
that is correct, in place of %B you can use \cB.
%B => \cB
%C => \cC
%U => \c_
%O => \cO
%R => \cV
These need to be in double quoted strings to work as expected. |
|
| Back to top |
|
 |
ShadowMetis
Joined: 05 Feb 2005 Posts: 2
|
Posted: Mon Feb 14, 2005 3:23 pm Post subject: |
|
|
Ahhhhh
Thanks, I was wondering about that for a while. |
|
| Back to top |
|
 |
ninjamalte
Joined: 22 Mar 2005 Posts: 1
|
Posted: Tue Mar 22, 2005 6:36 pm Post subject: |
|
|
| Khisanth wrote: | that is correct, in place of %B you can use \cB.
%B => \cB
%C => \cC
%U => \c_
%O => \cO
%R => \cV
These need to be in double quoted strings to work as expected. |
The following python-code doesn't seem to work. Am I missing something?
| Code: | | xchat.prnt("\cBfoo") |
|
|
| Back to top |
|
 |
Khisanth
Joined: 10 Jun 2004 Posts: 1557
|
Posted: Tue Mar 22, 2005 11:22 pm Post subject: |
|
|
| this is just for Perl, no idea about Python |
|
| Back to top |
|
 |
EXtes

Joined: 15 Jul 2004 Posts: 160 Location: Germany
|
Posted: Wed Mar 23, 2005 8:38 am Post subject: |
|
|
| In perl \003 or chr(03) will work like %C. Perhaps you find similar in python. |
|
| Back to top |
|
 |
boing

Joined: 22 Mar 2005 Posts: 19 Location: France
|
Posted: Wed Mar 23, 2005 9:05 am Post subject: IRC codes |
|
|
formatting codes are defined as:
(type : hexa = octal = xchat char)
Bold : 0x02 = 002 = %B
Color : 0x03 = 003 = %C (with 2 digits after, f.e. \00304 = color 4)
Underlined : 0x1F = 037 = %U
Reverse/Italic : 0x16 = 026 = %R
Out/Escape = 0x0F = 017 = %O
Note:
use octal with \ & code
ex: "\002text\002" will give text
"\026\037o\037ne \037t\037wo \037t\037hree" will give one two three (italic or reversed, I think it depends on the client... AFAIL it is most oftenly reversed) |
|
| Back to top |
|
 |
nexu
Joined: 15 Apr 2006 Posts: 13
|
Posted: Mon Jun 05, 2006 8:58 pm Post subject: |
|
|
| EXtes wrote: | | In perl \003 or chr(03) will work like %C. Perhaps you find similar in python. |
I have a function which does that for me: | Code: |
def colordecode(word):
_B = re.compile('%B', re.IGNORECASE)
_C = re.compile('%C', re.IGNORECASE)
_R = re.compile('%R', re.IGNORECASE)
_T = re.compile('%T', re.IGNORECASE)
_U = re.compile('%U', re.IGNORECASE)
return _B.sub('\002', _C.sub('\003', _R.sub('\026', _T.sub('\017', _U.sub('\037', word)))))
|
print colordecode("%Bhello%B world") |
|
| Back to top |
|
 |
|