Fixing Slack emojis in HexChat

If, like me, you are this person:


You may want to fix the stupid :slightly_smiling_face: messages you receive from Slack via the IRC gateway. Obviously, I’d prefer they went away entirely, but it’s still better to see a character than being spammed with colon abominations all over the place.

You’ll need the Python emoji package, and a HexChat plugin like this:

# Replace all the horrible :slightly_smiling_face: rubbish that Slack inserts
# into horrible Unicode emoji symbols.
# Author: Andy Balaam
# License: CC0

# Requires - I used 0.4.5
# I manually copied the emoji dir into:
# /home/andrebal/.local/lib/python2.7/site-packages
import emoji
import hexchat

__module_name__ = "slack-emojis"
__module_version__ = "1.0"
__module_description__ = "Translate emojis from Slack with colons into emojis"

print "Loading slack-emojis"
chmsg = "Channel Message"
prmsg = "Private Message to Dialog"

def preprint(words, word_eol, userdata):
    txt = word_eol[1]
    replaced = emoji.emojize(txt, use_aliases=True)
    if replaced != txt:
        return hexchat.EAT_HEXCHAT
        return hexchat.EAT_NONE

hexchat.hook_print(chmsg, preprint, {"msgtype": chmsg})
hexchat.hook_print(prmsg, preprint, {"msgtype": prmsg})

According to the page linked above, Slack are retiring the IRC gateway, which will make me very unhappy.

Update: added support for private messages too.

4 thoughts on “Fixing Slack emojis in HexChat”

  1. Hey there,

    I am not that coding expert, I just use wordpress and its plugins.

    Sorry for the noob question… Is there a way to make it work as a WordPress plugin?

    (I have connected a slack channel to create posts in wordpress, through zapier. The posts are created with the abomination :smile: stuff… )

    Thanks in advance for your reply

  2. Hi Victor, my plugin is written in Python, and WordPress plugins have to be PHP as far as I know, so there is no direct way to use it, I’m afraid :-(

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.