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
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 pylgb-0.1.0.tar.gz.
File metadata
- Download URL: pylgb-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bef98ad86084c43f68d72416067599559d23d28d3047efa94362ca0a3b51a7f0
|
|
| MD5 |
dde201843c61406aeafadc9d18cc2b23
|
|
| BLAKE2b-256 |
d3a27dfb972bc2f7cd9f75aefe27e6211f6efc955b4c69b4139a1d47c35f1cec
|
Provenance
The following attestation bundles were made for pylgb-0.1.0.tar.gz:
Publisher:
release.yml on ChowRex/pylgb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylgb-0.1.0.tar.gz -
Subject digest:
bef98ad86084c43f68d72416067599559d23d28d3047efa94362ca0a3b51a7f0 - Sigstore transparency entry: 1702398839
- Sigstore integration time:
-
Permalink:
ChowRex/pylgb@40019322c34919ce8852011949ef804fbbd94b28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ChowRex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@40019322c34919ce8852011949ef804fbbd94b28 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pylgb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pylgb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ca356a1074bc487067c88b2abcaf9513986859cec67921c96b013e34f460a8e
|
|
| MD5 |
46fdf941797ce51a704bdd3398bc6fae
|
|
| BLAKE2b-256 |
b0010e4d80f8825788fc190185faa9a5e2a8f0f0d60c4ed5ebfcebd89131c9f6
|
Provenance
The following attestation bundles were made for pylgb-0.1.0-py3-none-any.whl:
Publisher:
release.yml on ChowRex/pylgb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pylgb-0.1.0-py3-none-any.whl -
Subject digest:
7ca356a1074bc487067c88b2abcaf9513986859cec67921c96b013e34f460a8e - Sigstore transparency entry: 1702399164
- Sigstore integration time:
-
Permalink:
ChowRex/pylgb@40019322c34919ce8852011949ef804fbbd94b28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ChowRex
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@40019322c34919ce8852011949ef804fbbd94b28 -
Trigger Event:
push
-
Statement type: