Lark(A.K.A 飞书) Group Bot python API.
Project description
pylgb
Lark(A.K.A Feishu) Group Bot Python API - A simple and easy-to-use library for sending messages to Lark group bots.
Features
- 🤖 Smart Bot - Automatic message type detection
- 📝 Multiple Message Types - Text, Post, Image, Interactive Card
- 🔒 Signature Support - HMAC-SHA256 signature verification
- ✅ Type Hints - Full type annotation support
- 📦 Minimal Dependencies - Only requires requests
Installation
pip install pylgb
Quick Start
1. Get Webhook URL and Sign Key
- Add a custom bot in your Lark group
- Copy the webhook URL or just the key (UUID format)
- If signature verification is needed, copy the signing key
2. Send Messages
from pylgb import SmartBot
# Without signature
bot = SmartBot("your-webhook-key")
# With signature
bot = SmartBot("your-webhook-key", sign_secret="your-sign-secret")
# Send text message
bot.send("Hello, World!")
# Send text with @mentions
bot.send("Important!", mentioned_list=["ou_xxxx", "@all"])
Usage Guide
Text Message
from pylgb import TextBot
# Without signature
bot = TextBot("your-key")
# With signature
bot = TextBot("your-key", sign_secret="your-sign-secret")
bot.send("Text message", mentioned_list=["ou_xxxx"])
Post (Rich Text) Message
from pylgb import PostBot
content = [
[{"tag": "text", "text": "Project Weekly Report"}],
[{"tag": "text", "text": "Progress: 80%"}]
]
bot = PostBot("your-key", sign_secret="your-sign-secret")
bot.send("Weekly Report", content)
Interactive Card
from pylgb import InteractiveBot
card = {
"header": {"title": {"tag": "plain_text", "content": "Notification"}},
"elements": [{"tag": "div", "text": {"tag": "plain_text", "content": "Deployed successfully"}}]
}
bot = InteractiveBot("your-key", sign_secret="your-sign-secret")
bot.send(card)
Using SmartBot Auto-Detection
from pylgb import SmartBot
bot = SmartBot("your-key", sign_secret="your-sign-secret")
# Text
bot.send("Text message")
# Image
bot.send({"image_key": "img_xxxx"})
# Card
bot.send({"card": {"header": {...}, "elements": [...]}})
Project Structure
pylgb/
├── src/pylgb/
│ ├── __init__.py # Entry module
│ ├── _constants.py # Constants
│ └── bot/
│ ├── __init__.py
│ ├── _abstract.py # BaseBot class (with signature)
│ ├── _smart.py # SmartBot
│ ├── text.py # TextBot
│ ├── post.py # PostBot
│ ├── image.py # ImageBot
│ └── interactive.py # InteractiveBot
├── pyproject.toml
├── LICENSE
└── README.md
Development
# Install dev dependencies
pip install -e ".[test]"
# Run tests
pytest --cov=pylgb -v
References
- Lark Open Platform - Custom Bot
- pywgb - Wecom Group Bot API
License
MIT License
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
pylgb-0.0.1.tar.gz
(12.1 kB
view details)
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
pylgb-0.0.1-py3-none-any.whl
(13.6 kB
view details)
File details
Details for the file pylgb-0.0.1.tar.gz.
File metadata
- Download URL: pylgb-0.0.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8867e0eb29ddaee716add629d0a0a5b982e37aaa751de313906a82e64b2fadec
|
|
| MD5 |
5ad4b1731ef8f50c6b20d2ab2b5c6aed
|
|
| BLAKE2b-256 |
46323bb09848595e47678b5ba19d01e857a63d11b7ca2a4e9eb1859e62e1eac3
|
File details
Details for the file pylgb-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pylgb-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4602d74004182034ba41546f12245d0ba21ded8a3637e966114eaf2fed94760a
|
|
| MD5 |
2ee948a948bfc9ec00d9a097f37d1ccb
|
|
| BLAKE2b-256 |
1871a4bf02c9ab483cb801f273ecf54325196fbf13b12fc3992978de1a0ae137
|