Fixing Slack emojis in HexChat
February 16, 2018 [Tech]If, like me, you are this person:
(Source: 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:
# 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.
Andy Balaam 2018-04-30
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 :–(
Eitan Adler 2018-07-08
I added this here for more visibility: https://github.com/hexchat/hexchat-addons/tre...
Victor 2018-04-29
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