{"id":36495080,"url":"https://github.com/crazykun/feishu-bot-markdown","last_synced_at":"2026-01-12T02:00:38.243Z","repository":{"id":225939666,"uuid":"767297684","full_name":"crazykun/feishu-bot-markdown","owner":"crazykun","description":"飞书markdown消息模板 go-feishu-bot-markdown","archived":false,"fork":false,"pushed_at":"2025-11-25T01:56:39.000Z","size":162,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T23:02:43.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crazykun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-05T03:16:40.000Z","updated_at":"2025-11-25T01:54:16.000Z","dependencies_parsed_at":"2024-03-05T04:29:19.607Z","dependency_job_id":"1b8fe9af-176e-45c8-8e03-4bbd2fa71c46","html_url":"https://github.com/crazykun/feishu-bot-markdown","commit_stats":null,"previous_names":["crazykun/feishu-bot-markdown"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/crazykun/feishu-bot-markdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazykun%2Ffeishu-bot-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazykun%2Ffeishu-bot-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazykun%2Ffeishu-bot-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazykun%2Ffeishu-bot-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crazykun","download_url":"https://codeload.github.com/crazykun/feishu-bot-markdown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crazykun%2Ffeishu-bot-markdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28331505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-12T02:00:15.661Z","updated_at":"2026-01-12T02:00:38.237Z","avatar_url":"https://github.com/crazykun.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go飞书机器人Markdown消息工具\n\n## 项目简介\n\n一个基于Go语言封装的飞书群机器人消息发送工具，支持Markdown格式消息的快速构建与发送，提供简洁的API和丰富的消息格式支持。\n\n---\n\n## 安装\n\n```bash\ngo get github.com/crazykun/feishu-bot-markdown\n```\n\n---\n\n## 快速开始\n\n### 1. 配置机器人Hook地址\n\n```go\nimport (\n\tbot \"github.com/crazykun/feishu-bot-markdown\"\n)\n\nvar Hook = \"https://open.feishu.cn/open-apis/bot/v2/hook/xxxx-xxxx-xxxx-xxxx\"\n```\n\n### 2. 构建消息模板\n\n#### 方式一：使用 Map（传统方式）\n```go\nmsg := \u0026bot.FeishuMsg{\n\tTitle: \"任务完成通知\",\n\tMarkdown: map[string]any{\n\t\t\"状态\": \"\u003cfont color='green'\u003e成功\u003c/font\u003e\",\n\t\t\"进度\": \"已完成 100%\",\n\t\t\"日志\": \"```日志内容```\",\n\t},\n\tNote: \"点击查看详细日志\",\n\tNoteEmoji: true,\n\tLink: \"http://example.com/logs\",\n}\n```\n\n#### 方式二：使用 MarkdownItems（灵活，保持顺序）\n```go\nmsg := \u0026bot.FeishuMsg{\n\tTitle: \"任务完成通知\",\n\tMarkdownItems: []bot.Text{\n\t\t{Tag: \"状态\", Content: \"\u003cfont color='green'\u003e成功\u003c/font\u003e\"},\n\t\t{Tag: \"进度\", Content: \"已完成 100%\"},\n\t\t{Tag: \"日志\", Content: \"```日志内容```\"},\n\t},\n\tNote: \"点击查看详细日志\",\n\tNoteEmoji: true,\n\tLink: \"http://example.com/logs\",\n}\n```\n\n#### 方式三：使用 MarkdownArray（推荐，最简洁）\n```go\nmsg := \u0026bot.FeishuMsg{\n\tTitle: \"任务完成通知\",\n\tMarkdownArray: [][2]string{\n\t\t{\"状态\", \"\u003cfont color='green'\u003e成功\u003c/font\u003e\"},\n\t\t{\"进度\", \"已完成 100%\"},\n\t\t{\"日志\", \"```日志内容```\"},\n\t},\n\tNote: \"点击查看详细日志\",\n\tNoteEmoji: true,\n\tLink: \"http://example.com/logs\",\n}\n```\n\n### 3. 发送消息\n\n```go\nbot.SendFeishuMsg(Hook, msg)\n```\n\n---\n\n## 核心功能\n\n- [x] 支持完整Markdown语法子集\n- [x] 自定义消息卡片样式\n- [x] 颜色配置（支持绿色/红色/灰色等）\n- [x] 超链接与@用户功能\n- [x] 代码块与列表渲染\n- [x] 支持Note备注和随机Emoji\n- [x] **新增**：MarkdownItems 切片支持，解决 map 转 JSON 无序问题\n- [x] **新增**：MarkdownArray 键值对数组支持，提供最简洁的使用方式\n- [x] **新增**：智能优先级机制，支持多种内容格式自动选择\n\n---\n\n## 使用示例\n\n![消息展示效果](https://raw.githubusercontent.com/crazykun/feishu-bot-markdown/main/src/screenshot.jpg)\n\u003e 图1：消息发送效果示例（包含标题、内容、状态提示和操作链接）\n\n---\n\n## Markdown语法支持\n\n| 功能        | 语法示例                          | 展示效果                     | 说明                     |\n|-------------|----------------------------------|----------------------------|-------------------------|\n| 斜体        | *斜体文字*                       | *斜体文字*                  | 使用星号包裹            |\n| 颜色        | \u003cfont color='green'\u003e成功\u003c/font\u003e  | \u003cfont color='green'\u003e成功\u003c/font\u003e | 支持green/red/grey      |\n| 链接        | [飞书官网](https://feishu.cn)    | [飞书官网](https://feishu.cn) | 需要完整URL             |\n| 代码块      | ```go\\nfmt.Println(\"Hello\")\\n``` | ```go\\nfmt.Println(\"Hello\")\\n``` | 支持语言高亮            |\n\n---\n\n## 高级用法\n\n### 自定义卡片样式\n\n```go\n// 设置卡片头部颜色\nmsg.HeaderColor = bot.ColorWathet // 蓝色主题\nmsg.HeaderColor = bot.ColorGreen  // 绿色主题\nmsg.HeaderColor = bot.ColorRed    // 红色主题\nmsg.HeaderColor = bot.ColorGrey    // 灰色主题\nmsg.HeaderColor = bot.ColorDefault // 默认主题\n```\n\n### @指定用户\n\n```go\nmsg.Markdown[\"负责人\"] = `\u003cat id=user_123\u003e张三\u003c/at\u003e`\n```\n\n### 解决 JSON 序列化顺序问题\n\n提供三种解决方案来保证内容顺序：\n\n```go\n// 问题：map 在 JSON 序列化时顺序不固定\nmsg := \u0026bot.FeishuMsg{\n\tMarkdown: map[string]any{\n\t\t\"第三步\": \"完成\",\n\t\t\"第一步\": \"开始\", \n\t\t\"第二步\": \"进行中\",\n\t},\n}\n\n// 解决方案1：使用 MarkdownItems（灵活）\nmsg := \u0026bot.FeishuMsg{\n\tMarkdownItems: []bot.Text{\n\t\t{Tag: \"第一步\", Content: \"开始\"},\n\t\t{Tag: \"第二步\", Content: \"进行中\"},\n\t\t{Tag: \"第三步\", Content: \"完成\"},\n\t},\n}\n\n// 解决方案2：使用 MarkdownArray（最简洁，推荐）\nmsg := \u0026bot.FeishuMsg{\n\tMarkdownArray: [][2]string{\n\t\t{\"第一步\", \"开始\"},\n\t\t{\"第二步\", \"进行中\"},\n\t\t{\"第三步\", \"完成\"},\n\t},\n}\n```\n\n### 智能优先级机制\n\n系统按以下优先级自动选择内容格式：**Markdown** \u003e **MarkdownItems** \u003e **MarkdownArray**\n\n```go\nmsg := \u0026bot.FeishuMsg{\n\tTitle: \"智能选择示例\",\n\tMarkdown: map[string]any{}, // 空的 map\n\tMarkdownItems: []bot.Text{}, // 空的切片\n\tMarkdownArray: [][2]string{\n\t\t{\"自动使用\", \"MarkdownArray 内容\"},\n\t},\n}\n// 系统会自动使用 MarkdownArray 的内容\n```\n\n### 使用场景推荐\n\n- **MarkdownArray**: 简单键值对场景（推荐）\n- **MarkdownItems**: 需要混合键值对和纯内容的复杂场景\n- **Markdown**: 兼容现有代码，但顺序不固定\n\n---\n\n## 文档与资源\n\n- [飞书机器人官方文档](https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot)\n- [卡片搭建指南](https://open.feishu.cn/cardkit)\n- [Markdown语法说明](https://open.feishu.cn/document/uAjLw4CM/ukzMukzMukzM/feishu-cards/card-components/content-components/rich-text)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazykun%2Ffeishu-bot-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrazykun%2Ffeishu-bot-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrazykun%2Ffeishu-bot-markdown/lists"}