Instagram Saver Bot is an application I built to learn Go. It makes use of the Telebot package.
What Instagram Saver Bot does is to provide users with the ease of sending an Instagram URL and the bot sends back the user the image(s) requested. All through Telegram.
The application is live, hosted on Heroku, at @InstagramSaverBot.
There are two ways the application can be started:
Primarily, the application uses a config.yml
file.
Navigate to configs/. Make a copy of config.sample.yml
to
config.yml
and fill up the api_token
field with your
Telegram Bot token:
configs:
app_env: development
telegram_bot:
api_token: <insert your API token here>
api_url: https://api.telegram.org
bot_name: Instagram Saver Bot
To add-on the flexibility of using environment variables such as running on
Heroku, one could pass the -env
flag to the binary (built or using go run
)
to use.
$ export API_TOKEN=<insert your API token here>
$ export API_URL=https://api.telegram.org
$ export BOT_NAME=your-bot-name
$ ./instagramsaverbot -env
The Dockerfile makes use of multi-stage building to keep the resulting image size small.
You can build the image using:
$ make docker.build
...
Or:
$ docker build -f ./build/Dockerfile .
...
Run the built image with detached mode using:
$ docker run -d <IMAGE ID>
...
The binary that was compiled into the image will run automatically. To view logs (with -f flag to follow):
$ docker logs -f <CONTAINER ID>
{"event":"Loaded config file","timestamp":"2019-03-07T11:39:40.624153Z"}
{"event":"Unmarshalled config file","timestamp":"2019-03-07T11:39:40.624405Z"}
{"event":"Loaded Telegram message handlers","timestamp":"2019-03-07T11:39:42.208533Z"}
Build the binary using:
$ make go.build.generic
...
Or compile it with:
$ go build ./cmd/instagramsaverbot
...
Then, run the binary like:
$ ./instagramsaverbot
{"event":"Loaded config file","timestamp":"2019-03-07T11:39:40.624153Z"}
{"event":"Unmarshalled config file","timestamp":"2019-03-07T11:39:40.624405Z"}
{"event":"Loaded Telegram message handlers","timestamp":"2019-03-07T11:39:42.208533Z"}
...