A WeeChat script for Slack.com. Supports threads and reactions, synchronizes read markers, provides typing notification, etc..
A WeeChat script for Slack.com. Supports threads and reactions, synchronizes read markers, provides typing notification, etc..
A WeeChat native client for Slack.com. Provides supplemental features only available in the web/mobile clients such as: synchronizing read markers, typing notification, threads (and more)! Connects via the Slack API, and maintains a persistent websocket for notification of events.
See docs/contributing.md.
weechat-pythonArch Linux: pacman -S python-websocket-client
Debian/Ubuntu: apt install weechat-python python3-websocket
Fedora: dnf install python3-websocket-client
FreeBSD: pkg install py36-websocket-client
OpenBSD: pkg_add weechat-python py3-websocket-client
Other: python3 -m pip install websocket-client
The easiest way to install wee-slack is from inside WeeChat by running:
/script install slack.py
This will install and load it and enable automatically loading it when WeeChat starts.
Alternatively, you can download the wee_slack.py script from the GitHub repo,
either from the latest release or from the master branch and place it under the
python/ directory in the WeeChat data files
directory.
If you use the default XDG directories, this will be
$XDG_DATA_HOME/weechat/python, or ~/.local/share/weechat/python if
$XDG_DATA_HOME is not set. If you use the old single directory, it will be
~/.weechat/python.
If you use this method and want it to load automatically when WeeChat starts,
you have to create a symlink from the autoload directory to the script.
E.g. to install and automatically load the latest version from the master
branch when using ~/.local/share/weechat:
mkdir -p ~/.local/share/weechat/python/autoload
cd ~/.local/share/weechat/python
curl -O https://raw.githubusercontent.com/wee-slack/wee-slack/master/wee_slack.py
ln -s ../wee_slack.py autoload
If you already had WeeChat running when installing the script, or if you didn't
enable autoload, you have to load the
script
by running this inside WeeChat: /script load wee_slack.py
There are two types of tokens that can be used, OAuth tokens and session tokens. The official way to get a token is to use OAuth. However, this has several drawbacks, so an alternative way is to pull a session token out of the web client.
Drawbacks of OAuth tokens:
Drawbacks of session tokens:
Log in to Slack:
/slack register
This command prints a link you should open in your browser to authorize WeeChat with Slack. If the page shows a different team than the one you want to add, you can change the team in the top right corner of the page.
Once you've accomplished this, the page will show a command which you should run in WeeChat. The command is of the form:
/slack register <code>
Note that this will store your token in plain text in the
plugins.var.python.slack.slack_api_token option. See "Optional: Secure the
tokens" below for how to secure it.
Your Slack team is now added, and you can complete the setup by reloading the wee-slack script.
/python reload slack
Note that by default GitHub Pages will see a temporary code used to create your
token (but not the token itself). If you're worried about this, you can use the
-nothirdparty option, though the process will be a bit less user friendly.
Ctrl+Shift+J/Cmd+Opt+J in Chrome and Ctrl+Shift+K/Cmd+Opt+K in Firefox).window.prompt("Session token:", TS.boot_data.api_token)d and copy the value./slack register <token>:<cookie>./python reload slack.Note that this will store your token in plain text in the
plugins.var.python.slack.slack_api_token option. See "Optional: Secure the
tokens" below for how to secure it.
Note that if you log in or out of any teams in your browser, the cookie will be invalidated, and you will have to update it.
Note that in some cases it may be necessary to include the d-s cookie as
well. If so, you can supply it in this format <token>:d=<d_cookie>;d-s=<d-s_cookie>.
If you use Chrome or Firefox, you can run the extract_token_from_browser.py
script to get the tokens and cookies for all the teams you're logged into:
./extract_token_from_browser.py <browser>
(Note this script requires the Plyvel, PyCryptodome and SecretStorage libraries for Chrome and may require the python-snappy library for Firefox.)
You can run the register command multiple times to connect to multiple teams. If you set the token option yourself, you should separate the tokens with commas.
/mute /set plugins.var.python.slack.slack_api_token <token1>,<token2>,<token3>
The /mute prefix is to prevent "Option changed ..." from being printed to the
core buffer, so your token is not logged in your buffer logs.
The tokens you add will be stored as plain text in the option
plugins.var.python.slack.slack_api_token. If you don't want to store your API
token in plain text you can use the secure features of WeeChat:
/secure passphrase this is a super secret password
/secure set slack_token <YOUR_SLACK_TOKEN>
/set plugins.var.python.slack.slack_api_token ${sec.data.slack_token}
Note that you will have to move your tokens manually from
plugins.var.python.slack.slack_api_token to the secure variable after each
time you run /slack register <code>.
For the available options see docs/Options.md or run this command:
/set slack
Most options require that you reload the script with /python reload slack
after changing it to take effect.
For the available commands see docs/Commands.md or run this command:
/slack help
In addition to the commands listed with /slack help, most normal IRC
commands, like /join, /part, /query, /msg, /me, /topic, /away and
/whois work normally. See WeeChat's
documentation or
/help <cmd> if you are unfamiliar with these.
There are also some special messages you can send:
Modify previous message using regex:
s/old text/new text/
Modify 3rd previous message using regex:
3s/old text/new text/
The regex also supports the flags g for replacing all instances, i for
ignoring case, m for making ^ and $ match the start/end of each line and
s for making . match a newline too. Use them by appending one or more of
them to the regex:
s/old text/new text/gi
Delete previous message:
s///
Add a reaction to the nth last message. The number can be omitted and defaults to the last message. The + can be replaced with a - to remove a reaction instead.
3+:smile:
To send a command as a normal message instead of performing the action, prefix it with a slash or a space, like so:
//slack
s/a/b/
Start a new thread on the most recent message The number indicates which message in the buffer to reply to, in reverse time order:
/reply 1 here is a threaded reply to the most recent message!
No open issues yet, or sync has not completed.