{"id":13601067,"url":"https://github.com/songtianyi/wechat-go","last_synced_at":"2026-01-16T22:51:09.133Z","repository":{"id":41002206,"uuid":"79701262","full_name":"songtianyi/wechat-go","owner":"songtianyi","description":"go version wechat web api and message framework for building wechat robot","archived":false,"fork":false,"pushed_at":"2022-07-13T18:41:22.000Z","size":309,"stargazers_count":1860,"open_issues_count":36,"forks_count":344,"subscribers_count":87,"default_branch":"master","last_synced_at":"2025-08-13T18:37:17.559Z","etag":null,"topics":["api","bot","framework","golang","robot","web","wechat"],"latest_commit_sha":null,"homepage":"","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/songtianyi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://songtianyi.info/pages/life/sponsors.html"]}},"created_at":"2017-01-22T07:21:11.000Z","updated_at":"2025-08-04T07:26:03.000Z","dependencies_parsed_at":"2022-07-12T21:01:22.590Z","dependency_job_id":null,"html_url":"https://github.com/songtianyi/wechat-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/songtianyi/wechat-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songtianyi%2Fwechat-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songtianyi%2Fwechat-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songtianyi%2Fwechat-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songtianyi%2Fwechat-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/songtianyi","download_url":"https://codeload.github.com/songtianyi/wechat-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songtianyi%2Fwechat-go/sbom","scorecard":{"id":837930,"data":{"date":"2025-08-11","repo":{"name":"github.com/songtianyi/wechat-go","commit":"67e759036893ecf31dcc3f7f3e30ab3282ca4203"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Code-Review","score":2,"reason":"Found 7/24 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"17 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0197 / GHSA-4r78-hx75-jjj2 / GHSA-mv93-wvcp-7m7r","Warn: Project is vulnerable to: GO-2020-0014 / GHSA-vfw5-hrgq-h5wf","Warn: Project is vulnerable to: GO-2022-0536 / GHSA-39qc-96h7-956f / GHSA-hgr8-6h9x-f7q9","Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T19:40:44.872Z","repository_id":41002206,"created_at":"2025-08-23T19:40:44.872Z","updated_at":"2025-08-23T19:40:44.872Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28486568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T22:47:06.728Z","status":"ssl_error","status_checked_at":"2026-01-16T22:46:52.401Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","bot","framework","golang","robot","web","wechat"],"created_at":"2024-08-01T18:00:54.638Z","updated_at":"2026-01-16T22:51:09.100Z","avatar_url":"https://github.com/songtianyi.png","language":"Go","funding_links":["https://songtianyi.info/pages/life/sponsors.html"],"categories":["Misc","开源类库","Go","Open source library"],"sub_categories":["微信","WeChat"],"readme":"# wechat-go\n\n[![Build Status](https://travis-ci.org/songtianyi/wechat-go.svg?branch=master)](https://travis-ci.org/songtianyi/wechat-go)\n[![Join the chat at https://gitter.im/wechat-go/Lobby](https://badges.gitter.im/wechat-go/Lobby.svg)](https://gitter.im/wechat-go/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![Go Report Card](https://goreportcard.com/badge/github.com/songtianyi/wechat-go)](https://goreportcard.com/report/github.com/songtianyi/wechat-go)\n[![codebeat badge](https://codebeat.co/badges/4f78bcb2-bf75-477d-a8f4-b09fde3dae80)](https://codebeat.co/projects/github-com-songtianyi-wechat-go-master)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()\n\n### 使用前阅读：\n  - #### 17年6月下旬前登陆过web网页版的微信可以使用此框架，验证微信是否支持web版本API，请点击https://wx.qq.com/ ，扫码验证即可，假如出现无法登陆，则不适用于此框架\n\n### 介绍 \n 微信web版API的go实现，模拟微信网页版的登录／联系人／消息收发等功能，可以完全接管微信收到的消息, 并定制自己的发送内容\n\n* 支持多用户(多开)\n* 支持掉线后免扫码重登\n* 功能以插件的形式提供，可以根据用户(比如付费情况）选择加载或者不加载某插件\n* 插件编写简单, 可定制性强, 无需关心API和消息分发，二次开发极为方便\n* 对于加载的插件, 使用机器人的终端用户可以通过微信聊天界面动态开启/关闭.\n* 目前已提供头像(性别／年龄)识别, gif搜索, 笑话大全, \"阅后即焚\", 消息跨群转发, 中英互译等多个有趣插件\n* 可以发送图片/文字/gif/视频/表情等多种消息\n* 支持Linux/MacOSX/Windows, 树莓派也可以:)\n\n\n## 获取源码\n\tmkdir -p $GOPATH/src/golang.org/x\n\tcd $GOPATH/src/golang.org/x\n\tgit clone https://github.com/golang/net.git\n\n\tgo get -u -v github.com/songtianyi/wechat-go\n\tcd $GOPATH/src/github.com/songtianyi/wechat-go\n\tgo get ./...\n\n## 编译并运行\n#### linux/mac\n```\ngo build examples/linux/terminal_bot.go\n./terminal_bot\n```\n#### windows\nwindows版本需要在非windows系统使用交叉编译来生成, 生成之后在windows下运行\n```\nGOOS=windows GOARCH=amd64 go build examples/windows/windows_bot.go\n./windows_bot.exe\n扫码图片需要用软件打开，路径在输出日志内.\n```\n\n## 示例项目\n[go-aida](https://www.github.com/songtianyi/go-aida)\n\n#### 区别\n* go-aida是拥有扫码页面的功能性机器人\n* wechat-go实现了微信的API, 并提供了易用的消息框架, 但并不是可运行程序\n* 只需少量代码即可基于wechat-go创建一个属于自己的个性化机器人，对于更复杂的需求(扫码页面等)可以使用go-aida\n* wechat-go专注在API的稳定性/框架的易用性/通用插件这三方面\n* go-aida专注在机器人的个性化定制上\n\n## 示例代码\n##### 基于wechat-go创建自定义的机器人\n```go\npackage main\n\nimport (\n\t\"github.com/songtianyi/rrframework/logs\"\n\t\"github.com/songtianyi/wechat-go/plugins/wxweb/faceplusplus\"\n\t\"github.com/songtianyi/wechat-go/plugins/wxweb/gifer\"\n\t\"github.com/songtianyi/wechat-go/plugins/wxweb/replier\"\n\t\"github.com/songtianyi/wechat-go/plugins/wxweb/switcher\"\n\t\"github.com/songtianyi/wechat-go/wxweb\"\n)\n\nfunc main() {\n\t// 创建session, 一个session对应一个机器人\n\t// 二维码显示在终端上\n\tsession, err := wxweb.CreateSession(nil, nil, wxweb.TERMINAL_MODE)\n\tif err != nil {\n\t\tlogs.Error(err)\n\t\treturn\n\t}\n\n\t// 注册插件, 所有插件默认是开启的\n\tfaceplusplus.Register(session)\n\treplier.Register(session)\n\tswitcher.Register(session)\n\tgifer.Register(session)\n\n\t// 你也可以自己选择关闭插件里的handler(消息处理器)\n\tsession.HandlerRegister.DisableByName(\"faceplusplus\")\n\n\t// 登录并接收消息\n\tif err := session.LoginAndServe(false); err != nil {\n\t\tlogs.Error(\"session exit, %s\", err)\n\t}\n}\n```\n## 插件列表\n###### switcher\n一个管理插件的插件\n```\n#关闭某个插件, 在微信聊天窗口输入\ndisable faceplusplus\n#开启某个插件, 在微信聊天窗口输入\nenable faceplusplus\n#查看所有插件信息, 在微信聊天窗口输入\ndump\n```\n###### faceplusplus\n对收到的图片做面部识别，返回性别和年龄\n###### gifer\n以收到的文字消息为关键字做gif搜索，返回gif图, 注意返回的gif可能尺度较大，比如文字消息中包含“污”等关键词。\n###### replier\n对收到的文字/图片消息，做自动应答，回复固定文字消息\n###### laosj\n随机获取一张美女图片, 在聊天窗口输入\n```\n美女\n```\n###### joker\n获取一则笑话, 在聊天窗口输入\n```\n笑话\n```\n###### revoker\n消息撤回插件, 3s后自动撤回手机端所发的文本消息. 机器人发出的消息需要自己在对应插件里写撤回逻辑.\n\n###### system\n处理消息撤回/红包等系统提示\n\n###### forwarder\n消息跨群转发, 在插件里修改群名的全拼即可.\n\n###### youdao\n中英互译插件, 基于有道翻译API\n\n###### verify\n自动接受好友请求, 可以按条件过滤\n\n###### share\n资源(纸牌屋)自动分发示例\n\n###### config\n配置管理插件\n设置配置, 在聊天窗口输入\n```\nset config key value\n```\n查看配置，在聊天窗口输入\n```\nget config key\n```\n在代码中使用配置\n```go\nimport \"github.com/songtianyi/wechat-go/kv\"\nfunc demo() {\n\tkv.KVStorageInstance.Set(\"key\", \"value\")\n\tv := kv.KVStorageInstance.Get(\"key\")\n\tif v == nil {\n\t\treturn\n\t}\n\t// v.(string) etc.\n}\n```\n\n## 制作自己的插件\n自定义插件的两个原则\n* 一个插件只完成一个功能，不在一个插件里加入多个handler\n* 插件默认开启\n\n插件示例\n```go\npackage demo // 以插件名命令包名\n\nimport (\n\t\"github.com/songtianyi/rrframework/logs\" // 导入日志包\n\t\"github.com/songtianyi/wechat-go/wxweb\"  // 导入协议包\n)\n\n// 必须有的插件注册函数\n// 指定session, 可以对不同用户注册不同插件\nfunc Register(session *wxweb.Session) {\n\t// 将插件注册到session\n\t// 第一个参数: 指定消息类型, 所有该类型的消息都会被转发到此插件\n\t// 第二个参数: 指定消息处理函数, 消息会进入此函数\n\t// 第三个参数: 自定义插件名，不能重名，switcher插件会用到此名称\n\tsession.HandlerRegister.Add(wxweb.MSG_TEXT, wxweb.Handler(demo), \"textdemo\")\n\n\t// 开启插件\n\tif err := session.HandlerRegister.EnableByName(\"textdemo\"); err != nil {\n\t\tlogs.Error(err)\n\t}\n}\n\n// 消息处理函数\nfunc demo(session *wxweb.Session, msg *wxweb.ReceivedMessage) {\n\n\t// 可选: 可以用contact manager来过滤, 比如过滤掉没有保存到通讯录的群\n\t// 注意，contact manager只存储了已保存到通讯录的群组\n\tcontact := session.Cm.GetContactByUserName(msg.FromUserName)\n\tif contact == nil {\n\t\tlogs.Error(\"ignore the messages from\", msg.FromUserName)\n\t\treturn\n\t}\n\n\t// 可选: 根据消息类型来过滤\n\tif msg.MsgType == wxweb.MSG_IMG {\n\t\treturn\n\t}\n\n\t// 可选: 根据wxweb.User数据结构中的数据来过滤\n\tif contact.PYQuanPin != \"songtianyi\" {\n\t\t// 比如根据用户昵称的拼音全拼来过滤\n\t\treturn\n\t}\n\n\t// 可选: 过滤和自己无关的群组消息\n\tif msg.IsGroup \u0026\u0026 msg.Who != session.Bot.UserName {\n\t\treturn\n\t}\n\n\t// 取出收到的内容\n\t// 取text\n\tlogs.Info(msg.Content)\n\t//// 取img\n\t//if b, err := session.GetImg(msg.MsgId); err == nil {\n\t//\tlogs.Debug(string(b))\n\t//}\n\n\t// anything\n\n\t// 回复消息\n\t// 第一个参数: 回复的内容\n\t// 第二个参数: 机器人ID\n\t// 第三个参数: 联系人/群组/特殊账号ID\n\tsession.SendText(\"plugin demo\", session.Bot.UserName, wxweb.RealTargetUserName(session, msg))\n\t// 回复图片和gif 参见wxweb/session.go\n\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongtianyi%2Fwechat-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsongtianyi%2Fwechat-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongtianyi%2Fwechat-go/lists"}