This is the first post in a series I'l be doing on my experiences | |
using Slack [1] at the office. My company recently decided to switch | |
to it for inter-office communication. I found several things that I | |
disliked about the interface to their official client so I went | |
searching for a better way to use their service. After very little | |
effort I found a few options that looked promising. | |
Slack offers an IRC gateway. This looked promising but since Slack | |
offers some different features than standard IRC, the special Slack | |
features were not made available. This was going to be a problem for | |
me. A little more searching uncovered wee-slack [2], a python plugin | |
for the popular weechat [3] command line IRC client. This happens to | |
be my IRC client of choice and looked very promising. Instead of | |
interfacing with the IRC gateway provided by Slack, it uses the Slack | |
API to provide a more feature rich experience while still providing | |
the familiar, IRC client interface and commands. | |
This first post will be about my experience configuring WeeChat to use | |
the wee-slack plugin. Since I use a Macbook Pro for work, this info | |
will likely be interesting but only directly useful to users of MacOS. | |
Some pieces may carry over if your environment under Linux/BSD is | |
similar. | |
The installation of wee-slack is fairly straight forward and quick; | |
similar to all other WeeChat plugins. You download the python script | |
from their git repository and place it in your ~/.weechat/python | |
directory. You then load it with /python load wee-slack.py from the | |
weechat prompt. Upon doing this I received a python stack trace | |
informing me that it was unable to load the 'websockets' module. A | |
quick look at their documentation and I see that I need the | |
websocket-client python module installed. Running | |
`pip install websocket-client` from the command line should have fixed | |
this. Unfortunately, the error persisted. | |
I have WeeChat installed using Homebrew [4] (a package manager for MacOS). | |
Homebrew compiles and installs packages from source. You can run | |
`brew edit $APPNAME` | |
to modify the homebrew version of a Makefile. This is where you enable | |
special options for build-time. In the case of WeeChat, this is used | |
to enable language specific plugin support. Python support is one of | |
these options. I had already enabled Python support, but it was still | |
not working. | |
Enter my user environment. I have an exceedingly complicated user | |
environment on my work laptop. This is out of necessity due to the | |
variance in the type of work I do from day to day. One of the special | |
caveats about my work environment is the use of pyenv [5] to manage | |
multiple versions of python on the same system in a sane(ish) manner. | |
After much searching and discussion on IRC with weechat developers I | |
found out that CMAKE does some magic to discover where you have python | |
installed. If you're using pyenv, this can confound things a little, | |
making it nearly impossible to figure out which version of python it | |
has chosen to use and subsequently difficult to find out which python | |
I needed install websocket-client in. The workaround is to statically | |
define the python binary that should be used by CMAKE. This is done | |
with the -DPYTHON_EXECUTABLE flag. Setting this to the global python | |
version, rebuilding weechat, and installing the websocket-client | |
module to the system python fixed the issue with running wee-slack.py | |
in weechat. | |
As mentioned earlier, wee-slack.py uses a Slack legacy API token to | |
interface with Slack. This is then loaded in to weechat using the | |
command and restarting your weechat client: | |
/set plugins.var.python.slack.slack_api_token [YOUR_SLACK_TOKEN] | |
Initial impressions were very positive. There are some great features | |
built in to the core plugin and the default behavior is configured | |
well out of the box. | |
Tomorrow, I will discuss the configuration in more detail and explore | |
some additional plugins that I've found useful for providing | |
additional functionality and extending the built-in capabilities of | |
wee-slack.py. | |
I hope you've enjoyed this post, see you tomorrow! | |
[1] Slack | |
[2] wee-slack.py | |
[3] WeeChat | |
[4] Homebrew | |
[5] Pyenv |