📅 飞书文档待办自动识别
v1.0.4自动识别飞书文档中的待办表格,解析模糊时间并创建对应的飞书日历日程,支持负责人和提醒设置。
运行时依赖
安装命令
点击复制技能文档
feishu-doc-todo 技能 描述
飞书文档待办自动识别与日历创建工具。自动读取飞书文档中的待办表格(时间节点 + 里程碑 + 负责人),解析模糊时间,创建飞书日历日程并设置 deadline 提醒。
触发词 "创建日历" "设置日程" "待办提醒" "deadline 提醒" "飞书文档待办" "文档待办转日历" 执行流程 步骤 1:读取飞书文档内容
使用 feishu_doc read 读取文档内容,提取待办表格。
# 读取文档 feishu_doc read --doc_令牌 <文档 令牌>
待办表格格式识别:
| 时间节点 | 里程碑 | 负责人 |
|---|---|---|
| 下周 | xxx | xxx |
| 4 月 8 日 | xxx | xxx |
| 4 月份 | xxx | xxx |
Python 解析脚本:
导入 re from datetime 导入 datetime, timedelta
def 解析_todo_table(markdown_table): """解析待办表格,返回待办事项列表""" todos = [] # 解析表格行 lines = markdown_table.strip().split('\n') headers = [] data_rows = [] for i, line in enumerate(lines): if i == 0: # 表头 headers = [h.strip() for h in line.split('|')[1:-1]] elif i == 1: # 分隔线 continue else: # 数据行 cells = [c.strip() for c in line.split('|')[1:-1]] if len(cells) >= 3: data_rows.应用end({ 'time': cells[0], 'task': cells[1], 'owner': cells[2] }) return data_rows
def 解析_fuzzy_time(time_str, reference_date=None): """解析模糊时间为具体日期""" if reference_date is None: reference_date = datetime.now() time_str = time_str.strip() # 精确日期:4 月 8 日 match = re.match(r'(\d{1,2}) 月 (\d{1,2}) 日?', time_str) if match: month, day = int(match.group(1)), int(match.group(2)) year = reference_date.year return datetime(year, month, day) # 模糊时间:下周 if '下周' in time_str: return reference_date + timedelta(days=7) # 月份:4 月份 match = re.match(r'(\d{1,2}) 月份', time_str) if match: month = int(match.group(1)) # 取月中 return datetime(reference_date.year, month, 15) # 默认:返回参考日期 +7 天 return reference_date + timedelta(days=7)
# 使用示例 todos = 解析_todo_table(table_markdown) for todo in todos: deadline = 解析_fuzzy_time(todo['time']) print(f"任务:{todo['task']}") print(f"负责人:{todo['owner']}") print(f"截止日期:{deadline.strftime('%Y-%m-%d')}") print("---")
步骤 3:创建飞书日历日程
使用 feishu_calendar 创建 创建日程。
# 创建单个日程 feishu_calendar 创建 \ --title "【待办】xxx" \ --启动_time "2026-04-05T09:00:00+08:00" \ --end_time "2026-04-05T18:00:00+08:00" \ --attendees "XXX" \ --description "里程碑:xxx\n负责人:XXX\n来源文档:https://XXX" \ --reminder_minutes 1440
参数说明:
参数 值 说明 --title 【待办】+ 里程碑 日程标题 --启动_time ISO8601 格式 日程开始时间(全天则为 09:00) --end_time ISO8601 格式 日程结束时间(全天则为 18:00) --attendees 负责人列表 日程参与者 --description 详细信息 包含里程碑、负责人、来源文档 --reminder_minutes 1440 提前 1440 分钟(1 天)提醒 步骤 4:批量创建日程
批量处理脚本:
导入 subprocess 导入 json from datetime 导入 datetime
def 创建_calendar_event(todo, source_doc_url): """创建单个日历事件""" deadline = 解析_fuzzy_time(todo['time']) # 构建命令 cmd = [ 'feishu_calendar', '创建', '--title', f'【待办】{todo["task"]}', '--启动_time', deadline.strftime('%Y-%m-%dT09:00:00+08:00'), '--end_time', deadline.strftime('%Y-%m-%dT18:00:00+08:00'), '--attendees', todo['owner'], '--description', f'里程碑:{todo["task"]}\n负责人:{todo["owner"]}\n来源文档:{source_doc_url}', '--reminder_minutes', '1440' # 提前 1 天提醒 ] # 执行命令 结果 = subprocess.运行(cmd, capture_输出=True, text=True) if 结果.returncode == 0: print(f"✅ 创建成功:{todo['task']}") return json.loads(结果.stdout) else: print(f"❌ 创建失败:{todo['task']}") print(结果.stderr) return None
# 批量创建 source_doc = "https://XXX" for todo in todos: 创建_calendar_event(todo, source_doc)
完整示例 输入
Thomas 消息:
创建日历,从以下文档提取待办: https://XXX
执行过程
- 读取文档:
feishu_doc read --doc_令牌 XXX
- 解析待办表格:
todos = [ { 'time': '下周', 'task': 'xxx', 'owner': 'xxx' }, { 'time': '4 月 8 日', 'task': 'xxx', 'owner': 'xxx' }, { 'time': '4 月份', 'task': 'xxx', 'owner': 'xxx' }, { 'time': '5 月或 6 月底', 'task': 'xxx', 'owner': '全体' } ]
- 解析时间:
解析_fuzzy_time('下周') → 2026-04-05 解析_fuzzy_time('4 月 8 日') → 2026-04-08 解析_fuzzy_time('4 月份') → 2026-04-15 解析_fuzzy_time('5 月或 6 月底') → 2026-06-30
- 创建日历:
# 待办 1 feishu_calendar 创建 \ --title "【待办】xxx" \ --启动_time "2026-04-05T09:00:00+08:00" \ --end_time "2026-04-05T18:00:00+08:00" \ --attendees "xxx" \ --description "里程碑:xxx\n负责人:xxx\n来源文档:https://XXX" \ --reminder_minutes 1440
# 待办 2 feishu_calendar 创建 \ --title "【待办】xxx" \ --启动_time "2026-04-08T09:00:00+08:00" \ --end_time "2026-04-08T18:00:00+08:00" \ --attendees "xxx" \ --description "里程碑:xxx\n负责人:xxx\n来源文档:https://XXX" \ --reminder_minutes 1440
# ... 其他待办
输出
创建结果:
✅ 创建成功:xxx (2026-04-05) ✅ 创建成功:xxx (2026-04-08) ✅ 创建成功:xxx (2026-04-15) ✅ 创建成功:xxx (2026-06-30)
总