Autoreplace Outgoing Text in XChat with Python
Having grown to like some unicode characters while talking on XChat, I decided there was a better way to enter them than to use CTRL+SHIFT+U + Numbers (linux) every time again. So I dug into the Python XChat interface a bit and threw together a quick script that will check everything you write and replace certain things with prettier unicode variants. Figured I would post it here in case someone somewhere can find it useful.
# -*- coding: utf-8 -*-
__module_name__ = "Unicode"
__module_version__ = "0.1.20100130"
__module_description__ = "Replaces random smileys with Unicode variants"
import xchat
def intercept_print(word, word_eol, userdata):
line = word_eol[0] \
.replace("<3", "♥") \
.replace("=)", "ツ") \
.replace("^^", "^̮^") \
.replace("!!", "‼") \
.replace("°C", "℃") \
.replace("->", "→") \
.replace("=>", "⇒")
xchat.command(" ".join(["msg", xchat.get_info("channel"), line]))
return xchat.EAT_ALL
# Empty command means catching normal text apparently
xchat.hook_command("", intercept_print)
Note that I have neither much experience in Python, nor in XChat programming so I would not be surprised if there are cleaner/more efficient ways to go at it.