{"id":50368415,"url":"https://github.com/weaming/tg-bot-cli","last_synced_at":"2026-05-30T05:30:31.599Z","repository":{"id":349264794,"uuid":"1201410945","full_name":"weaming/tg-bot-cli","owner":"weaming","description":null,"archived":false,"fork":false,"pushed_at":"2026-04-12T17:21:29.000Z","size":45,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-12T19:14:11.832Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weaming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2026-04-04T16:35:44.000Z","updated_at":"2026-04-12T17:21:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/weaming/tg-bot-cli","commit_stats":null,"previous_names":["weaming/tg-bot-cli"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weaming/tg-bot-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Ftg-bot-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Ftg-bot-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Ftg-bot-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Ftg-bot-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weaming","download_url":"https://codeload.github.com/weaming/tg-bot-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weaming%2Ftg-bot-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33681809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-30T02:00:06.278Z","response_time":92,"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-05-30T05:30:30.354Z","updated_at":"2026-05-30T05:30:31.583Z","avatar_url":"https://github.com/weaming.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tg-bot-cli\n\nTelegram Bot API 命令行工具。\n\n## 安装\n\n需要 Go 1.25+，并确保 `$(go env GOPATH)/bin` 在 PATH 中。\n\n```bash\n# 锁定 token 安装到 GOPATH/bin\nmake install-tg TOKEN=123:AAA... BINARY=tg\n\n# 锁定 token + 目标 chat\nmake install-tg TOKEN=123:AAA... TARGET=@mychannel BINARY=tg-chan\n\n# 多 bot / 多目标场景\nmake install-tg TOKEN=123:AAA... TARGET=-100123456 BINARY=tg-work\nmake install-tg TOKEN=456:BBB... TARGET=@personal  BINARY=tg-personal\n\n# 单独的程序转换 std markdown -\u003e tg HTML\nmake install-md2tg\n```\n\n参考 [md2tg readme](cmd/md2tg/README.md)\n\n## 优先级\n\nToken：`--token` / `-T` \u003e `TG_BOT_TOKEN` \u003e 编译内置\n\nTarget：`--to` / `--chat` \u003e `TG_TARGET` \u003e 编译内置\n\nProxy：`--proxy` / `-x` \u003e `TG_PROXY` \u003e `HTTPS_PROXY` / `HTTP_PROXY`\n\n## 命令\n\n```bash\ntg config                                        # 查看当前配置来源\ntg send   -t \u003cchat\u003e  -m \"内容\"                  # 发文本\ntg send   -t \u003cchat\u003e  -i \u003cfile\u003e                  # 从文件读取\ntg send   -t \u003cchat\u003e  -i - --md2html            # 从 stdin 读取并转 HTML\ntg send   -t \u003cchat\u003e  -f ./photo.jpg -c \"说明\"  # 发媒体文件\ntg edit   -c \u003cchat\u003e -m \u003cid\u003e -t \"新内容\"\ntg delete -c \u003cchat\u003e -m \u003cid\u003e\ntg forward -f \u003cfrom\u003e -t \u003cto\u003e -m \u003cid\u003e\ntg copy    -f \u003cfrom\u003e -t \u003cto\u003e -m \u003cid\u003e\ntg pin     -c \u003cchat\u003e -m \u003cid\u003e\ntg unpin   -c \u003cchat\u003e [-m \u003cid\u003e]\ntg info    -c \u003cchat\u003e\ntg me\n```\n\n## 常用选项\n\n| 选项           | 简写 | 说明                                                |\n| -------------- | ---- | --------------------------------------------------- |\n| `--to`         | `-t` | 目标 chat，username 可省略 `@`                      |\n| `--chat`       | `-c` | 目标 chat（edit/delete/pin/info）                   |\n| `--text`       | `-m` | 消息文本                                            |\n| `--input-file` | `-i` | 从文件或 stdin（-）读取                             |\n| `--md2html`    | —    | 将 markdown 转换为 HTML                             |\n| `--file`       | `-f` | 文件路径（自动识别类型）                            |\n| `--caption`    | `-c` | 文件说明                                            |\n| `--msg`        | `-m` | 消息 ID                                             |\n| `--from`       | `-f` | 来源 chat（forward/copy）                           |\n| `--reply-to`   | `-r` | 回复的消息 ID                                       |\n| `--silent`     | `-s` | 静默发送                                            |\n| `--protect`    | `-p` | 防止转发/保存                                       |\n| `--thread`     | —    | 话题群 message_thread_id                            |\n| `--button`     | `-b` | Inline 按钮（多次使用 = 多行，`,` 同行，`\\|` 换行） |\n| `--parse-mode` | —    | 默认不传（纯文本）；可选 HTML \\| MarkdownV2         |\n| `--json`       | `-j` | 输出完整 JSON 响应                                  |\n\n## 示例\n\n```bash\n# 发送 HTML 消息\ntg send -t mychannel -m \"\u003cb\u003e加粗\u003c/b\u003e 内容\" --parse-mode HTML\n\n# 发送 MarkdownV2 消息\ntg send -t mychannel -m \"这是 *粗体* 和 _斜体_\" --parse-mode MarkdownV2\n\n# 从文件读取并自动转 HTML（.md 文件）\ntg send -t mychannel -i ./readme.md\n\n# 从 stdin 读取并转 HTML\ncat readme.md | tg send -t mychannel -i - --md2html\n\n# 带按钮\ntg send -t mychannel -m \"点击\" \\\n  -b \"官网:https://example.com,文档:https://docs.example.com\" \\\n  -b \"GitHub:https://github.com\"\n\n# 发图片\ntg send -t 123456789 -f ./image.png -c \"说明\"\n\n# 从管道发送\necho \"定时任务完成\" | tg send -t alerts -i -\n\n# 获取 JSON 格式结果\ntg info -c mychannel -j\n\n# 检查编译内置情况\ntg config\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Ftg-bot-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweaming%2Ftg-bot-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweaming%2Ftg-bot-cli/lists"}