Categorygithub.com/ndrewnee/lesswrong-bot
modulepackage
0.0.0-20210318142815-2afc11d648a6
Repository: https://github.com/ndrewnee/lesswrong-bot.git
Documentation: pkg.go.dev

# README

๐Ÿค– lesswrong-bot

Go

Telegram bot for reading posts from:

๐Ÿ˜Ž Usage

Commands:

/top - Top posts

/random - Read random post

/source - Change source:

  1. Lesswrong.ru (default)
  2. Slate Star Codex
  3. Astral Codex Ten.
  4. Lesswrong.com

/help - Help

๐Ÿง‘โ€๐Ÿ’ป Run locally

Register new bot at https://t.me/BotFather or use previously created one.

Take bot access token.

Before running copy sample file and replace env vars with your credentials

cp .env.sample .env
source .env

Run application locally:

make run

Redis is used as cache. If redis isn't available fallbacks to memory cache.

Also you can run bot with redis in docker compose:

docker-compose up

๐Ÿ‘ท Build

Build binary

make build

๐Ÿงช Testing

Run unit tests

make test

Run integration tests

make test_integration

๐Ÿ– Lint

Run linters

make lint

๐Ÿ›ฅ Deployment

Automatic CI/CD pipelines are building and testing the bot on each PR.

Demo bot is deployed to production on Heroku on merge to master.

To deploy your app on Heroku read documentation.

brew install heroku/brew/heroku

heroku login
heroku create lesswrong-bot
heroku config:set WEBHOOK=true
heroku config:set TOKEN=<token>
heroku webhooks:add -i api:build -l notify -u https://deploy-hook-bot.herokuapp.com/hooks -t <auth_token> # To add deploy hook

git push heroku main

If application is already setup just run:

make deploy

๐Ÿ›  Environment variables

Env varTypeDescriptionDefault
REDIS_URLStringRedis connection stringredis://localhost:6379/1
TOKENStringTelegram bot access token
DEBUGBooleanEnable debug modefalse
WEBHOOKBooleanEnable webhook modefalse
PORTStringPort for webhook9999
WEBHOOK_HOSTStringWebhook host for telegram bothttps://lesswrong-bot.herokuapp.com
TIMEOUTIntegerRequest timeout in seconds15s
CACHE_EXPIREIntegerPosts cache expire in hours24h

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author