bin.py

TKa 08.07.04 11:51

muuttaa tekstin binäärimuotoon. typerä lelu x-chattiin

 Tekstiversio  Arvo: 4 (4 ääntä)  Äänestä: +  -
import xchat

__module_name__="bin"
__module_version__="0.2"
__module_description__="Convert text strings to binary strings (8-bit version)"

def text2bin( word, word_eol, userdata ):
    tmp = ""
    out = ""
    for list in word[1:]:
        for i in list:
            x = ord( i )
            while x:
                x, d = divmod( x, 2 )
                tmp = str( d ) + tmp
            if( len( tmp ) < 8 ):
                tmp = '0' + tmp
            out += tmp
            tmp = ""
    konteksti = xchat.find_context()
    konteksti.command( "say " + out )
    return xchat.EAT_ALL

xchat.hook_command( "bin", text2bin )
 

BlueByte 14:18 8.7.04 
Erittäin hyödyllinen kapistus.
ZcMander 14:41 19.8.05 
mutta tuo on hyvä koodivinkki, miten xchat scriptejä tehään.