Skip to content

yalagtyarzh/leaf_bot

Repository files navigation

Leaf (pocket) bot

LeafBot - is a Telegram bot, which allows you to save link in the application Pocket. Leafbot is a client for Pocket.

Used libraries:

Implement

First at all, when the bot started, bot generates the link with unique request token, which created and stored in DB when user started the bot, and send it to the user, at the click of the link authorization process starts.

To implement user authorization, together with the bot, an HTTP server is started on port 80. HTTP server is using for creating access token, put it in the DB and redirecting from Pocket after successful user authorization.

After the authorization process, user can save links to Pocket by LeafBot.

How to use

For local using you can clone this repository via git:

git clone github.com/yalagtyarzh/leaf_bot

or install it via go:

go install github.com/yalagtyarzh/leaf_bot

After, you need to:

  • Build a program with the pre-registred enviroment dependencies using Docker:
docker build -t <build-name> .

and run it like that:

docker run -e TOKEN -e CONSUMER_KEY -e AUTH_SERVER_URL -d \ --name <container-name>

You can use Makefile for building docker image and running docker container (Makefile must be installed).

  • Uncomment os.Setenv functions in config.go and enter telegram bot token instead of YourAwesomeBotToken, enter Pocket consumer key instead of YourAwesomePocketToken and enter vaild authorization server instead and build program using go tools or Makefile (Makefile must be installed) (not recommended).
make run

After these steps, the bot should start (hopefully Kappa).

Stack: