{"id":28445101,"url":"https://github.com/wechaty/python-wechaty-template","last_synced_at":"2025-06-29T20:32:02.572Z","repository":{"id":44339226,"uuid":"512126321","full_name":"wechaty/python-wechaty-template","owner":"wechaty","description":"getting started project template for python-wechaty","archived":false,"fork":false,"pushed_at":"2022-10-29T11:53:55.000Z","size":46,"stargazers_count":58,"open_issues_count":4,"forks_count":19,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-06T10:11:37.463Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wechaty.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}},"created_at":"2022-07-09T07:48:27.000Z","updated_at":"2025-05-14T02:40:53.000Z","dependencies_parsed_at":"2023-01-20T15:15:55.569Z","dependency_job_id":null,"html_url":"https://github.com/wechaty/python-wechaty-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wechaty/python-wechaty-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpython-wechaty-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpython-wechaty-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpython-wechaty-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpython-wechaty-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wechaty","download_url":"https://codeload.github.com/wechaty/python-wechaty-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wechaty%2Fpython-wechaty-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262663066,"owners_count":23344986,"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":"2025-06-06T10:11:20.430Z","updated_at":"2025-06-29T20:32:02.546Z","avatar_url":"https://github.com/wechaty.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-wechaty-template\n\nPython Wechaty Project Template which contains the best practise.\n\n## Getting Started\n\n### 申请Token\n\n如要运行微信机器人，需要申请Token来启动服务，在此推荐申请[Padlocal Token](http://pad-local.com/#/)来快速启动该服务。\n\n### 启动Gateway Docker 服务\n运行本项目下的`start_gateway_docker.sh`脚本，并将申请到的Padlocal Token作为脚本参数传入\n\n```shell\n./start_gateway_docker.sh \u003cyour_token\u003e\n```\n\n### 运行机器人\n\n```shell\nmake bot\n```\n\n初次登陆时，可能需要多次扫码才会登陆成功。\n扫码登陆成功后，wechaty机器人就算启动成功了，可以通过微信向机器人发送消息`ding`来测试。默认开启DingDong插件，机器人会自动回复`dong`。\n至此，恭喜你，你的第一个微信机器人成功运行了！接下来可以将各种需求和业务逻辑以插件的形式加入到机器人中。\n\n## 编写插件\n\n目前有很多开发者将所有的业务逻辑都写在一个文件的一个函数（`on_message`）里面，时间长了，业务多了，就导致这里的代码很难管理，故需要从代码文件层面就将业务隔离开，此时我们推荐使用[插件系统](https://wechaty.readthedocs.io/zh_CN/latest/plugins/introduction/)来编写对应业务。\n\n* 插件示例\n\n```python\nfrom wechaty import WechatyPlugin, Message\n\nclass DingDongPlugin(WechatyPlugin):\n    async def on_message(self, msg: Message) -\u003e None:\n        if msg.text() == \"ding\":\n            await msg.say(\"dong\")\n```\n\n* 插件消息传递\n\n如果在Bot中use了很多个插件：[A, B, C, D, E, ...]，wechaty接收到消息之后会挨个儿将消息传递给插件去处理，如果其中回复了消息之后，想阻止插件继续传递的话，需要添加一个message_controller模块，代码示例如下：\n\n```python\nfrom wechaty import WechatyPlugin, Message\nfrom wechaty_plugin_contrib.message_controller import message_controller\n\nclass DingDongPlugin(WechatyPlugin):\n\n    @message_controller\n    async def on_message(self, msg: Message) -\u003e None:\n        if msg.text() == \"ding\":\n            await msg.say(\"dong\")\n            message_controller.disable_all_plugins(msg)\n```\n\n对代码的修改只需要三行修改：\n* 添加message_controller全局单例对象的导入\n* 将其作为装饰器应用在on_message函数上\n* 在想阻止消息传递的地方添加一行代码：`message_controller.disable_all_plugins(msg)`，此时需要注意需要将msg对象传递进去。\n\n## History\n\n### v0.0.2 (Aug 2022)\n\nadd `wechaty-ui` based code.\n\n### v0.0.1 (July 2022)\n\nThe `python-wechaty-template` project was created. \n\n## Maintainers\n\n- @wj-Mcat - [wj-Mcat](https://github.com/wj-Mcat), nlp researcher\n\n## Copyright \u0026 License\n\n- Code \u0026 Docs © 2022 Wechaty Contributors \u003chttps://github.com/wechaty\u003e\n- Code released under the Apache-2.0 License\n- Docs released under Creative Commons\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Fpython-wechaty-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwechaty%2Fpython-wechaty-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwechaty%2Fpython-wechaty-template/lists"}