nonebot-plugin-gocqhttp-cross-machine-upload-file
========
为go-cqhttp与nonebot部署于不同机器的系统提供上传群文件、私聊文件的能力。
**只适用于FastAPI反向驱动器**
## 用法
```python
from io import StringIO
from nonebot import on_startswith, require
from nonebot.adapters.onebot.v11 import Bot, MessageEvent
require("nonebot_plugin_gocqhttp_cross_machine_upload_file")
from nonebot_plugin_gocqhttp_cross_machine_upload_file import upload_file
@on_startswith("test").handle()
async def handle(bot: Bot, event: MessageEvent):
# 上传指定路径文件
await upload_file(bot, event, "image.png", path="image.png")
# 上传打开的IO流
with StringIO() as f:
f.write("Hello World")
f.seek(0)
await upload_file(bot, event, "hello.txt", f)
# 上传bytes
await upload_file(bot, event, "hello.txt", "Hello World".encode())
```
## 配置
### callback_host
回调HOST,设置为nonebot所在的主机名/IP。务必保证go-cqhttp所在主机可访问,用于让go-cqhttp下载本机文件。
默认值:127.0.0.1
### callback_port
回调端口,保持默认值即可。
默认值:与PORT保持一致即可
Raw data
{
"_id": null,
"home_page": "",
"name": "nonebot-plugin-gocqhttp-cross-machine-upload-file",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "ssttkkl",
"author_email": "huang.wen.long@hotmail.com",
"download_url": "https://files.pythonhosted.org/packages/60/88/7800a04be91c9e259f8ed8d543af0b252986abd043e9edf6b8db93b86a2b/nonebot_plugin_gocqhttp_cross_machine_upload_file-0.1.5.tar.gz",
"platform": null,
"description": "nonebot-plugin-gocqhttp-cross-machine-upload-file\n========\n\n\u4e3ago-cqhttp\u4e0enonebot\u90e8\u7f72\u4e8e\u4e0d\u540c\u673a\u5668\u7684\u7cfb\u7edf\u63d0\u4f9b\u4e0a\u4f20\u7fa4\u6587\u4ef6\u3001\u79c1\u804a\u6587\u4ef6\u7684\u80fd\u529b\u3002\n\n**\u53ea\u9002\u7528\u4e8eFastAPI\u53cd\u5411\u9a71\u52a8\u5668**\n\n## \u7528\u6cd5\n\n```python\nfrom io import StringIO\n\nfrom nonebot import on_startswith, require\nfrom nonebot.adapters.onebot.v11 import Bot, MessageEvent\n\nrequire(\"nonebot_plugin_gocqhttp_cross_machine_upload_file\")\n\nfrom nonebot_plugin_gocqhttp_cross_machine_upload_file import upload_file\n\n\n@on_startswith(\"test\").handle()\nasync def handle(bot: Bot, event: MessageEvent):\n # \u4e0a\u4f20\u6307\u5b9a\u8def\u5f84\u6587\u4ef6\n await upload_file(bot, event, \"image.png\", path=\"image.png\")\n\n # \u4e0a\u4f20\u6253\u5f00\u7684IO\u6d41\n with StringIO() as f:\n f.write(\"Hello World\")\n f.seek(0)\n await upload_file(bot, event, \"hello.txt\", f)\n\n # \u4e0a\u4f20bytes\n await upload_file(bot, event, \"hello.txt\", \"Hello World\".encode())\n```\n\n\n## \u914d\u7f6e\n\n### callback_host\n\n\u56de\u8c03HOST\uff0c\u8bbe\u7f6e\u4e3anonebot\u6240\u5728\u7684\u4e3b\u673a\u540d/IP\u3002\u52a1\u5fc5\u4fdd\u8bc1go-cqhttp\u6240\u5728\u4e3b\u673a\u53ef\u8bbf\u95ee\uff0c\u7528\u4e8e\u8ba9go-cqhttp\u4e0b\u8f7d\u672c\u673a\u6587\u4ef6\u3002\n\n\u9ed8\u8ba4\u503c\uff1a127.0.0.1\n\n### callback_port\n\n\u56de\u8c03\u7aef\u53e3\uff0c\u4fdd\u6301\u9ed8\u8ba4\u503c\u5373\u53ef\u3002\n\n\u9ed8\u8ba4\u503c\uff1a\u4e0ePORT\u4fdd\u6301\u4e00\u81f4\u5373\u53ef",
"bugtrack_url": null,
"license": "MIT",
"summary": "",
"version": "0.1.5",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "09acf0e4007625ac21d97342fd6b88e5d65b61f9a29d6fe43f2dad9c7f3c7874",
"md5": "f2cca643c9f5519c97d47c1c0f3c3c34",
"sha256": "ce84fe33e70871875ea0dc70922f6b05cdbb741372581e855eebf1ae0554b636"
},
"downloads": -1,
"filename": "nonebot_plugin_gocqhttp_cross_machine_upload_file-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f2cca643c9f5519c97d47c1c0f3c3c34",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 4476,
"upload_time": "2023-05-31T13:54:02",
"upload_time_iso_8601": "2023-05-31T13:54:02.853129Z",
"url": "https://files.pythonhosted.org/packages/09/ac/f0e4007625ac21d97342fd6b88e5d65b61f9a29d6fe43f2dad9c7f3c7874/nonebot_plugin_gocqhttp_cross_machine_upload_file-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "60887800a04be91c9e259f8ed8d543af0b252986abd043e9edf6b8db93b86a2b",
"md5": "cb8853b0e9537ab26294ee33d00ad1c6",
"sha256": "1d0b3551748d47e75dc00ff2ef3851acd158655cfcd599731898857aa205d576"
},
"downloads": -1,
"filename": "nonebot_plugin_gocqhttp_cross_machine_upload_file-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "cb8853b0e9537ab26294ee33d00ad1c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 3109,
"upload_time": "2023-05-31T13:54:04",
"upload_time_iso_8601": "2023-05-31T13:54:04.441296Z",
"url": "https://files.pythonhosted.org/packages/60/88/7800a04be91c9e259f8ed8d543af0b252986abd043e9edf6b8db93b86a2b/nonebot_plugin_gocqhttp_cross_machine_upload_file-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-31 13:54:04",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nonebot-plugin-gocqhttp-cross-machine-upload-file"
}