Skip to main content

SDK for interacting with LotusChat API

Project description

Lotus-chat Bot Sdk

A lightweight and extensible Python SDK to interact with the LotusChat Bot API


🚀 Summary

Documents Chatbot from Lotus: https://lotuschat.vn/user/chatbots/docs

LotusChat Bot SDK simplifies integration with the LotusChat platform. It supports:

  • Sending messages, documents, and commands
  • Receiving and handling incoming messages via webhook or polling
  • Custom keyboard and entity formatting
  • Async and sync interfaces

💻 Version

lastest version: 0.1.18

Install dependencies:

pip install lotuschat-bot-sdk

⚙️ Python Compatibility

  • Supported versions: >=3.13

📦 Dependencies

Library Purpose
aiohttp Async HTTP requests
pydantic Data validation / modeling
schedule Scheduled jobs
flask Webhook support (optional)
requests Synchronous fallback
pillow Image conversion (.webp, etc)
beautifulsoup4 HTML parsing for sticker sets
playwright Optional: scrape dynamic content (requires install)

Change log versions:

  • 0.1.18:
    • add webhook async for quart, old webhook for flask
  • 0.1.17:
    • submit _handle_message_hook with async thought thread pool
    • change all listener event to async
    • add example
  • 0.1.16:
    • add async to _handle_message_hook
  • 0.1.15:
    • add document
    • change structure for
    • fix import error in command.
    • add edit message and edit message api
  • 0.1.14:
    • fix send message có truyền entity
    • and 3 api set,get,delete command
    • fix return raw messge nếu response nó trả về không phải json
  • 0.1.13:
    • add async cho function
    • add delete message function
    • change package sdk -> lotuschat_sdk
  • 0.1.12:
    • update 2 api sendMessage & getUpdates full parameters
    • open entity_extract used for extract entities in messages object

How to use

init

    bot = ChatBot(
        name="bot name used for filter message from this bot",
        token="bot token, get from @BotCreator",
        max_threads=5, # Optional : thread number used for bot, default = 5
        is_vpn=True # Optional : True for develop, False for lotuschat.vn
    )

hook message with flask

    app = Flask(__name__)
    
    @app.route("/", methods=["POST"])
    def lc_webhook():
        return bot.web_hook_flask()

hook message with quart

    app = Quart(__name__)
    
    @app.route("/", methods=["POST"])
    async def lc_webhook():
        return bot.web_hook()

add listener

    async def on_errors(self, error):
        print(f"handle bot error")

    async def on_self_messages(self, text: str, chat_id: int, message: Message):
        print(f"handle all message from this bot")

    async def on_messages(self,  text: str, chat_id: int, message: Message):
        print(f"handle all message")

    async def on_messages_no_command(self, text: str, chat_id: int, message: Message):
        print(f"handle all message with no command")

    async def on_commands(self, command: str, args: list[Argument], chat_id: int, message: Message):
        print(f"handle all command with format /temp argument1 argument2...")

    async def on_temp_command(self, args: list[Argument], chat_id: int, message: Message):
        print(f"handle temp command with format /temp argument1 argument2...")

    bot = ChatBot(
        name="bot name used for filter message from this bot",
        token="bot token, get from @BotCreator",
    )
    bot.set_on_errors(on_errors)
    bot.set_self_messages(on_self_messages)
    bot.set_on_messages(on_messages)
    bot.set_on_messages(on_messages_no_command, is_get_command=False)
    set_on_commands(on_commands)
    bot.set_on_command("/temp", on_temp_command)

Project details


Download files

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

Source Distribution

lotuschat_bot_sdk-0.1.18.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lotuschat_bot_sdk-0.1.18-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file lotuschat_bot_sdk-0.1.18.tar.gz.

File metadata

  • Download URL: lotuschat_bot_sdk-0.1.18.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for lotuschat_bot_sdk-0.1.18.tar.gz
Algorithm Hash digest
SHA256 2b0baf26a214a2287968062eee130e34d9b6532b148aee14b45c048b4c7ee5f3
MD5 40e177012ef4be44ea00df7ca8b4d28d
BLAKE2b-256 9868f4f159ea0c570f254cb3e4f73b2272183886ddf7a707e476221423637420

See more details on using hashes here.

File details

Details for the file lotuschat_bot_sdk-0.1.18-py3-none-any.whl.

File metadata

File hashes

Hashes for lotuschat_bot_sdk-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 d273c8c5136bc858f05fe92970206c70190eed3b8835ca7eef6f315ccca422b5
MD5 10c8dae658ebc4add433b7d5972e5324
BLAKE2b-256 1dd1d7c647bd9b6d4dd2a24bdde083936b78e35cffe4f48d42955d9513162866

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page