Load bot info from environment

This commit is contained in:
David Todd 2020-01-19 17:45:07 -06:00
parent efcf7f91a1
commit a356c50ce0
4 changed files with 24 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@
*~
.vscode
.env
bot.session

View File

@ -9,11 +9,18 @@ The production environment will eventually be hosted at [save.c0de.link](https:/
This project uses [Pipenv](https://pipenv.readthedocs.io/en/latest/) to manage the dependencies, so install that first after cloning this repository.
* Install dependencies - `pipenv install`
* Create a Telegram bot (see Creating a Telegram Bot)
* Enter the environment - `pipenv shell`
* Start the server - `python server.py`
* Start the server - `bash run.sh`
The server will be running on `http://localhost:8080/`
### Creating a Telegram bot
1. Login to [my.telegram.org/apps](https://my.telegram.org/apps) and create a Web App - You will need the `api_id` and `api_hash`
1. Message the [BotFather](https://t.me/BotFather) to get an `api_token`
1. Copy `sample.env` to `.env` and fill in the details from the previous steps
## Available Requests
Now that you have a running server, you can issue requests via a web browser, curl, wget, etc to the following endpoints:

7
run.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# Copyright 2020 - David Todd (c0de@c0defox.es)
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
# Part of the Simple Bookmark Service
source .env
python server.py

8
sample.env Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
# Copyright 2020 - David Todd (c0de@c0defox.es)
# Licensed under the MIT License (https://opensource.org/licenses/MIT)
# Part of the Simple Bookmark Service
export telethon_api_id=
export telethon_api_hash=
export telethon_token=