Skip to main content

Python client for the Weixin iLink Bot API

Project description

openilink-sdk-python

Python SDK for the Weixin iLink Bot API.

Install

pip install -e .

Quick Start

from openilink import Client, LoginCallbacks, MonitorOptions, extract_text

client = Client()

# QR code login
result = client.login_with_qr(
    callbacks=LoginCallbacks(
        on_qrcode=lambda url: print(f"Scan: {url}"),
        on_scanned=lambda: print("Scanned!"),
    )
)
print(f"Connected: BotID={result.bot_id}")

# Echo bot
client.monitor(
    lambda msg: client.push(msg.from_user_id, "echo: " + extract_text(msg)),
    opts=MonitorOptions(
        on_error=lambda e: print(f"Error: {e}"),
    ),
)

API

Method Description
Client(token, base_url, ...) Create client
client.login_with_qr(callbacks) QR code login
client.monitor(handler, opts) Long-poll message loop
client.send_text(to, text, context_token) Send text message
client.push(to, text) Send with cached context token
client.send_typing(user_id, ticket, status) Typing indicator
client.get_config(user_id, context_token) Get bot config
client.get_upload_url(req) Get CDN upload URL
client.stop() Stop monitor loop
extract_text(msg) Extract first text from message

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

openilink_sdk_python-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

openilink_sdk_python-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

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