Mastodon-to-Slack is a simple Slack integrations tool to post a toot to a Slack channel by using Incoming Webhooks.
To use this tool you need a few configurations.
- Copy
.env.sample
file
$ cp .env.sample .env
- Fill in
MASTODON_INSTANCE_HOST
andMASTODON_USERNAME
MASTODON_INSTANCE_HOST
is a Mastodon instance hostname with which you want to integrate Slack. A URL scheme and a trailing slash must not exist.MASTODON_USERNAME
is your username, not a display name.@
and a Mastodon instance hostname must not exist.
# Bad
MASTODON_INSTANCE_HOST='https://mastodon.social'
MASTODON_INSTANCE_HOST='mastodon.social/'
# Good
MASTODON_INSTANCE_HOST='mastodon.social'
# Bad
MASTODON_USERNAME='@noraworld'
MASTODON_USERNAME='[email protected]'
MASTODON_USERNAME='@[email protected]'
# Good
MASTODON_USERNAME='noraworld'
- Access
https://<YOUR_MASTODON_INSTANCE_HOST>/settings/applications/new
- Create a new application by following the screenshot below
Item | Value |
---|---|
Application name | Anything is OK |
Application website | Anything is OK |
Redirect URI | urn:ietf:wg:oauth:2.0:oob (default) |
Scopes | Only read |
- Click the
SUBMIT
button - Copy your access token
- Paste it to
MASTODON_ACCESS_TOKEN
in.env
- Access Slack App Directory
- Search Incoming WebHooks
- Click the
Add Configuration
button - Select a channel you want to integrate
- Click the
Add Incoming WebHooks integration
button - Copy your Webhook URL
- Paste it to
SLACK_WEBHOOK_URI
in.env
- [OPTIONAL] Change integration settings
$ bundle install
The usage is very simple. All you need to do is run the following command:
$ ruby src/mastodon_to_slack.rb
Note that you must run this command in a project root directory:
# Bad
$ cd src
$ ruby mastodon_to_slack.rb
# Good
$ ruby src/mastodon_to_slack.rb
Toot something, and this tool will post a Mastodon status URL to a Slack channel!
To stop this tool just send SIGINT signal (press Ctrl-C
).
When a connection closes or an error occurs, it outputs nothing because a log file is filled with tons of connection close and error messages!! If you want to output all of the statuses just append --verbose
to the command.
$ ruby src/mastodon_to_slack.rb --verbose
All codes of this repository are available under the MIT license. See the LICENSE for more information.