From d88e4439ad26ecea3c77b315aae3a5f6183489d0 Mon Sep 17 00:00:00 2001 From: Gleb Garanin Date: Thu, 13 May 2021 17:51:54 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20example=20of=20usage=20pollin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fece638..03ebb4cc 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ asyncio.run(main()) ``` -## 🌟Webhooks & handlers +## 🌟Webhooks / polling & handlers ```python import logging @@ -205,6 +205,36 @@ wallet.start_webhook( ``` +## 🧑🏻‍🔬Polling updates +```python +import datetime + +from glQiwiApi import QiwiWrapper, types + +api_access_token = "your token" +phone_number = "your number" + +wallet = QiwiWrapper( + api_access_token=api_access_token, + phone_number=phone_number +) + + +@wallet.transaction_handler() +async def my_first_handler(update: types.Transaction): + assert isinstance(update, types.Transaction) + + +def on_startup(wrapper: QiwiWrapper): + wrapper.dispatcher.logger.info("This message logged on startup") + + +wallet.start_polling( + get_updates_from=datetime.datetime.now() - datetime.timedelta(hours=1), + on_startup=on_startup +) +``` + ## 💳Send to card & check commission ```python