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 # davtelepot
This project conveniently mirrors the Telegram bot API with the class `Bot`. 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. Check requirements.txt for third party dependencies.
@ -9,21 +9,21 @@ Check out `help(Bot)` for detailed information.
## Project folders ## Project folders
### data folder ### `davtelepot/data` folder
* `*.db`: databases used by bots * `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) * `*.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)
``` ### `examples` folder
my_token = 'token_of_bot1' This folder contains full-commented and ready-to-run examples for simple davtelepot.bot Telegram bots.
my_other_token = 'token_of_bot2'
...
```
## Usage ## Usage
``` ```
import sys import sys
from davtelepot.bot import Bot from davtelepot.bot import Bot
from data.passwords import my_token, my_other_token from data.passwords import my_token, my_other_token
long_polling_bot = Bot(token=my_token, database_url='my_db') 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') @long_polling_bot.command('/foo')
async def foo_command(bot, update, user_record): async def foo_command(bot, update, user_record):
return "Bar!" return "Bar!"
@webhook_bot.command('/bar') @webhook_bot.command('/bar')
async def bar_command(bot, update, user_record): 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) sys.exit(exit_state)
``` ```
Check out `help(Bot)` for detailed information. Check out `help(Bot)` for detailed information.