Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pansapiens committed Nov 26, 2022
1 parent 8bf8804 commit 29327e2
Show file tree
Hide file tree
Showing 5 changed files with 732 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .github/workflows/release.yaml

on:
release:
types: [created]

jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, linux/arm64, darwin/amd64, darwin/arm64
goos: [linux, darwin]
goarch: ["386", amd64, arm64]
exclude:
- goarch: "386"
goos: darwin
steps:
- uses: actions/checkout@v3
- uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://dl.google.com/go/go1.19.3.linux-amd64.tar.gz"
project_path: "./"
binary_name: "masto2slack"
extra_files: LICENSE README.md
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# masto2slack

`masto2slack` reads posts (toots?) from your Mastodon account and feeds them to a Slack channel.


## Installation

Download the binary from releases, put it somewhere you can run it under a cron job.


## Setup

You'll need to:

- On your Mastodon server, create a 'new application' and get an access token (`access_token`) (you can do this under `https://<your_instance>/settings/applications/new` in the web interface). You'll need `read` access.
- Create a [Slack App](https://api.slack.com/apps?new_app=1) and enable an incoming webhook (you'll get the `webhook_url`)
- Create a configuration file, `~/.config/masto2slack/config.yml`, as below.

Example `~/.config/masto2slack/config.yml`:

```yaml
slack:
webhook_url: https://hooks.slack.com/services/TSDFICIU/B0USDFIK9/cs8dyhl3nkj3knfnwnlkfc
mastodon:
server: https://tootymctootface.social
access_token: 2903458u2305_34534o8543_34kj5h34k5hk35k3
```
## Running
Either create a cronjob (`crontab -e`) to call `masto2slack` every 5 mins (or longer):

```
*/5 * * * * /usr/local/bin/masto2slack >/dev/null 2>&1
```
(this assumes you've copied `masto2slack` to `/usr/local/bin/masto2slack`)
Alternatively, run:
`watch -n 300 ./masto2slack`
to check for new posts every 5 mins (300 seconds).
## Ideas / TODO
- Option to run in our own polling loop rather than require a cronjob
- Use websockets so we don't need to poll
- Better logging and a `--verbose` commandline option
- Better Slack post formatting (eg media posts in Slack message 'blocks' ?)
31 changes: 31 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module github.com/pansapiens/masto2slack

go 1.19

require (
github.com/JohannesKaufmann/html-to-markdown v1.3.6 // indirect
github.com/PuerkitoBio/goquery v1.8.0 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-mastodon v0.0.6 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/slack-go/slack v0.11.4 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.14.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 29327e2

Please sign in to comment.