The aim of this project is to build a telegram bot, that accepts an image as a file or photo and uploads it to Instagram. It also adds appropriate hashtags and geotags based on image data. Video and gallery support could be added at later stages of the project.
In order to get things working user needs to provide these environment variables:
credentials for an account to post to
INSTAGRAM_USERNAME=username
INSTAGRAM_PASSWORD=passw0rdcredentials for adding appropriate #hashtags, see this guide to setup
GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/file.jsontoken and settings
TELEGRAM_BOT_TOKEN=123456789:FSw4TQw4gwaRARDfasdfaW$R@qrh9jhu
# this is for debugging, set to anything to enable
DEBUG_TELEGRAM_BOT=1
# if set run server as Webhook otherwise run in Long-Polling client mode
WEBHOOK_MODE=1
# bot webhook settings (unneeded in polling mode)
SERVER_BASE_URL=https://www.google.com:8443/
CERT_FILE=cert.pem
KEY_FILE=key.pemto get this key and cert files use something like this:
$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodesor use ones from LetsEncrypt
in order to get image stylized, use this server as a reference implementation:
STYLE_SERVER_URL=https://example.com/uploadto get a nice caption for the photo, use something like deepai API
CAPTION_API_URL=https://api.deepai.org/api/neuraltalk
CAPTION_API_KEY=fffffff-0123-4567-8901-fffffffffffffto have a nice emoji icons in photo caption, use something like this serverless API
EMOJI_API_URL=https://wt-01234567890-0.sandbox.auth0-extend.com/emojifyThe program expects no parameters, just set environment variables correctly. It could be run like so:
$ instabotAfter running the program sits there and listens for incoming updates from telegram.
For convenience a simple Dockerfile is provided. Using it one can build a container:
NOTE: Before building a container don't forget to place all necessary file(s) inside the folder,
such as keys, certs, JSONs.
$ docker build -t instabot .And then run it like so:
$ docker run -e INSTAGRAM_USERNAME=username -e INSTAGRAM_PASSWORD=passw0rd -e TELEGRAM_BOT_TOKEN=123456789:FSw4TQw4gwaRARDfasdfaW$R@qrh9jhu -e GOOGLE_APPLICATION_CREDENTIALS=/path/to/service/account/file.json instabot