返回顶部
m

message-split

长消息自动拆分 skill。当回复内容超过渠道限制时,自动将消息拆分为多条有序发送,避免截断或丢消息。Auto-split long messages into smaller chunks before sending, with sequence markers.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
85
下载量
0
收藏
概述
安装方式
版本历史

message-split

# Message Split Skill ## Problem Many messaging channels (Feishu, Telegram, etc.) have a per-message character limit (~4000 chars for Feishu). When a response exceeds this limit, it either gets truncated or silently fails, leaving the user with no feedback. ## Solution Before sending any message, check its length and split if necessary. ## Usage ```python def send_long_message(text, channel="{active_channel}"): """ Send a message, splitting it into multiple chunks if it exceeds the length limit. Args: text: The message text to send channel: Target channel (feishu/telegram/discord/whatsapp/signal/imessage/openclaw-weixin) Returns: Number of chunks sent """ MAX_LEN = 3600 # Feishu limit with margin CHUNK_HEADER = "[{i}/{total}]\n" if len(text) <= MAX_LEN: message(action="send", channel=channel, message=text) return 1 chunks = split_text(text, MAX_LEN) total = len(chunks) for i, chunk in enumerate(chunks, 1): header = f"[{i}/{total}]\n" if total > 1 else "" message(action="send", channel=channel, message=header + chunk) return total def split_text(text, max_len): """ Split text into chunks of at most max_len characters. Attempts to split at sentence boundaries or line breaks for readability. """ import re # Try to split at sentence-ending punctuation first sentence_split = re.split(r'(?<=[。!?.!?])\s+', text) chunks = [] current = "" for sentence in sentence_split: if len(current) + len(sentence) + 1 <= max_len: current += (" " + sentence if current else sentence) else: if current: chunks.append(current) # If single sentence exceeds limit, split by words/characters if len(sentence) > max_len: for i in range(0, len(sentence), max_len - 100): chunks.append(sentence[i:i + max_len - 100]) current = "" else: current = sentence if current: chunks.append(current) return chunks ``` ## Channel Limits Reference | Channel | Max chars (approx) | Notes | |---------|-------------------|-------| | Feishu | 4000 | Hard limit | | Telegram | 4096 | | | Discord | 2000 | Embed limit 6000 | | WhatsApp | 65000 | But relayed messages get truncated | | Signal | 700 | Very low | | iMessage | ~4000 | Via macOS relay | ## Notes - Always use `MAX_LEN = 3600` as a safe default (leaves room for header) - If channel is unknown, default to feishu behavior - Splitting is done on word/sentence boundaries when possible to preserve readability - Sequence headers `[{i}/{total}]` are only added when `total > 1`

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 message-split-1776027040 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 message-split-1776027040 技能

通过命令行安装

skillhub install message-split-1776027040

下载 Zip 包

⬇ 下载 message-split v1.0.0

文件大小: 2.05 KB | 发布时间: 2026-4-13 11:01

v1.0.0 最新 2026-4-13 11:01
Auto-split long messages to avoid Feishu/Telegram truncation. Splits on sentence boundaries with sequence markers.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部