Skip to content

iley/digestbot

Repository files navigation

Digestbot

Personal Telegram bot that sends a daily digest combining weather and news.

Digest contents

  • Weather — today's forecast (temperature range, precipitation, conditions) from Open-Meteo
  • Irish Times — top 3 stories from the Irish Times RSS feed, selected and summarized by an LLM
  • Meduza — top 3 stories from the Meduza RSS feed, selected and summarized in Russian by an LLM

Prerequisites

  • Go 1.26+
  • A Telegram bot token (from @BotFather)
  • The chat ID where the bot should send messages (send a message to your bot, then visit https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates — the chat ID is in result[].message.chat.id)
  • An OpenAI API key (from platform.openai.com)

Configuration

All configuration is done via environment variables or CLI flags. Flags take precedence over environment variables.

Setting Env var Flag Required Default
Telegram bot token DIGESTBOT_BOT_TOKEN --bot-token yes
Telegram chat ID DIGESTBOT_CHAT_ID --chat-id yes
Latitude DIGESTBOT_LATITUDE --latitude yes
Longitude DIGESTBOT_LONGITUDE --longitude yes
OpenAI API key DIGESTBOT_OPENAI_API_KEY --openai-api-key yes
Timezone DIGESTBOT_TIMEZONE --timezone no Europe/Dublin
Segments DIGESTBOT_SEGMENTS --segments no weather,irishtimes,meduza

Latitude and longitude are used to fetch weather from Open-Meteo. Timezone must be a valid tz database name (e.g. Europe/Dublin, America/New_York).

Segments controls which digest sections are included and in what order. Available segments: weather, irishtimes, meduza.

Running

From source

go build ./cmd/digestbot

DIGESTBOT_BOT_TOKEN=123:ABC \
DIGESTBOT_CHAT_ID=-100123456 \
DIGESTBOT_LATITUDE=53.35 \
DIGESTBOT_LONGITUDE=-6.26 \
DIGESTBOT_OPENAI_API_KEY=sk-... \
./digestbot

Or with flags:

./digestbot --bot-token 123:ABC --chat-id -100123456 --latitude 53.35 --longitude -6.26 --openai-api-key sk-...

With go run

DIGESTBOT_BOT_TOKEN=123:ABC \
DIGESTBOT_CHAT_ID=-100123456 \
DIGESTBOT_LATITUDE=53.35 \
DIGESTBOT_LONGITUDE=-6.26 \
DIGESTBOT_OPENAI_API_KEY=sk-... \
go run ./cmd/digestbot

Docker

docker build -t digestbot .

docker run --rm \
  -e DIGESTBOT_BOT_TOKEN=123:ABC \
  -e DIGESTBOT_CHAT_ID=-100123456 \
  -e DIGESTBOT_LATITUDE=53.35 \
  -e DIGESTBOT_LONGITUDE=-6.26 \
  -e DIGESTBOT_OPENAI_API_KEY=sk-... \
  digestbot

Development

go vet ./...
go fmt ./...
go test ./...

About

My personal daily digest Telegram bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages