Top Qs
Chronologie
Chat
Contexte
Utilisateur:Schnouki/Scripts X-Chat
De Wikipédia, l'encyclopédie libre
Remove ads
Un petit script python qui corrige les bugs des caractères utf8 sur le salon IRC #frrc.wikipedia.
# -*- coding: utf8 -*-
__module_name__ = "rc utf8 bug fix"
__module_version__ = "0.1"
__module_description__ = "Fixes a bug with the RC bot which breaks all utf8 characters"
__module_author__ = "[[fr:Utilisateur:MagicTom]]"
import xchat
characters = {
"C)": "é",
"C'": "ç",
"C ": "à",
"E": "œ",
"C\"": "â",
"C(": "è",
"C4": "ô",
"C/": "ï",
"C;": "û",
"C*": "ê",
"=C": "É"
}
def rc_bug_fix(word, word_eol, userdata):
channel = xchat.get_info("channel") # We only want to do this in #??rc.wikipedia channels ;-)
if channel.count("rc.wikipedia") > 0:
nick = word[0] # Unuseeful: we could simply keep word[0] when nick is needed. But this is nicer ;-)
line = word_eol[1] # The whole line except the first word (sender's nickname)
changed = False
for key in characters.keys():
tmp = line.replace(key, characters[key]) # Replaces bad characters with good characters
if tmp != line:
changed = True
line = tmp
if changed: # Only do something if the line was changed
xchat.emit_print("Channel Message", nick, line)
return xchat.EAT_XCHAT
else:
return xchat.EAT_NONE
else:
return xchat.EAT_NONE
xchat.hook_print("Channel Message", rc_bug_fix)
print "Plugin " + __module_name__ + " " + __module_version__ + " loaded."
Remove ads
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads