2019-12-10 / syui

weechat

wee-slackを使ってみた

weechatというCLIのIRC Clientがあります。今回は、weechatでslackを使うwee-slackというpluginの紹介です。

https://github.com/wee-slack/wee-slack

install

# install
$ sudo pacman -S python-websocket-client weechat
$ mkdir -p ~/.weechat/python/autoload
$ cd ~/.weechat/python
$ url -O https://raw.githubusercontent.com/wee-slack/wee-slack/master/wee_slack.py
$ ln -s ../wee_slack.py autoload

次に、weechatを起動し、/slack registerコマンドを実行すると、https://slack.com/oauth/authorize?client_id=xxx&scope=clientというoauth urlが出てきます。これをブラウザで開きます。

# slackに接続
$ weechat
/slack register
#### Retrieving a Slack token via OAUTH ####
1) Paste this into a browser:
https://slack.com/oauth/authorize?client_id=xxx&scope=client
2) Select the team you wish to access from wee-slack in your browser.
3) Click "Authorize" in the browser **IMPORTANT: the redirect will fail, this is
expected**o
   If you get a message saying you are not authorized to install wee-slack, the team has
restricted Slack app installation and you will have to request it from an admin. To do
that, go to https://my.slack.com/apps/A1HSZ9V8E-wee-slack and click "Request to
portion of
the URL to  "code" portion of the URL to your clipboard
5) Return to weechat and run `/slack register [code]`

ブラウザを開いてリダイレクトされたurlのうちcode=xxxxxxxのxxxの部分がregister番号になります。これを/slack register xxxで実行します。また、https://${my}.slack.com/apps/A1HSZ9V8E-wee-slackを開いて、wee-slackのアプリを許可します。

/slack register xxx
/python reload slack

use

これでslackに接続できたと思います。続いて、weechatの使い方です。

weechatはまずCtrl + xでbufferを移動します。user-nameである[syui]みたいに表示されたところがslackです。上にアクセス元も表示されます。xxx.slack.com

補完も効くので、よく使いそうなコマンドを挙げます。

# channelに入る
/join #randam
/join syui

# メッセージを投稿, そのまま書けば投稿されます
[syui]test message.
test message.

# weechatを終了する
/exit

wee-slackの使い方はこちら

https://github.com/wee-slack/wee-slack/blob/master/docs/Options.md

https://github.com/wee-slack/wee-slack/blob/master/docs/Commands.md