Skip to content

donglinfei-debug/feishu-bot-pusher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“£ Feishu Bot Pusher

Python module for sending 7 types of messages via Feishu (Lark) Bot API

GitHub Stars GitHub Issues GitHub Forks License Python Feishu

🌏 Language / θ―­θ¨€οΌšπŸ‡¨πŸ‡³ δΈ­ζ–‡ | πŸ‡¬πŸ‡§ English


A Python module for sending multi-type messages to Feishu (Lark) via the Open API Bot identity β€” not a webhook. Supports text, image, file, audio, video, rich text (post), and interactive card messages with automatic token management.

πŸ“Œ Why This?

You've built a Python script that needs to send messages to Feishu β€” but the webhook isn't enough.

  • You want to send images, files, audio, video β€” Feishu webhooks only support text and simple cards
  • Your token expires every 2 hours β€” without automatic refresh, your bot goes silent until you manually re-authenticate
  • You need interactive cards β€” the raw Feishu Open API is verbose and error-prone to call directly
  • You have multiple automation scripts β€” each one ends up duplicating the same Feishu integration code

Feishu Bot Pusher wraps all of this into a single from feishu_bot import FeiShuBot. One import, 7 message types, automatic token management. Your scripts stay clean, your team stays notified.

πŸ—οΈ Architecture

flowchart LR
    subgraph YourCode["🧩 Your Application"]
        APP[Your Script]
    end
    subgraph Module["πŸ“¦ feishu_bot.py"]
        FB[FeiShuBot Class]
        TM[Token Manager<br/>auto-refresh]
        FU[File Uploader<br/>auto-upload]
    end
    subgraph Feishu["☁️ Feishu OpenAPI"]
        API[Open API Gateway]
    end

    APP --> FB
    FB --> TM
    FB --> FU
    FB --> API

    style APP fill:#6366f1,color:#fff,stroke:none
    style FB fill:#0ea5e9,color:#fff,stroke:none
    style TM fill:#0ea5e9,color:#fff,stroke:none
    style FU fill:#0ea5e9,color:#fff,stroke:none
    style API fill:#f59e0b,color:#fff,stroke:none
Loading

πŸ“¦ Features

# Feature Description
1 7 Message Types Text, image, file, audio, video, rich text, interactive card
2 Bot Identity Sends as a Feishu Bot (not a webhook)
3 Auto Token Mgmt Caches tenant_access_token with auto-refresh
4 Media Auto-Upload Uploads images/files before sending
5 Flexible Config Env vars, config file, or constructor args

πŸ“¦ Requirements

Requirement Version
Python 3.7+
requests Any recent version
Feishu App Self-built app with Bot capability enabled

πŸš€ Quick Start

pip install requests
from feishu_bot import FeiShuBot

bot = FeiShuBot()

# Send text
bot.send_text("Hello from Feishu Bot")

# Send image
bot.send_image("screenshot.png")

# Send rich text
bot.send_post("Notice", [
    {"tag": "md", "text": "**Update**: v2.0 released"},
    {"tag": "a", "text": "Details", "href": "https://example.com"},
])

πŸ“ Files

feishu-bot-pusher/
β”œβ”€β”€ feishu_bot.py         # Core module β€” FeiShuBot class
β”œβ”€β”€ feishu_config.json    # Config file (optional)
β”œβ”€β”€ .env.example          # Environment variable template
β”œβ”€β”€ requirements.txt      # requests
β”œβ”€β”€ LICENSE               # MIT
└── README.md / README.zh.md

❓ FAQ

Can I send messages to a group chat instead of an individual user? Yes. Feishu Bot supports both private chat and group chat. Set the receive_id_type to chat_id to send to a group.

Does this support Feishu interactive cards with buttons? Yes. send_card() supports color headers, buttons, markdown content, and dividers. You pass a standard Feishu card JSON structure.

How does token auto-refresh work? The FeiShuBot caches tenant_access_token in memory and automatically requests a new one before it expires β€” so you never get 99991663 auth errors.

Can I use this with multiple Feishu apps? Yes. Create multiple FeiShuBot instances with different app_id/app_secret pairs. Each manages its own token lifecycle independently.

πŸ“„ License

MIT Β© 2026 Ryan Dong

🌟 Star History

Star History Chart

πŸ‘€ About the Author

Ryan Dong β€” AI Product Manager & Full-Stack Developer

I bridge the gap between AI capabilities and production-ready software. My work spans the full stack: from designing AI-powered product features and integrating LLM APIs, to building modular backend services and shipping clean, documented code.

Role Focus
🧠 AI Product Manager Product strategy, AI feature design, prompt engineering, model selection
πŸ’» Full-Stack Developer Python, FastAPI, Google Apps Script, automation pipelines, API integration

This repository is part of a personal toolbox β€” a growing collection of practical, reusable modules that solve real automation problems. Each project is designed to be independently useful and easily integrated into larger systems.

πŸ“¬ donglinfei@gmail.com β€” open to business discussions, collaborations, and recruiting inquiries.

πŸ“¬ Contact

Ryan Dong β€” donglinfei@gmail.com

About

Python module for sending multi-type messages to Feishu (Lark) Bot API. Text, image, file, audio, video, rich text, interactive cards. Auto token management.

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages