Categorygithub.com/osoderholm/svenska-yle-bot
repositorypackage
1.0.6
Repository: https://github.com/osoderholm/svenska-yle-bot.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

svenska-yle-bot

Go Report Card

Telegram bot for Svenska Yle news feed.

Chat with SvenskaYleBot on Telegram

Why

WhatsApp ended support for sending mass-group messages, or something like that. Svenska Yle had a questionnaire regarding other messaging platforms, where they could continue sending out news updates to readers.

Telegram offers channels, that allow you to send out messages to your "followers", without having to use a chaotic group where everyone can type anything. This is fine, but it requires work. Of course in hindsight, someone probably gets paid for doing posting these news.

Anyway, this bot can do even more! You can add it to channels (contact me), but it can also be added to groups and you can even get news directly from it as a user.

Features

The bot can act on different commands sent by users.

CommandDescriptionPrivateGroupChannel
/latestReturns 5 latest articlesYesYesNo
/subscribeSubscribes you to news feed. You will receive latest news every hour-ishYesNoNo
/unsubscribeEnds your subscription if you had oneYesNoNo

You can use /help to see available commands.

Developers

Running

Docker

DISCLAIMER! Don't trust GitHub docker registry latest tag!

There is a docker-compose.yml file containing an example of how to run the bot using Docker.

The only thing you need is a Telegram API token. You can get it using Telegram BotFather.

Local run

In order to run this locally, you must have:

  • Go 1.13
  • Postgres 12 database
  • Environmental variables set

Fetch dependencies:

go mod download

Run:

go run .

Database

The bot needs a database and currently that needs to be a Postgres database. This database can run anywhere, as long as the bot can access it. The connection params are specified using environmental variables.

The bot will automatically perform migrations and at the same time create a schema bot where all tables will go.

Environmental variables

NameDescription
TG_API_TOKENTelegram API Token. Get it from BotFather.
CHANNEL_SUBSCRIBERSA comma separated list of channels that subscribe to news. Channels begin with @, no spaces. Example: "@channelname,@channel2". The bot must have the right to post to the channel. Can be empty or left out completely.
DB_HOSTDatabase host address.
DB_PORTDatabase host port.
DB_NAMEDatabase name.
DB_USERDatabase username.
DB_PASSWORDDatabase password for given DB_USER.