Documentation

This commit is contained in:
Davte 2019-07-13 18:26:12 +02:00
parent fc7da6d1bd
commit 0ac4553591
3 changed files with 36 additions and 9 deletions

View File

@ -22,20 +22,24 @@ my_other_token = 'token_of_bot2'
## Usage ## Usage
``` ```
from davtelepot import Bot import sys
from davtelepot.bot import Bot
from data.passwords import my_token, my_other_token from data.passwords import my_token, my_other_token
my_bot = Bot.get(token=my_token, db_name='my_db') long_polling_bot = Bot(token=my_token, database_url='my_db')
my_other_bot = Bot.get(token=my_other_token, db_name='my_other_db') webhook_bot = Bot(token=my_other_token, hostname='example.com',
certificate='path/to/certificate.pem',
database_url='my_other_db')
@my_bot.command('/foo') @long_polling_bot.command('/foo')
async def foo_command(update): async def foo_command(bot, update, user_record):
return "Bar!" return "Bar!"
@my_other_bot.command('/bar') @webhook_bot.command('/bar')
async def bar_command(update): async def bar_command(bot, update, user_record):
return "Foo!" return "Foo!"
Bot.run() exit_state = Bot.run()
sys.exit(exit_state)
``` ```
Check out `help(Bot)` for detailed information. Check out `help(Bot)` for detailed information.

View File

@ -7,7 +7,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.0" __version__ = "2.0.1"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -2,6 +2,29 @@
camelCase methods mirror API directly, while snake_case ones act as middlewares camelCase methods mirror API directly, while snake_case ones act as middlewares
someway. someway.
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')
webhook_bot = Bot(token=my_other_token, hostname='example.com',
certificate='path/to/certificate.pem',
database_url='my_other_db')
@long_polling_bot.command('/foo')
async def foo_command(bot, update, user_record):
return "Bar!"
@webhook_bot.command('/bar')
async def bar_command(bot, update, user_record):
return "Foo!"
exit_state = Bot.run()
sys.exit(exit_state)
```
""" """
# Standard library modules # Standard library modules