Skip to main content

Lark(A.K.A 飞书) Group Bot python API.

Project description

pylgb

Python versions License: MIT

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

  1. Add a custom bot in your Lark group
  2. Copy the webhook URL or just the key (UUID format)
  3. 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

License

MIT License

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

pylgb-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

pylgb-0.1.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

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

Hashes for pylgb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bef98ad86084c43f68d72416067599559d23d28d3047efa94362ca0a3b51a7f0
MD5 dde201843c61406aeafadc9d18cc2b23
BLAKE2b-256 d3a27dfb972bc2f7cd9f75aefe27e6211f6efc955b4c69b4139a1d47c35f1cec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylgb-0.1.0.tar.gz:

Publisher: release.yml on ChowRex/pylgb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pylgb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca356a1074bc487067c88b2abcaf9513986859cec67921c96b013e34f460a8e
MD5 46fdf941797ce51a704bdd3398bc6fae
BLAKE2b-256 b0010e4d80f8825788fc190185faa9a5e2a8f0f0d60c4ed5ebfcebd89131c9f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pylgb-0.1.0-py3-none-any.whl:

Publisher: release.yml on ChowRex/pylgb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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