Skip to main content

Extra Async Support for LINE Messaging API SDK

Project description

PyPI - Version PyPI - Status PyPI - Python Version PyPI - License Code Style - Black Ko-fi - Donate

Extra feature for LINE Messaging API SDK for Python.

Installation

pip install line-bot-sdk-extra

or:

python setup.py install

To use the package:

>>> import linebotx

Features

Asynchronous API

Allows you to write non-blocking code which makes your bot respond much faster with little changes.

Synchronous:

from linebot import LineBotApi, WebhookHandler
line_bot_api = LineBotApi('YOUR_CHANNEL_ACCESS_TOKEN')
handler = WebhookHandler('YOUR_CHANNEL_SECRET')

Asynchronous:

from linebotx import LineBotApiAsync, WebhookHandlerAsync
line_bot_api = LineBotApiAsync('YOUR_CHANNEL_ACCESS_TOKEN')
handler = WebhookHandlerAsync('YOUR_CHANNEL_SECRET')

Equivalent Counterpart

linebotx linebot
LineBotApiAsync LineBotApi
AioHttpClient HttpClient
AioHttpResponse HttpResponse
WebhookHandlerAsync WebhookHandler

NOTE: Every public method is coroutine and should be awaited. For example:

@app.route("/callback", methods=['POST'])
async def callback():
   ...
   await handler.handle(body, signature)
   ...


@handler.add(MessageEvent, message=TextMessage)
async def handle_message(event):
    await line_bot_api.reply_message(
       event.reply_token,
       TextSendMessage(text=event.message.text))

Additional Methods

coroutine LineBotApiAsync.close()
Close underlying http client.
coroutine AioHttpClient.close()
See aiohttp.ClientSession.close().

Timeout

To set a timeout you can pass aiohttp.ClientTimeout object instead of numeric value.

Examples

Contributing

If you would like to contribute, please check for open issues or open a new issue if you have ideas, changes, or bugs to report.

References

This project is just a small addition to the original SDK, please refer to line-bot-sdk-python or the docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for line-bot-sdk-extra, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size line_bot_sdk_extra-0.1.2-py3-none-any.whl (7.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size line-bot-sdk-extra-0.1.2.tar.gz (8.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page