diff --git a/.gitignore b/.gitignore index b865828..03cc852 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ go.mod go.sum -mastodon-group-bot *.db diff --git a/README.md b/README.md index 699585b..0b976c0 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # Mastodon group bot - This is a bot which implements group functionality in Mastodon. +## Features +* Repost toots +* Welcome message of new members +* Limit of toots per hour +* Admin commands + # Configuration - The bot is configured in a JSON file that looks like this: - ``` { "Server": "https://example.com", @@ -20,17 +23,30 @@ The bot is configured in a JSON file that looks like this: ``` # Building - ``` go mod init mastodon-group-bot - go mod tidy - go build ``` -# Usage +# Setup services +For first copy config and binary +``` +cp mastodon-group-bot /usr/bin/mastodon-group-bot +cp config.json /etc/mastodon-group-bot.json +``` +## Systemd +``` +cp ./services/systemd/mastodon-group-bot.service /etc/systemd/system/mastodon-group-bot.service +``` + +## OpenRC +``` +cp ./services/openrc/mastodon-group-bot /etc/init.d/mastodon-group-bot +``` + +# Usage ``` Usage of mastodon-group-bot: -config string diff --git a/services/openrc/mastodon-group-bot b/services/openrc/mastodon-group-bot new file mode 100644 index 0000000..4cf5242 --- /dev/null +++ b/services/openrc/mastodon-group-bot @@ -0,0 +1,18 @@ +#!/sbin/openrc-run +name=$RC_SVCNAME +command="/usr/bin/$name" +command_args="-config" +cfgfile="/etc/$name.json" +pidfile="/run/$name.pid" +user="nobody:nobody" +description="Mastodon group bot which reposts toots" +start() { + ebegin "Starting $name" + start-stop-daemon -bm -S -u $user -p $pidfile -x $command -- $command_args $cfgfile + eend $? +} +stop() { + ebegin "Stopping $name" + start-stop-daemon -K -p $pidfile + eend $? +} diff --git a/services/systemd/mastodon-group-bot.service b/services/systemd/mastodon-group-bot.service new file mode 100644 index 0000000..ae3cc86 --- /dev/null +++ b/services/systemd/mastodon-group-bot.service @@ -0,0 +1,12 @@ +[Unit] +Description=Mastodon group bot which reposts toots +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +User=nobody +ExecStart=/usr/bin/mastodon-group-bot -config /etc/mastodon-group-bot.json + +[Install] +WantedBy=multi-user.target