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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openilink_sdk_python-0.1.0.tar.gz.
File metadata
- Download URL: openilink_sdk_python-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a44fcd7678069b46876f1d6edb8a981236c4ea23349d7623e0257950565faa9
|
|
| MD5 |
3ed28dceb4df8a95b38bd2c4e9b010fa
|
|
| BLAKE2b-256 |
ffb1a2c0db44546ad0ebc3038a0bf9070691b043324b64d0a9104328b5e3b774
|
File details
Details for the file openilink_sdk_python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openilink_sdk_python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e045e9f43f0d76c2470ff47ab2d88c461bf2f681cc398552255e78ae5d8f16c2
|
|
| MD5 |
0db6cfe0b93639b74ed145f3ce698da0
|
|
| BLAKE2b-256 |
cc97756aa0cfe9175ab75321870aee1555daaa60b15d4d80ace7bee05c332a42
|