{ "info": { "author": "Richard Chien", "author_email": "richardchienthebest@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# CQHttp Python SDK with Asynchronous I/O\n\n[![License](https://img.shields.io/github/license/richardchien/python-aiocqhttp.svg)](LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/aiocqhttp.svg)](https://pypi.python.org/pypi/aiocqhttp)\n[![QQ \u7fa4](https://img.shields.io/badge/qq%E7%BE%A4-768887710-orange.svg)](https://jq.qq.com/?_wv=1027&k=5OFifDh)\n[![Telegram](https://img.shields.io/badge/telegram-chat-blue.svg)](https://t.me/cqhttp)\n[![QQ \u7248\u672c\u53d1\u5e03\u7fa4](https://img.shields.io/badge/%E7%89%88%E6%9C%AC%E5%8F%91%E5%B8%83%E7%BE%A4-218529254-green.svg)](https://jq.qq.com/?_wv=1027&k=5Nl0zhE)\n[![Telegram \u7248\u672c\u53d1\u5e03\u9891\u9053](https://img.shields.io/badge/%E7%89%88%E6%9C%AC%E5%8F%91%E5%B8%83%E9%A2%91%E9%81%93-join-green.svg)](https://t.me/cqhttp_release)\n\n\u672c\u9879\u76ee\u4e3a\u9177 Q \u7684 CoolQ HTTP API \u63d2\u4ef6\u7684\u65b0\u4e00\u4ee3 Python SDK\uff0c\u91c7\u7528\u5f02\u6b65 I/O\uff0c\u5c01\u88c5\u4e86 web server \u76f8\u5173\u7684\u4ee3\u7801\uff0c\u652f\u6301 HTTP API \u63d2\u4ef6\u7684 HTTP \u548c\u53cd\u5411 WebSocket \u4e24\u79cd\u901a\u4fe1\u65b9\u5f0f\uff0c\u8ba9\u4f7f\u7528 Python \u7684\u5f00\u53d1\u8005\u80fd\u65b9\u4fbf\u5730\u5f00\u53d1\u63d2\u4ef6\u3002\u4ec5\u652f\u6301 Python 3.6+ \u53ca\u63d2\u4ef6 v4.x\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u8f83\u65e7\u7248\u672c\uff0c\u8bf7\u4f7f\u7528 [`python-cqhttp`](https://github.com/richardchien/python-cqhttp)\u3002\n\n\u5173\u4e8e CoolQ HTTP API \u63d2\u4ef6\uff0c\u89c1 [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api)\uff1b\u5173\u4e8e\u5f02\u6b65 I/O\uff0c\u89c1 [asyncio](https://docs.python.org/3/library/asyncio.html)\u3002\n\n## \u5efa\u8bae\n\n\u672c SDK \u662f\u4e00\u4e2a\u57fa\u7840 SDK\uff0c\u53ea\u662f\u5bf9 CoolQ HTTP API \u63d2\u4ef6\u7684\u4e00\u5c42\u7b80\u5355\u5305\u88c5\uff0c\u5982\u679c\u4f60\u60f3\u5feb\u901f\u5730\u7f16\u5199\u673a\u5668\u4eba\u7684\u5b9e\u9645\u529f\u80fd\uff0c\u5efa\u8bae\u4f18\u5148\u8003\u8651\u4f7f\u7528 [NoneBot](https://none.rclab.tk/)\uff0c\u8fd9\u662f\u4e00\u4e2a\u57fa\u4e8e\u672c SDK \u7684\u66f4\u9ad8\u5c01\u88c5\u7a0b\u5ea6\u7684\u673a\u5668\u4eba\u6846\u67b6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u7684\u5f00\u53d1\u66f4\u65b9\u4fbf\u3002\n\n## \u57fa\u672c\u7528\u6cd5\n\n\u9996\u5148\u5b89\u88c5 `aiocqhttp` \u5305\uff1a\n\n```bash\npip install aiocqhttp\n```\n\n\u6ce8\u610f\u53ef\u80fd\u9700\u8981\u628a `pip` \u6362\u6210 `pip3`\u3002\n\n\u4e5f\u53ef\u4ee5 clone \u672c\u4ed3\u5e93\u4e4b\u540e\u7528 `python setup.py install` \u6765\u5b89\u88c5\u3002\n\n\u7136\u540e\u65b0\u5efa Python \u6587\u4ef6\uff0c\u8fd0\u884c CQHttp \u540e\u7aef\uff1a\n\n```python\nfrom aiocqhttp import CQHttp\n\nbot = CQHttp(api_root='http://127.0.0.1:5700/',\n access_token='your-token',\n secret='your-secret')\n\n\n@bot.on_message()\nasync def handle_msg(context):\n await bot.send(context, '\u4f60\u597d\u5440\uff0c\u4e0b\u9762\u4e00\u6761\u662f\u4f60\u521a\u521a\u53d1\u7684\uff1a')\n return {'reply': context['message']}\n\n\n@bot.on_notice('group_increase')\nasync def handle_group_increase(context):\n await bot.send(context, message='\u6b22\u8fce\u65b0\u4eba\uff5e',\n at_sender=True, auto_escape=True)\n\n\n@bot.on_request('group', 'friend')\nasync def handle_request(context):\n return {'approve': True}\n\n\nbot.run(host='127.0.0.1', port=8080)\n```\n\n\u4e0a\u9762\u7684\u4ee3\u7801\u4fbf\u5b9e\u73b0\u4e86\u4e00\u4e2a\u57fa\u4e8e HTTP \u901a\u4fe1\u65b9\u5f0f\u7684\u6700\u57fa\u672c\u7684 QQ \u673a\u5668\u4eba\u540e\u7aef\uff0c\u4e0b\u9762\u6765\u505a\u5177\u4f53\u89e3\u91ca\u3002\n\n### `CQHttp` \u7c7b\n\n\u9996\u5148\u9700\u8981\u521b\u5efa\u4e00\u4e2a `CQHttp` \u7c7b\u7684\u5b9e\u4f8b\u3002\u6709\u4e09\u79cd\u53ef\u884c\u7684\u7528\u6cd5\uff1a\n\n#### \u53ea\u4f7f\u7528\u53cd\u5411 WebSocket\n\n\u4e0d\u9700\u8981\u4f20\u5165 `api_root`\u3001`secret`\uff0c\u4f46\u5982\u679c\u63d2\u4ef6\u4e2d\u914d\u7f6e\u4e86 `access_token`\uff0c\u4ecd\u9700\u8981\u4f20\u5165 `access_token`\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u8bbe\u7f6e `enable_http_post` \u4e3a `False`\uff0c\u4ee5\u7981\u7528 HTTP \u4e0a\u62a5\u7684\u5165\u53e3\u3002\n\n\u8fd9\u662f\u6700\u63a8\u8350\u7684\u7528\u6cd5\uff0c\u56e0\u4e3a\u76f8\u6bd4 HTTP\uff0c\u53cd\u5411 WebSocket \u53ea\u5728\u63d2\u4ef6\u542f\u52a8\u65f6\u5efa\u7acb\u8fde\u63a5\uff0c\u540e\u7eed\u7684\u4e8b\u4ef6\u4e0a\u62a5\u548c API \u8c03\u7528\u5168\u90fd\u8d70\u5df2\u7ecf\u5efa\u7acb\u597d\u7684\u8fde\u63a5\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\uff0c\u5b9e\u9645\u6d4b\u8bd5\u4e2d\u6709\u5927\u7ea6 1\uff5e2 \u500d\u7684\u6027\u80fd\u63d0\u5347\u3002\n\n\u793a\u4f8b\uff1a\n\n```python\nbot = CQHttp(access_token='your-token',\n enable_http_post=False)\n```\n\n#### \u53ea\u4f7f\u7528 HTTP\n\n\u4f20\u5165 `api_root`\uff0c\u5373\u4e3a\u9177 Q HTTP API \u63d2\u4ef6\u7684\u76d1\u542c\u5730\u5740\uff0c\u5982\u679c\u4f60\u4e0d\u9700\u8981\u8c03\u7528 API\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u4f20\u5165\u3002\u8bbf\u95ee\u4ee4\u724c\uff08`access_token`\uff09\u548c\u7b7e\u540d\u5bc6\u94a5\uff08`secret`\uff09\u4e5f\u5728\u8fd9\u91cc\u4f20\u5165\uff0c\u5982\u679c\u6ca1\u6709\u914d\u7f6e\u63d2\u4ef6\u7684 `access_token` \u6216 `secret` \u9879\uff0c\u5219\u4e0d\u4f20\u3002\n\n\u793a\u4f8b\uff1a\n\n```python\nbot = CQHttp(api_root='http://127.0.0.1:5700/',\n access_token='your-token',\n secret='your-secret')\n```\n\n#### \u6df7\u5408\u4f7f\u7528 HTTP \u548c\u53cd\u5411 WebSocket\n\n\u6df7\u5408\u4f7f\u7528\u65f6\u521b\u5efa `CQHttp` \u7c7b\u7684\u65b9\u5f0f\u548c\u53ea\u7528 HTTP \u65f6\u4e00\u6837\uff0c`CQHttp` \u7c7b\u4f1a\u540c\u65f6\u5f00\u542f HTTP \u548c\u53cd\u5411 WebSocket \u7684\u5165\u53e3\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u63d2\u4ef6\u4e2d**\u4e0d\u5e94**\u540c\u65f6\u914d\u7f6e `post_url` \u548c `ws_reverse_event_url`\uff0c\u5426\u5219\u4e8b\u4ef6\u5c06\u4f1a\u88ab\u540c\u4e00\u4e2a\u51fd\u6570\u5904\u7406\u4e24\u6b21\uff0cAPI \u8c03\u7528\u5219\u4e0d\u5b58\u5728\u8fd9\u4e2a\u95ee\u9898\u3002\n\n### \u4e8b\u4ef6\u5904\u7406\n\n`CQHttp` \u7c7b\u7684\u5b9e\u4f8b\u7684 `on_message`\u3001`on_notice`\u3001`on_request`\u3001`on_meta_event` \u88c5\u9970\u5668\u5206\u522b\u5bf9\u5e94\u63d2\u4ef6\u7684\u56db\u79cd\u4e0a\u62a5\u7c7b\u578b\uff08`post_type`\uff09\uff0c\u62ec\u53f7\u4e2d\u6307\u51fa\u8981\u5904\u7406\u7684\u6d88\u606f\u7c7b\u578b\uff08`message_type`\uff09\u3001\u901a\u77e5\u7c7b\u578b\uff08`notice_type`\uff09\u3001\u8bf7\u6c42\u7c7b\u578b\uff08`request_type`\uff09\u3001\u5143\u4e8b\u4ef6\u7c7b\u578b\uff08`meta_event_type`\uff09\uff0c\u4e00\u6b21\u53ef\u6307\u5b9a\u591a\u4e2a\uff0c\u5982\u679c\u7559\u7a7a\uff0c\u5219\u4f1a\u5904\u7406\u6240\u6709\u8fd9\u4e2a\u4e0a\u62a5\u7c7b\u578b\u7684\u4e0a\u62a5\u3002\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d `handle_msg` \u51fd\u6570\u5c06\u4f1a\u5728\u6536\u5230\u4efb\u610f\u6e20\u9053\u7684\u6d88\u606f\u65f6\u88ab\u8c03\u7528\uff0c`handle_group_increase` \u51fd\u6570\u4f1a\u5728\u7fa4\u6210\u5458\u589e\u52a0\u65f6\u8c03\u7528\u3002\n\n\u4e0a\u9762\u88c5\u9970\u5668\u88c5\u9970\u7684\u51fd\u6570\uff0c\u7edf\u4e00\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570\uff0c\u5373\u4e3a\u4e0a\u62a5\u7684\u6570\u636e\uff0c\u5177\u4f53\u6570\u636e\u5185\u5bb9\u89c1 [\u4e8b\u4ef6\u4e0a\u62a5](https://cqhttp.cc/docs/#/Post)\uff1b\u51fd\u6570\u53ef\u4ee5\u4e0d\u8fd4\u56de\u503c\uff0c\u4e5f\u53ef\u4ee5\u8fd4\u56de\u4e00\u4e2a\u5b57\u5178\uff0c\u4f1a\u88ab\u81ea\u52a8\u4f5c\u4e3a\u5feb\u901f\u64cd\u4f5c\u63d0\u4f9b\u7ed9 HTTP API \u63d2\u4ef6\u6267\u884c\uff08\u8981\u6c42\u63d2\u4ef6\u7248\u672c\u5728 4.2 \u4ee5\u4e0a\uff09\uff0c\u4f8b\u5982 `return {'reply': context['message']}` \u5c06\u4f1a\u8ba9\u63d2\u4ef6\u628a\u6536\u5230\u7684\u6d88\u606f\u91cd\u65b0\u53d1\u51fa\u53bb\uff0c\u5177\u4f53\u89c1 [\u4e0a\u62a5\u8bf7\u6c42\u7684\u54cd\u5e94\u6570\u636e\u683c\u5f0f](https://cqhttp.cc/docs/#/Post?id=%E4%B8%8A%E6%8A%A5%E8%AF%B7%E6%B1%82%E7%9A%84%E5%93%8D%E5%BA%94%E6%95%B0%E6%8D%AE%E6%A0%BC%E5%BC%8F)\u3002\n\n\u65e0\u8bba\u4f7f\u7528 HTTP \u548c\u53cd\u5411 WebSocket \u65b9\u5f0f\u6765\u4e0a\u62a5\u4e8b\u4ef6\uff0c\u90fd\u8c03\u7528\u540c\u6837\u7684\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\uff0c\u56e0\u6b64\uff0c\u5982\u679c\u63d2\u4ef6\u540c\u65f6\u914d\u7f6e\u4e86 `post_url` \u548c `ws_reverse_event_url`\uff0c\u4e8b\u4ef6\u5c06\u4f1a\u88ab\u5904\u7406\u4e24\u6b21\u3002\n\n### API \u8c03\u7528\n\n\u521b\u5efa\u5b9e\u4f8b\u65f6\u4f20\u5165\u7684 `api_root` \u548c\u5f53\u524d\u5df2\u8fde\u63a5\u5230\u53cd\u5411 WebSocket API \u5165\u53e3\u7684\u5ba2\u6237\u7aef\u90fd\u4f1a\u88ab\u7528\u4e8e API \u8c03\u7528\uff0c**\u5982\u679c\u540c\u65f6\u53ef\u7528\uff0c\u5219\u4f18\u5148\u4f7f\u7528\u53cd\u5411 WebSocket**\u3002\n\n\u76f4\u63a5\u5728 `CQHttp` \u7c7b\u7684\u5b9e\u4f8b\u4e0a\u5c31\u53ef\u4ee5\u8c03\u7528 API\uff0c\u4f8b\u5982 `bot.send_private_msg(user_id=123456, message='hello')`\uff0c\u8fd9\u91cc\u7684 `send_private_msg` \u5373\u4e3a [`/send_private_msg` \u53d1\u9001\u79c1\u804a\u6d88\u606f](https://cqhttp.cc/docs/#/API?id=send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF) \u4e2d\u7684 `/send_private_msg`\uff0c**API \u6240\u9700\u53c2\u6570\u76f4\u63a5\u901a\u8fc7\u547d\u540d\u53c2\u6570\uff08keyword argument\uff09\u4f20\u5165**\u3002\u5176\u5b83 API \u89c1 [API \u5217\u8868](https://cqhttp.cc/docs/#/API?id=api-\u5217\u8868)\u3002\n\n\u4e3a\u4e86\u7b80\u5316\u53d1\u9001\u6d88\u606f\u7684\u64cd\u4f5c\uff0c\u63d0\u4f9b\u4e86 `send(context, message)` \u51fd\u6570\uff0c\u8fd9\u91cc\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570 `context` \u4e5f\u5c31\u662f\u4e0a\u62a5\u6570\u636e\uff0c\u4f20\u5165\u4e4b\u540e\u51fd\u6570\u4f1a\u81ea\u5df1\u5224\u65ad\u5f53\u524d\u9700\u8981\u53d1\u9001\u5230\u54ea\u91cc\uff08\u54ea\u4e2a\u597d\u53cb\uff0c\u6216\u54ea\u4e2a\u7fa4\uff09\uff0c\u65e0\u9700\u624b\u52a8\u518d\u6307\u5b9a\uff0c\u5176\u5b83\u53c2\u6570\u4ecd\u7136\u53ef\u4ee5\u4ece keyword argument \u6307\u5b9a\uff0c\u4f8b\u5982 `auto_escape=True`\u3002\n\n\u8c03\u7528 API \u65f6\uff0c\u5982\u679c API \u5f53\u524d\u4e0d\u53ef\u7528\uff08\u4f8b\u5982\u6ca1\u6709\u4efb\u4f55\u8fde\u63a5\u4e86\u7684 WebSocket\u3001\u6216\u672a\u914d\u7f6e API root\uff09\uff0c\u5219\u629b\u51fa `aiocqhttp.ApiNotAvailable`\uff1b\u5982\u679c API \u53ef\u7528\uff0c\u4f46\u7f51\u7edc\u65e0\u6cd5\u8fde\u63a5\u6216\u8fde\u63a5\u51fa\u73b0\u9519\u8bef\uff0c\u4f1a\u629b\u51fa `aiocqhttp.NetworkError` \u5f02\u5e38\u3002\u800c\u4e00\u65e6\u8bf7\u6c42\u6210\u529f\uff0cSDK \u4f1a\u5224\u65ad HTTP \u54cd\u5e94\u72b6\u6001\u7801\u662f\u5426\u4e3a 2xx\uff0c\u5982\u679c\u4e0d\u662f\uff0c\u5219\u629b\u51fa `aiocqhttp.HttpFailed` \u5f02\u5e38\uff0c\u5728\u8fd9\u4e2a\u5f02\u5e38\u4e2d\u53ef\u901a\u8fc7 `status_code` \u83b7\u53d6 HTTP \u54cd\u5e94\u72b6\u6001\u7801\uff1b\u5982\u679c\u662f 2xx\uff0c\u5219\u8fdb\u4e00\u6b65\u67e5\u770b\u54cd\u5e94 JSON \u7684 `status` \u5b57\u6bb5\uff0c\u5982\u679c `status` \u5b57\u6bb5\u4e3a `failed`\uff0c\u5219\u629b\u51fa `aiocqhttp.ActionFailed` \u5f02\u5e38\uff0c\u5728\u8fd9\u4e2a\u5f02\u5e38\u4e2d\u53ef\u901a\u8fc7 `retcode` \u83b7\u53d6 API \u8c03\u7528\u7684\u8fd4\u56de\u7801\u3002\u4ee5\u4e0a\u5404\u5f02\u5e38\u5168\u90fd\u7ee7\u627f\u81ea `aiocqhttp.Error`\u3002**\u5982\u679c `status` \u4e3a `ok` \u6216 `async`\uff0c\u5219\u4e0d\u629b\u51fa\u5f02\u5e38\uff0c\u51fd\u6570\u8fd4\u56de\u63d2\u4ef6\u54cd\u5e94\u6570\u636e\u7684 `data` \u5b57\u6bb5\uff08\u6709\u53ef\u80fd\u4e3a None\uff09**\u3002\u5177\u4f53 HTTP \u54cd\u5e94\u72b6\u6001\u7801\u548c `retcode` \u7684\u542b\u4e49\uff0c\u89c1 [\u54cd\u5e94\u8bf4\u660e](https://cqhttp.cc/docs/#/API?id=%E5%93%8D%E5%BA%94%E8%AF%B4%E6%98%8E)\u3002\n\n### \u8fd0\u884c\u5b9e\u4f8b\n\n\u4f7f\u7528\u88c5\u9970\u5668\u5b9a\u4e49\u597d\u5904\u7406\u51fd\u6570\u4e4b\u540e\uff0c\u8c03\u7528 `bot.run()` \u5373\u53ef\u8fd0\u884c\u3002\u4f60\u9700\u8981\u4f20\u5165 `host` \u548c `port` \u53c2\u6570\uff0c\u6765\u6307\u5b9a\u670d\u52a1\u7aef\u9700\u8981\u8fd0\u884c\u5728\u54ea\u4e2a\u5730\u5740\u3002\n\n\u540e\u7aef\u8fd0\u884c\u4e86\u4e4b\u540e\uff0c\u9700\u8981\u914d\u7f6e HTTP API \u63d2\u4ef6\u3002\u5bf9\u4e8e HTTP \u4e8b\u4ef6\u4e0a\u62a5\uff0c\u9700\u8981\u914d\u7f6e `post_url` \u4e3a `http://host:port/`\uff1b\u5bf9\u4e8e\u53cd\u5411 WebSocket \u4e8b\u4ef6\u4e0a\u62a5\u548c API \u8c03\u7528\uff0c\u5206\u522b\u9700\u8981\u914d\u7f6e `ws_reverse_event_url` \u548c `ws_reverse_api_url` \u4e3a `ws://host:port/ws/event/` \u548c `ws://host:port/ws/api/`\u3002\u5176\u4e2d `host` \u548c `port` \u5747\u4e3a `bot.run()` \u8fd0\u884c\u65f6\u7684\u76f8\u5e94\u53c2\u6570\u3002\n\n## \u9ad8\u7ea7\u7528\u6cd5\n\n### \u90e8\u7f72\n\n`bot.run()` \u53ea\u9002\u7528\u4e8e\u5f00\u53d1\u73af\u5883\uff0c\u4e0d\u5efa\u8bae\u7528\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u56e0\u6b64 SDK \u63d0\u4f9b `bot.asgi` \u5c5e\u6027\u4ee5\u83b7\u53d6\u5176\u5185\u90e8\u7684 ASGI \u5b9e\u4f8b\uff0c\u4ece\u800c\u53ef\u4ee5 [\u4f7f\u7528 ASGI \u670d\u52a1\u5668\u6765\u90e8\u7f72](https://pgjones.gitlab.io/quart/deployment.html)\uff0c\u4f8b\u5982\uff1a\n\n```bash\nhypercorn demo:bot.asgi\n```\n\n### \u6dfb\u52a0\u8def\u7531\n\n`CQHttp` \u5185\u90e8\u4f7f\u7528 [Quart](https://pgjones.gitlab.io/quart/) \u6765\u63d0\u4f9b web server\uff0c\u9ed8\u8ba4\u6dfb\u52a0\u4e86 bot \u6240\u9700\u7684 `/` \u548c `/ws/` \u8def\u7531\uff08`enable_http_post=False` \u65f6\u53ea\u6dfb\u52a0\u4e86 `/ws/`\uff09\uff0c\u5982\u9700\u6dfb\u52a0\u5176\u5b83\u8def\u7531\uff0c\u4f8b\u5982\u5728 `/admin/` \u63d0\u4f9b\u7ba1\u7406\u9762\u677f\u8bbf\u95ee\uff0c\u53ef\u4ee5\u901a\u8fc7 `bot.server_app` \u8bbf\u95ee\u5185\u90e8\u7684 `Quart` \u5b9e\u4f8b\u6765\u505a\u5230\uff1a\n\n```python\napp = bot.server_app\n\n@app.route('/admin')\nasync def admin():\n return 'This is the admin page.'\n```\n\n\u76ee\u524d `bot.server_app` \u548c `bot.asgi` \u7b49\u4ef7\u3002\n\n### \u65e5\u5fd7\n\n\u901a\u8fc7 `bot.logger` \u5c5e\u6027\u53ef\u4ee5\u83b7\u53d6\u5230 Quart \u6846\u67b6\u7684 [app logger](https://pgjones.gitlab.io/quart/logging.html)\uff0c\u5b83\u662f\u4e00\u4e2a\u6807\u51c6\u7684 Python Logger\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u5bf9\u5176\u8fdb\u884c\u914d\u7f6e\u548c\u4f7f\u7528\u3002\n\n### `message` \u6a21\u5757\n\n\u53ef\u4f7f\u7528 `message` \u6a21\u5757\u6765\u66f4\u65b9\u4fbf\u5730\u64cd\u4f5c\u6d88\u606f\uff0c\u4e3b\u8981\u63d0\u4f9b `Message` \u548c `MessageSegment` \u7c7b\uff0c\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a\n\n```python\nfrom aiocqhttp import CQHttp\nfrom aiocqhttp.message import Message, MessageSegment\n\nbot = CQHttp(message_class=Message) # message_class \u9ed8\u8ba4\u4e3a None\uff0c\u5373\u4fdd\u6301\u4e0a\u62a5\u65f6\u7684\u539f\u6837\n\n\n@bot.on_message('group')\nasync def handle(context):\n # \u5982\u679c\u8bbe\u7f6e\u4e86 message_class \u53c2\u6570\uff0c\u5219\u8fd9\u91cc\u65ad\u8a00\u5c31\u4f1a\u6210\u7acb\n # \u8be5\u53c2\u6570\u4e0d\u5f71\u54cd\u540e\u9762\u53d1\u9001\u6d88\u606f\u65f6\u5bf9 Message \u7c7b\u7684\u4f7f\u7528\n assert isinstance(context['message'], Message)\n\n await bot.send(context, Message('\u4f60\u597d\uff01') + MessageSegment.at(context['user_id']))\n await bot.send(context, Message('\u4f60\u521a\u521a\u53d1\u4e86\uff1a') + context['message'].extract_plain_text())\n```\n\n\u76f8\u5173 API \u6587\u6863\u89c1 [`MessageSegment`](https://none.rclab.tk/api.html#class-messagesegment) \u548c [`Message`](https://none.rclab.tk/api.html#class-message)\u3002\n\n## \u66f4\u65b0\u65e5\u5fd7\n\n\u66f4\u65b0\u65e5\u5fd7\u89c1 [CHANGELOG.md](CHANGELOG.md)\u3002\n\n## \u9047\u5230\u95ee\u9898\n\n\u5982\u679c\u5728\u4f7f\u7528\u672c SDK \u65f6\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u8bf7 [\u63d0\u4ea4 issue](https://github.com/richardchien/python-aiocqhttp/issues/new)\u3002", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/richardchien/python-aiocqhttp", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "aiocqhttp", "package_url": "https://pypi.org/project/aiocqhttp/", "platform": "any", "project_url": "https://pypi.org/project/aiocqhttp/", "project_urls": { "Homepage": "https://github.com/richardchien/python-aiocqhttp" }, "release_url": "https://pypi.org/project/aiocqhttp/0.6.8/", "requires_dist": null, "requires_python": ">=3.6.1", "summary": "CQHttp Python SDK with Asynchronous I/O", "version": "0.6.8" }, "last_serial": 5469246, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "47f2a276791cc1e1361db6e7a8a41a78", "sha256": "53308c5522f4dd51a197cc93e9f2e3e67d50b9118e8067a91dd24d2c4f0fa13b" }, "downloads": -1, "filename": "aiocqhttp-0.0.1.tar.gz", "has_sig": false, "md5_digest": "47f2a276791cc1e1361db6e7a8a41a78", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 5139, "upload_time": "2018-05-29T14:46:21", "url": "https://files.pythonhosted.org/packages/79/0f/0dd8e1f0987464ae2cca68a94e16a83c1ef1d9dcf5821d8a9b3e0c2008fc/aiocqhttp-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "ed8b2da99eb9e1cf0775a367eee6c07d", "sha256": "559017c8ff2d5da006c116c9aef50e2a81eec13b5b8374f6fb35a7dd3e3066fa" }, "downloads": -1, "filename": "aiocqhttp-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ed8b2da99eb9e1cf0775a367eee6c07d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7446, "upload_time": "2018-06-02T12:41:58", "url": "https://files.pythonhosted.org/packages/c7/98/a80d1d119a435815fc232bc5aad25823a426470500bbe1cf43962df89149/aiocqhttp-0.0.2.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "ac317885dc81d6703c675167849789e6", "sha256": "9da3c00ccd2a8a2b2b9b1be416b512839e6aa9890873a7b12f07f9c563fa491d" }, "downloads": -1, "filename": "aiocqhttp-0.1.0.tar.gz", "has_sig": false, "md5_digest": "ac317885dc81d6703c675167849789e6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7615, "upload_time": "2018-06-02T15:19:50", "url": "https://files.pythonhosted.org/packages/a1/ce/b498399f379a82887a4bb0fc43565bfb75341a138bf69144bd42bbc25a62/aiocqhttp-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "87ab5cd8e6f936964f8993addfd4f1ec", "sha256": "2dcbad5afb9ffc89991a18a1048efc302e3538fc4761c20aefaef77e95a1f1e2" }, "downloads": -1, "filename": "aiocqhttp-0.1.1.tar.gz", "has_sig": false, "md5_digest": "87ab5cd8e6f936964f8993addfd4f1ec", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7677, "upload_time": "2018-06-03T02:35:57", "url": "https://files.pythonhosted.org/packages/50/16/7a7c1a42611be9767b3960213faab40f841b9b10ae6ff8291c1af5b64673/aiocqhttp-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "154e60527587220e0e3c6a94afacd564", "sha256": "fdaaa862fbbb88bf937f39e851c1e6c2264ab5c6ad2580a7cb402bfdd91b93de" }, "downloads": -1, "filename": "aiocqhttp-0.2.0.tar.gz", "has_sig": false, "md5_digest": "154e60527587220e0e3c6a94afacd564", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 9956, "upload_time": "2018-06-03T10:33:31", "url": "https://files.pythonhosted.org/packages/0f/f9/09333e99fb085da2b5b780efdd9db950ddd58d41c93a18945fba5047c776/aiocqhttp-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "ad4df8db202b0212b84a3bdf07e906d4", "sha256": "caeb5c9b19b0d7bf4cee035222770da48d40ec7957c42db901628abf95f18fae" }, "downloads": -1, "filename": "aiocqhttp-0.3.0.tar.gz", "has_sig": false, "md5_digest": "ad4df8db202b0212b84a3bdf07e906d4", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 10563, "upload_time": "2018-06-07T12:46:39", "url": "https://files.pythonhosted.org/packages/b3/66/f2e45ab5e45eb5ebe0ef1327629c087c028875d916d412cda29f424aa3fb/aiocqhttp-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "279c11ec62d3a0bf4846686e7b88643a", "sha256": "5db42b496fbbe66fd8d57f1480b37e0a4fb9d660359fc297d15dd9c05d04ffdb" }, "downloads": -1, "filename": "aiocqhttp-0.4.0.tar.gz", "has_sig": false, "md5_digest": "279c11ec62d3a0bf4846686e7b88643a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 11343, "upload_time": "2018-07-02T06:38:31", "url": "https://files.pythonhosted.org/packages/65/c5/935b88309f3f1bea6fd7c29da92df95a269234407b3cf6d978a498e65346/aiocqhttp-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "837069e86c29dd2ec6bd266ae7950b2b", "sha256": "1ea3095b0d288373267ca64209dd93abe450f087f01118c0f400c987d28fefde" }, "downloads": -1, "filename": "aiocqhttp-0.5.0.tar.gz", "has_sig": false, "md5_digest": "837069e86c29dd2ec6bd266ae7950b2b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 11700, "upload_time": "2018-07-03T02:09:18", "url": "https://files.pythonhosted.org/packages/cd/41/d597b08f8c5e0e2346f2f6ff2a64a6887e46e94c9ae7a872080774fd36d1/aiocqhttp-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "b2bcd13dde7dfc9461b74a8cb7553cad", "sha256": "e67528a7681de59e5903638ed33ddb60cc2b11efa02c90e351f8420048b045ef" }, "downloads": -1, "filename": "aiocqhttp-0.6.0.tar.gz", "has_sig": false, "md5_digest": "b2bcd13dde7dfc9461b74a8cb7553cad", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 11704, "upload_time": "2018-07-22T14:07:36", "url": "https://files.pythonhosted.org/packages/63/43/3370c56a9c66be8563fbb7e61352ffaba34959762a5f59e3e5f0db812c59/aiocqhttp-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "1c49affb8b5937b2a1b85938df8b3b41", "sha256": "c15b08fa052b0c6d5d62c0ce50b5f67d55b20e7d530858630d3b3913c8d6bc9c" }, "downloads": -1, "filename": "aiocqhttp-0.6.1.tar.gz", "has_sig": false, "md5_digest": "1c49affb8b5937b2a1b85938df8b3b41", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15816, "upload_time": "2018-08-26T02:25:26", "url": "https://files.pythonhosted.org/packages/b1/7d/c37581a4b30ec5503aa24b00f9f0869257b409993b31b242d0e2476aff90/aiocqhttp-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "cacf0024d3f334db0d37d8b09633410f", "sha256": "0fd961a4a379d1ebdf5a0c39aa1181bd77981e807c280665012935aeaf7b64a0" }, "downloads": -1, "filename": "aiocqhttp-0.6.2.tar.gz", "has_sig": false, "md5_digest": "cacf0024d3f334db0d37d8b09633410f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15931, "upload_time": "2018-09-02T02:37:59", "url": "https://files.pythonhosted.org/packages/77/bc/baf8cd47774a87e3d00a2abffd8478e7d2ef9eb65f12d0bbb58336084a37/aiocqhttp-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "bc3f79b3e7b32a5bf1eb318ef4607149", "sha256": "80dc7df9c274a32e467805bcd6f785912b86704b625814ec50684f8e1f29fcca" }, "downloads": -1, "filename": "aiocqhttp-0.6.3.tar.gz", "has_sig": false, "md5_digest": "bc3f79b3e7b32a5bf1eb318ef4607149", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 16166, "upload_time": "2018-09-27T13:02:01", "url": "https://files.pythonhosted.org/packages/24/33/6dc0390e13c17ba82f069da023373db700adcb1a99187e80b53818c776f6/aiocqhttp-0.6.3.tar.gz" } ], "0.6.4": [ { "comment_text": "", "digests": { "md5": "cfe6dca97a2172df0dff4927862b39b2", "sha256": "ba8dc27838595fb230b8cc9eaffacd3faf8625f9fdabf80a33c12a27888bbe39" }, "downloads": -1, "filename": "aiocqhttp-0.6.4.tar.gz", "has_sig": false, "md5_digest": "cfe6dca97a2172df0dff4927862b39b2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 16690, "upload_time": "2018-10-16T03:20:28", "url": "https://files.pythonhosted.org/packages/0f/9d/dcb3022894be7c5188837c5792905baef91d01799af6bade1d8fb929c3e3/aiocqhttp-0.6.4.tar.gz" } ], "0.6.5": [ { "comment_text": "", "digests": { "md5": "47505149e221a3bad8d323c43b92db6c", "sha256": "343d5b4dcafee1d557734048f460a4b0418b4f82db342fd63362cc5fa0ecace8" }, "downloads": -1, "filename": "aiocqhttp-0.6.5.tar.gz", "has_sig": false, "md5_digest": "47505149e221a3bad8d323c43b92db6c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 16646, "upload_time": "2018-11-11T04:10:48", "url": "https://files.pythonhosted.org/packages/ac/77/db35aae3a14cc04df9b3bc0447422f522d07ab21fc32ba1930670eab8b8e/aiocqhttp-0.6.5.tar.gz" } ], "0.6.6": [ { "comment_text": "", "digests": { "md5": "8761ba1f94eeecb065a9ace38ecc945e", "sha256": "18af4ba4c8a9bbbc9c3f5cae7f3102698db357ff5913a2ec6e42a57bee64d099" }, "downloads": -1, "filename": "aiocqhttp-0.6.6.tar.gz", "has_sig": false, "md5_digest": "8761ba1f94eeecb065a9ace38ecc945e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 16950, "upload_time": "2018-12-11T05:01:34", "url": "https://files.pythonhosted.org/packages/53/eb/02efc713544a66a79967a46c14cbb75bfb9496f6b1901623f3015383f449/aiocqhttp-0.6.6.tar.gz" } ], "0.6.7": [ { "comment_text": "", "digests": { "md5": "a36dc02a924746510f03fae597c1739f", "sha256": "86353ad389846eddf185bb61c8a85edea8419981457bc388fe221aa6c37b6dd6" }, "downloads": -1, "filename": "aiocqhttp-0.6.7.tar.gz", "has_sig": false, "md5_digest": "a36dc02a924746510f03fae597c1739f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 17029, "upload_time": "2018-12-21T14:49:00", "url": "https://files.pythonhosted.org/packages/34/45/b4923fb43e36ba588c8a754739296c1ddfd1c94145011cb21b95a63168ec/aiocqhttp-0.6.7.tar.gz" } ], "0.6.8": [ { "comment_text": "", "digests": { "md5": "c2233c6aea7d4bba9fd1149aa51f9e97", "sha256": "e2edd94aad2ddb35ccb3c1de40f3cf3e75e6ace808eaab10ba890c68f1eec83d" }, "downloads": -1, "filename": "aiocqhttp-0.6.8.tar.gz", "has_sig": false, "md5_digest": "c2233c6aea7d4bba9fd1149aa51f9e97", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 17427, "upload_time": "2019-07-01T01:46:40", "url": "https://files.pythonhosted.org/packages/03/00/c39365234f4af1e2a4546b57c01ef037fb88cc67074f2c511a406e6bc24f/aiocqhttp-0.6.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2233c6aea7d4bba9fd1149aa51f9e97", "sha256": "e2edd94aad2ddb35ccb3c1de40f3cf3e75e6ace808eaab10ba890c68f1eec83d" }, "downloads": -1, "filename": "aiocqhttp-0.6.8.tar.gz", "has_sig": false, "md5_digest": "c2233c6aea7d4bba9fd1149aa51f9e97", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.1", "size": 17427, "upload_time": "2019-07-01T01:46:40", "url": "https://files.pythonhosted.org/packages/03/00/c39365234f4af1e2a4546b57c01ef037fb88cc67074f2c511a406e6bc24f/aiocqhttp-0.6.8.tar.gz" } ] }