Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Repository files navigation

Better alternative: https://github.com/uezo/aiolinebot

🤖 line-bot-sdk-python-extra

PyPI - VersionPyPI - StatusPyPI - Python VersionPyPI - LicenseCode Style - BlackKo-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:

fromlinebotimportLineBotApi, WebhookHandlerline_bot_api=LineBotApi('YOUR_CHANNEL_ACCESS_TOKEN')
handler=WebhookHandler('YOUR_CHANNEL_SECRET')

Asynchronous:

fromlinebotximportLineBotApiAsync, WebhookHandlerAsyncline_bot_api=LineBotApiAsync('YOUR_CHANNEL_ACCESS_TOKEN')
handler=WebhookHandlerAsync('YOUR_CHANNEL_SECRET')
Equivalent Counterpart
linebotxlinebot
LineBotApiAsyncLineBotApi
AioHttpClientHttpClient
AioHttpResponseHttpResponse
WebhookHandlerAsyncWebhookHandler

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

@app.route("/callback", methods=['POST'])asyncdefcallback():
...
awaithandler.handle(body, signature)
...
@handler.add(MessageEvent, message=TextMessage)asyncdefhandle_message(event):
awaitline_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.

About

Extra feature for LINE Messaging API SDK for Python

Topics

Resources

Stars

14 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages