-- Leo's gemini proxy

-- Connecting to republic.circumlunar.space:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Fixing Slack emojis in HexChat


If, like me, you are this person:


[‡ team chat]


(Source: xkcd.com/1782)


[‡ team chat]

xkcd.com/1782


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:


IRC gateway

Python emoji package


# Replace all the horrible :slightly_smiling_face: rubbish that Slack inserts
# into horrible Unicode emoji symbols.
# Author: Andy Balaam
# License: CC0 https://creativecommons.org/publicdomain/zero/1.0/

# Requires https://pypi.python.org/pypi/emoji - 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:
       hexchat.emit_print(
           userdata["msgtype"],
           words[0],
           replaced.encode('utf-8'),
       )
       return hexchat.EAT_HEXCHAT
   else:
       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.


Originally posted at 2018-02-16 15:53:05+00:00. Automatically generated from the original post : apologies for the errors introduced.


original post

-- Response ended

-- Page fetched on Sun May 19 08:24:05 2024