{"id":13816078,"url":"https://github.com/node-webot/webot-cli","last_synced_at":"2025-06-21T18:07:50.697Z","repository":{"id":7964122,"uuid":"9362863","full_name":"node-webot/webot-cli","owner":"node-webot","description":"command line interface for weixin-robot","archived":false,"fork":false,"pushed_at":"2016-10-21T10:38:56.000Z","size":37,"stargazers_count":96,"open_issues_count":1,"forks_count":26,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-19T00:16:45.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/node-webot.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}},"created_at":"2013-04-11T05:25:57.000Z","updated_at":"2025-05-09T05:33:29.000Z","dependencies_parsed_at":"2022-09-25T05:40:30.420Z","dependency_job_id":null,"html_url":"https://github.com/node-webot/webot-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/node-webot/webot-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fwebot-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fwebot-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fwebot-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fwebot-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-webot","download_url":"https://codeload.github.com/node-webot/webot-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-webot%2Fwebot-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260759598,"owners_count":23058449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-04T05:00:33.197Z","updated_at":"2025-06-21T18:07:45.683Z","avatar_url":"https://github.com/node-webot.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webot-cli\n\nCommand line interface for [weixin-robot](https://github.com/node-webot/weixin-robot).\n\n    npm install webot-cli -g\n\n## Commands\n\n```man\n  Usage: webot \u003ccommand\u003e [options]\n\n  Options:\n\n    -h, --help     output usage information\n    -V, --version  output the version number\n\n  Commands:\n\n    send [image|text|loc|..]   send a message to test host\n    menu [create|delete|get]   manipulate wechat menu\n    help [command]             view help info for specified command\n```\n\nUse `webot help` for more details.\n\n## 发送测试消息\n\n```man\n  Usage: webot send [type] [options] [message]\n\n  Types:\n\n    # t, text            Send text messages (default)\n    # i, image, pic      Send image messages\n    # l, loc, location   Send location messages\n    # e, event           Send event messages\n    # scan               Send scan QRcode event\n    # reportloc          Send report location event\n\n  Options:\n\n    --token          API token for wechat, defaults to `process.env.WX_TOKEN`\n    --port           The port your service is listening at, defaults to `process.env.PORT`\n    --host           Server hostname, defaults to 127.0.0.1\n    --route          The subdirectory you are watching\n    --des            Request destination, a full url\n                     Will override host, port and route\n    --user           FromUserName of this message.\n\n  Examples:\n\n    webot send --token abc123 --des http://example.com/webot\n    webot send t Hello\n    webot send loc 20.12 120.33 \"Somewhere Out There\"\n```\n\n### 在代码里使用\n\n```javascript\nvar send = require('webot-cli').commands.send\nvar options = {\n  silent: true,\n  port: PORT,\n  route: media.webotPath(),\n  token: media.wx_token,\n  input: ['text', 'abcotea']\n}\n\nsend(options, data)\n```\n\n## 微信自定义菜单\n\n    webot help menu\n\n需要一个 json 文件保存 access_token 等配置信息（默认是当前目录的 **wx_config.json**）。\n为安全起见，建议你只在本地使用此文件，不要把它放到代码仓库中。\n\n```javascript\n{\n  \"appid\": \"abcedfe123456\",\n  \"secret\": \"abcdefghijklmn1234567890\"\n}\n```\n\n### 创建或修改\n\n按照微信文档中的[请求示例][1]，新建一个 json 文件（如`menu.json`），然后利用 stdin 传入 `webot menu create` 命令：\n\n文件 **menu.json** 的内容：\n\n```javascript\n {\n     \"button\":[\n     {  \n          \"type\":\"click\",\n          \"name\":\"今日歌曲\",\n          \"key\":\"V1001_TODAY_MUSIC\"\n      },\n      {\n           \"type\":\"click\",\n           \"name\":\"歌手简介\",\n           \"key\":\"V1001_TODAY_SINGER\"\n      },\n      {\n           \"name\":\"菜单\",\n           \"sub_button\":[\n            {\n               \"type\":\"click\",\n               \"name\":\"hello word\",\n               \"key\":\"V1001_HELLO_WORLD\"\n            },\n            {\n               \"type\":\"click\",\n               \"name\":\"赞一下我们\",\n               \"key\":\"V1001_GOOD\"\n            }]\n       }]\n }\n```\n\n执行命令：\n\n    webot menu create --config wx_config.json \u003c menu.json\n\n### 自定义菜单与 webot 的结合\n\n发送文字消息或者触发点击事件都可以：\n\n```\nvar reg_gequ = /(今日歌曲|today music)/i;\n\nwebot.set('today_music', {\n  pattern: function(info) {\n    return reg_gequ.test(info.text) || info.param.eventKey === 'V1001_TODAY_MUSIC';\n  },\n  handler: function(info, cb) {\n    // 从你的数据库里查找今日歌曲\n    cb(null, {\n      type: 'music',\n      musicUrl: 'http://xxxx...',\n      hqMusicUrl: 'http://xxxx...'\n    });\n  },\n});\n```\n\n## LICENCE\n\n(the MIT licence)\n\n[1]:http://mp.weixin.qq.com/wiki/index.php?title=%E8%87%AA%E5%AE%9A%E4%B9%89%E8%8F%9C%E5%8D%95%E6%8E%A5%E5%8F%A3#.E8.8F.9C.E5.8D.95.E5.88.9B.E5.BB.BA)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-webot%2Fwebot-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-webot%2Fwebot-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-webot%2Fwebot-cli/lists"}