Information updated

This commit is contained in:
Davte 2019-07-15 18:06:32 +02:00
parent 8ab1ec4461
commit 925c03b1ed

View File

@ -1,7 +1,7 @@
# davtelepot
This project conveniently mirrors the Telegram bot API with the class `Bot`.
Please note that you need Python3.5+ to run async code.
Please note that Python3.5+ is needed to run async code.
Check requirements.txt for third party dependencies.
@ -9,21 +9,21 @@ Check out `help(Bot)` for detailed information.
## Project folders
### data folder
* `*.db`: databases used by bots
### `davtelepot/data` folder
* `config.py` contains configuration settings (e.g. certificate path, local_host, port etc.)
* `passwords.py` contains secret information to be git-ignored (e.g. bot tokens)
* `*.db` files are SQLite databases used by bots
* `*.log`: log files (store log_file_name and errors_file_name in `data/config.py` module)
* `passwords.py`: contains secret information to be git-ignored (e.g. bot tokens)
```
my_token = 'token_of_bot1'
my_other_token = 'token_of_bot2'
...
```
### `examples` folder
This folder contains full-commented and ready-to-run examples for simple davtelepot.bot Telegram bots.
## Usage
```
import sys
from davtelepot.bot import Bot
from data.passwords import my_token, my_other_token
long_polling_bot = Bot(token=my_token, database_url='my_db')
@ -33,13 +33,16 @@ webhook_bot = Bot(token=my_other_token, hostname='example.com',
@long_polling_bot.command('/foo')
async def foo_command(bot, update, user_record):
return "Bar!"
return "Bar!"
@webhook_bot.command('/bar')
async def bar_command(bot, update, user_record):
return "Foo!"
return "Foo!"
exit_state = Bot.run()
exit_state = Bot.run(
local_host='127.0.0.5',
port=8552
)
sys.exit(exit_state)
```
Check out `help(Bot)` for detailed information.