pywayne-lark-bot
Feishu/Lark Bot API wrapper for full-featured Feishu bot interactions. Use when users need to send messages (text, image, audio, file, rich_text, card, share), especially Markdown delivery via send_markdown_message_to_chat with card_v2/post routing, table fallback, and auto chunking; build or update schema 2.0 cards; send in-place streaming reply cards with reply_streaming_card, update_streaming_card, recolor_streaming_card, stream_reply_card, or astream_reply_card; manage files (upload/download); query user/group info; reply to messages; forward/recall/update messages; edit previously sent text/rich_text/card messages via edit_text_message, edit_post_message, edit_card_message; add reactions; pin messages; manage chats (create, delete, update, members, admins); get message history; batch send; handle read receipts and urgent notifications.
What this skill does
# Pywayne Lark Bot - Full-Featured Feishu API Wrapper
## Overview
`LarkBot` is a comprehensive Feishu (Lark) application bot wrapper that provides complete bidirectional interaction capabilities. It's designed for scenarios requiring **full message lifecycle management, chat administration, and complex card-based interactions**.
**Key Capabilities**:
- Send all message types (text, image, audio, video, file, rich_text, card)
- Reply, forward, recall, update messages
- Edit sent text/rich_text/card messages with semantic helper methods
- Build and update in-place streaming cards for long-running or LLM-style responses
- Reactions, pins, read receipts, urgent notifications
- Chat management (create, delete, update, members, admins, announcements)
- File upload/download with message resource handling
- User and group information queries
- Batch messaging to users/departments
- **Recommended**: `send_markdown_message_to_chat` with auto-chunking and table fallback
**Companion Classes**:
- `TextContent`: Quick text formatting (@mentions, bold, italic, links)
- `PostContent`: Rich text builder with Markdown table handling
- `CardContentV2`: Schema 2.0 card builder
- `LarkBotListener`: Event listener for incoming messages (separate skill)
## Installation
```bash
pip install pywayne lark-oapi
```
## Quick Start
```python
from pywayne.lark_bot import LarkBot
# Initialize bot
bot = LarkBot(
app_id="cli_xxxxxxxxxxxx",
app_secret="your_app_secret"
)
# Send text to user
bot.send_text_to_user("ou_xxxxxxxx", "Hello from LarkBot!")
# Send text to chat group
bot.send_text_to_chat("oc_xxxxxxxx", "Hello, everyone!")
```
## LarkBot Class
### Constructor
```python
bot = LarkBot(
app_id: str, # Feishu application ID
app_secret: str # Feishu application secret
)
```
**Instance Attributes**:
- `client`: Underlying `lark.Client` for advanced usage
- All methods return `Dict` with API response data
## Helper Classes
### TextContent - Quick Text Formatting
Static helper for creating formatted text patterns used in text messages.
**Available Methods**:
```python
from pywayne.lark_bot import TextContent
# @mentions
at_all = TextContent.make_at_all_pattern()
at_user = TextContent.make_at_someone_pattern("ou_xxxx", "John", "open_id")
# Text styles
bold = TextContent.make_bold_pattern("Bold text")
italic = TextContent.make_italian_pattern("Italic text")
underline = TextContent.make_underline_pattern("Underlined text")
strikethrough = TextContent.make_delete_line_pattern("Strike text")
# Links
link = TextContent.make_url_pattern("https://example.com", "Click here")
```
**Example: Formatted Notification**:
```python
from pywayne.lark_bot import LarkBot, TextContent
bot = LarkBot(app_id="cli_xxx", app_secret="sec_xxx")
message = (
TextContent.make_at_someone_pattern("ou_xxxx", "Wayne", "open_id")
+ " "
+ TextContent.make_bold_pattern("Deployment completed")
+ " - "
+ TextContent.make_url_pattern("https://jenkins.example.com", "View build")
)
bot.send_text_to_chat("oc_xxxx", message)
```
### PostContent - Rich Text Post Builder
Builder for complex structured rich text messages supporting text, links, @mentions, images, code blocks, and Markdown content.
**Constructor**:
```python
from pywayne.lark_bot import PostContent
post = PostContent(title="Post Title")
```
**Content Creation Methods**:
```python
# Text with optional styles
text = post.make_text_content("Text", styles=["bold", "underline", "lineThrough", "italic"])
# Hyperlink
link = post.make_link_content("Display text", "https://example.com")
# @mention
at = post.make_at_content("ou_xxxx", styles=["bold"])
# Image
img = post.make_image_content("img_key")
# Media (video/audio with thumbnail)
media = post.make_media_content(file_key="file_xxx", image_key="thumb_xxx")
# Emoji (Feishu emoji codes like "OK", "THUMBSUP", "HEART")
emoji = post.make_emoji_content("THUMBSUP")
# Horizontal rule
hr = post.make_hr_content()
# Code block
code = post.make_code_block_content(language="python", text='print("hello")')
# Markdown
md = post.make_markdown_content("**Bold** and *italic*")
```
**Adding Content**:
```python
# Add to current line
post.add_content_in_line(content_dict)
post.add_contents_in_line([content1, content2]) # Multiple elements in same line
# Add to new line
post.add_content_in_new_line(content_dict)
post.add_contents_in_new_line([content1, content2])
```
**Recommended: Add Markdown Directly**:
```python
md_text = """
## Section Title
- Item 1
- Item 2
| Column A | Column B |
| -------- | -------- |
| Data 1 | Data 2 |
"""
# Auto-chunk and handle tables
post.add_markdown(
md_text,
table_as="code_block", # "code_block" or "md"
max_chunk_bytes=8000, # Max bytes per chunk
mono_max_col_width=40 # Max column width for code_block mode
)
# Send
bot.send_rich_text_to_chat("oc_xxx", post.get_content())
```
**Complete Example**:
```python
from pywayne.lark_bot import LarkBot, PostContent
bot = LarkBot(app_id="cli_xxx", app_secret="sec_xxx")
# Build post
post = PostContent(title="Release Report")
# Line 1: Title
post.add_content_in_new_line(
post.make_text_content("Version 1.2.0 Released", styles=["bold"])
)
# Line 2: @mention with emoji
post.add_contents_in_new_line([
post.make_at_content("ou_xxx"),
post.make_text_content(" "),
post.make_emoji_content("OK")
])
# Line 3: Link
post.add_content_in_new_line(
post.make_link_content("View release notes", "https://example.com/release/1.2.0")
)
# Line 4: Code block
post.add_content_in_new_line(
post.make_code_block_content("bash", "deploy.sh --env prod --version 1.2.0")
)
# Send
bot.send_rich_text_to_chat("oc_xxx", post.get_content())
```
### CardContentV2 - Schema 2.0 Interactive Card Builder
Lightweight builder for Feishu schema 2.0 cards, ideal for announcements, reports, and status updates with Markdown content.
**Constructor**:
```python
from pywayne.lark_bot import CardContentV2
card = CardContentV2(
title="Card Title", # Optional header title
template="blue" # Header color: "blue", "wathet", "turquoise", "green", "yellow", "orange", "red", "carmine", "violet", "purple", "indigo", "grey"
)
```
**Methods**:
```python
# Add Markdown content (auto-chunks by bytes)
card.add_markdown(md_text: str, *, max_chunk_bytes: int = 18_000)
# Add horizontal divider
card.add_hr()
# Add image
card.add_image(img_key: str, *, size: str = "large", preview: bool = True)
# List commonly used header templates
templates = CardContentV2.list_header_templates() # ["blue", "wathet", ...]
# Get complete card JSON
card_json = card.get_card()
```
**Common Header Templates**:
- `blue`
- `wathet`
- `turquoise`
- `green`
- `yellow`
- `orange`
- `red`
- `carmine`
- `violet`
- `purple`
- `indigo`
- `grey`
**Example: Daily Report Card**:
```python
from pywayne.lark_bot import LarkBot, CardContentV2
bot = LarkBot(app_id="cli_xxx", app_secret="sec_xxx")
# Build card
card = CardContentV2(title="Daily Report", template="blue")
card.add_markdown("""
# Today's Progress
- โ
API integration completed
- โ
Fixed 3 critical bugs
- ๐ Code review in progress
- ๐ Documentation updated
""")
card.add_hr()
card.add_markdown("**Next Steps**: Deploy to staging environment")
# Send
bot.send_card_to_chat("oc_xxx", card.get_card())
```
## Core Messaging Methods
### Recommended Entry Point: send_markdown_message_to_chat
**The preferred high-level method for sending Markdown content** with automatic chunking, table handling, and dual routing (card_v2/rich_text).
```python
responses = bot.send_markdown_message_to_chat(
chat_id: str,
md_text: str,
*,
title: str = "",
prefer: str = "card_v2", # "card_v2" or "post"
table_fallback: str = "code_block", # "code_block" or "md" (for post route)
max_message_bytes: Optional[int] = None
) -> List[Dict]
```
**Parameters**:
- `chat_id`: Target chat ID
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.