Skip to content

Instantly share code, notes, and snippets.

@ralphholz
Last active December 4, 2017 06:24
Show Gist options
  • Save ralphholz/6fbfe62eb8b79cc75655d132e4beeae3 to your computer and use it in GitHub Desktop.
Save ralphholz/6fbfe62eb8b79cc75655d132e4beeae3 to your computer and use it in GitHub Desktop.
Using Slack via weechat with slack plugin via websockets (macOS HighSierra)

First half: following instructions to get weechat to run with Python plugin

This is for macOS High Sierra.

These instructions extend those on https://gist.github.com/fluxsauce/060ab39a4fb7b8fc89524690c727627b with a few things that went wrong for me.

Python via brew

You might find yourself without a Python installation via brew (even though you installed pyton via brew at some point in the past). That is important, however, because we need pip. Run

Run

env $PATH

The path /usr/local/bin should appear before /usr/bin. If not, you are using the relatively old Python provided by macOS.

To get a brew-installed Python 2.7.14 and Python 3.6.3, I had to forcefully remove Python and reinstall:

brew uninstall --ignore-dependencies python
brew uninstall --ignore-dependencies python3
brew install python
brew install python3

Check again if the first python in your path is from /usr/local/bin:

which python

should no longer point to /usr/bin, but to something like /usr/local/opt/python/libexec/bin/python.

Installing weechat

weeslack is a plugin for weechat. It is written in Python, and hence we must make sure that we install weechat with support for Python:

brew install weechat --with-python --with-perl
pip install websocket-client

Do a

brew info weechat

and check if python is ticked. It must be.

Second half: Installing weeslack

Installing weeslack works via download via wget:

mkdir -p ~/.weechat/python/autoload
wget https://raw.githubusercontent.com/rawdigits/wee-slack/master/wee_slack.py -O ~/.weechat/python/autoload/wee_slack.py

If you run weechat now, you should get an error message complaining that the Slack legacy tokens are not known to the plugin. That is as it should be.

Enable Slack legacy API

Quit weechat and go to your Slack. Under https://api.slack.com/custom-integrations/legacy-tokens, you will find the Legacy Token Generator. Generate tokens for all your teams that you want to use in weechat.

Start weechat again, and run:

weechat
/set plugins.var.python.slack.slack_api_token [YOUR_SLACK_TOKEN],[YOUR_OTHER_SLACK_TOKEN]
/save
/script install buffers.pl
/script autoload buffers.pl
/python reload

Note the comma-separated list of tokens.

That should give you your Slack teams.

Notification centre

According to https://gist.github.com/fluxsauce/060ab39a4fb7b8fc89524690c727627b, one can get the notification centre plugin to work. I haven't had success yet and will update this gist when I have it running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment