{"id":19217039,"url":"https://github.com/shellvon/tdd","last_synced_at":"2026-06-14T18:38:09.142Z","repository":{"id":71590839,"uuid":"140104051","full_name":"shellvon/tdd","owner":"shellvon","description":"微信公众号-淘逗逗","archived":false,"fork":false,"pushed_at":"2018-08-21T02:45:50.000Z","size":5600,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-13T18:03:39.509Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shellvon.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}},"created_at":"2018-07-07T17:26:28.000Z","updated_at":"2019-08-29T16:31:29.000Z","dependencies_parsed_at":"2023-05-12T02:45:33.557Z","dependency_job_id":null,"html_url":"https://github.com/shellvon/tdd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shellvon/tdd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellvon%2Ftdd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellvon%2Ftdd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellvon%2Ftdd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellvon%2Ftdd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shellvon","download_url":"https://codeload.github.com/shellvon/tdd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shellvon%2Ftdd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34333806,"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-06-14T02:00:07.365Z","response_time":62,"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":"2024-11-09T14:19:55.179Z","updated_at":"2026-06-14T18:38:09.111Z","avatar_url":"https://github.com/shellvon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 订阅号-淘逗逗\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"400\" height=\"400\" src=\"./screenshot/tdd.jpg\"\u003e\n\u003c/p\u003e\n\n此项目立意是用于学习/了解公众号相关机制，非盈利。\n\n目前公众号内引入的功能:\n\n+ 智能闲聊 -By [腾讯AI-自然语言处理](https://ai.qq.com/doc/nlpchat.shtml)\n+ 闲聊/百度/菜谱/搜索/笑话 -By [图灵机器人](http://www.tuling123.com/)\n+ 图像美肤/融合/化妆/年龄检测 -By [腾讯AI-计算机视觉](https://ai.qq.com/doc/facecosmetic.shtml)\n+ 电影检索(Plugins) -By [torrentkitty](https://www.torrentkitty.tv)\n+ 斗图(Plugins)  -By [斗图啦](https://www.doutula.com/apidoc)\n+ 淘宝优惠券(Plugins) -By [阿里妈妈](https://www.alimama.com/index.htm), 部分代码借鉴至:[@xsren](https://github.com/xsren/wx_taobao_fanli)\n+ VIP视频解析(Plugins) -By [网络资源](https://iodefog.github.io/text/mviplist.json)\n\n# 技术方案:\n\n+ Python2.7 ( With wechatpy + requests + flask )\n\n目前机器人核心代码放在 [bot.py](./bot.py) 下，本质上是调用 腾讯AI 进行瞎聊。\n\n## Command注册机制\n\n一个 Command 即用户输入的一个指令，用于完成一些特定的功能，比如当用户输入 Menu 等，即表示查看菜单。这个类似于关键字回复。\n\n目前的实现方式是: `bot.register_cmd(cmd_name:str, cmd:CommandItem)`。\n\n注册的 Command 总是显示在菜单的最后面, 一个 cmd_name 只能有一个回调函数，重复注册只有最新的会生效。\n\n一个简单的例子如下:\n\n```\nimport sys\n\nthis_module = sys.modules[__name__]\nbot = AI('your_app_id', 'your_app_key', your_plugins)\n# 注册一个名字叫cmd_name的函数,类型为 CommandItem, 属性见用例\nbot.register_cmd('cmd_name',\n                 CommandItem(desc='描述此命令做什么的,将会在菜单中展示', re='触发的正则表达式,',\n                             method=(this_module, 'hello')))))\n\n# method 即指定触发的回调函数,类型为tuple, 此参数用于getattr(*method), 其格式为(obj, attr, default) 其中default为可选.\ncmd = ai.parse_command(msg) # -\u003e 当msg 符合re时返回对应的CommandItem\nai.unregister_cmd('cmd_name') # 取消注册\nprint cmd\n\n```\n\n## 插件机制\n\n为了更灵活的支持微信的 **关键词自动回复** 功能, 因此也引入了插件机制。\n已经写好的插件代码见 `plugins` 目录。\n\n\u003e 某种程度上讲，之前的函数注册机制和目前的插件机制很类似, 但还是有一些区别:\n\u003e 1. 插件支持非正则的方式进行匹配，而不仅仅限制于文本消息内容，这一点 Command 无法做到。\n\u003e 2. 插件比注册的 Command 优先级更高。只有当插件没有匹配到或者返回为空的情况下，Command 才会有机会进行处理。\n\u003e 3. 插件更为灵活，优先级调控 / 自动触发 bootstrap 等。 注册的插件可以在\u003c帮助\u003e中查看，注册的 Command 可以在\u003cMenu\u003e中查看。\n\n一个插件十分简单，只需要实现俩个方法即可:\n\n\n+ **match(msg: wechatpy.messages.BaseMessage, bot:bot.AI)**\n+ **response(msg: wechatpy.messages, bot:bot.AI)**\n\n一个简单的例子参见:[plugins/hello.py](./plugins/hello.py)\n\n```python\n# -*- coding:utf-8 -*-\n\n\nimport re\n\n__plugin__ = 'hello_world'\n__description__ = '发送hello,回复你好呀'\n\nHELLO_REGEX = re.compile('^hello$', re.I)\n\n# current plugin priority. optional. default is 0\nPRIORITY = 10\n\n\ndef match(msg, bot=None):\n    return msg.type == 'text' and HELLO_REGEX.match(msg.content)\n\n\ndef response(msg, bot=None):\n    return u'你好呀^_^'\n\n```\n\n插件支持优先级。(即当相同规则被多个插件同时满足时优先级较高的可以被处理，从而跳过优先级较低的)。\n设置插件的优先级请使用属性 `PRIORITY`, 默认为0。越大越优先。\n\n插件其他特性:\n\n+ 支持使用 `__plugins__` 等 `__description__` 特殊变量用于描述和说明插件功能（当用户查看帮助时可见）\n+ 支持 `bootstrap` 即当插件启动时触发的函数,参见 [plugins/help.py](./plugins/help.py)\n\n\n# 效果截图\n\n\u003cimg align=\"left\" width=\"320\" height=\"580\" src=\"./screenshot/chat.png\"\u003e\n\u003cimg align=\"right\" width=\"320\" height=\"580\" src=\"./screenshot/alimama.png\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellvon%2Ftdd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshellvon%2Ftdd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshellvon%2Ftdd/lists"}