You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1.7 KiB
1.7 KiB
The Photo-Album Bot for Telegram
Compilation
Fetch dependencies.
go get -u github.com/go-telegram-bot-api/telegram-bot-api
go get -u github.com/spf13/viper
go get -u gopkg.in/yaml.v2
go get -u github.com/rakyll/statik
Pack all web files
go generate
Compile for Raspberry PI.
GOOS=linux GOARCH=arm64 go build -o photo-bot
Create a Bot
Talk to BotFather to create your bot.
/newbot
Keep your bot token secure and safe!
Installation
On your Raspberry PI.
mkdir -p /opt/photo-bot/bin
mkdir -p /opt/photo-bot/etc
mkdir -p /srv/photo-bot
useradd -d /srv/photo-bot -s /bin/false -m -r bot
chown bot:bot /srv/photo-bot
scp photo-bot root@raspberry-pi.example.test:/opt/photo-bot/bin/
Create a file named photo-bot.yaml in /opt/photo-bot/etc/.
TelegramToken: "bot.token.here"
TelegramDebug: true
TargetDir: /srv/photo-bot
AuthorizedUsers:
- john
- jane
chown bot:bot /opt/photo-bot/etc/photo-bot.yaml
chmod 600 /opt/photo-bot/etc/photo-bot.yaml
Start the bot manually.
sudo -u bot /opt/photo-bot/bin/photo-bot
Create the startup script in /etc/init.d/photo-bot.
#!/bin/sh /etc/rc.common
# photo-bot
# Start late in the boot process
START=80
STOP=20
start() {
cd /opt/photo-bot/etc/ && start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -S
}
stop() {
start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -K
}
chmod 755 /etc/init.d/photo-bot
service photo-bot enable
service photo-bot start