<!-- markdownlint-disable MD033 MD036 MD041-->
<div align="center">
# nonebot-plugin-smms
_✨ sm.ms 图床插件 ✨_
</div>
<p align="center">
<a href="https://raw.githubusercontent.com/mobyw/nonebot-plugin-smms/master/LICENSE">
<img src="https://img.shields.io/github/license/mobyw/nonebot-plugin-smms.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-smms">
<img src="https://img.shields.io/pypi/v/nonebot-plugin-smms.svg" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
</p>
## 简介
本插件提供 [sm.ms](https://sm.ms/) 图床的上传、删除、查询上传历史功能。
## 安装
### 使用 `nb-cli` 安装(推荐)
```bash
nb plugin install nonebot-plugin-smms
```
### 使用 `pip` 安装
```bash
pip install nonebot-plugin-smms
```
需要在 bot 根目录 `pyproject.toml` 文件中 [tool.nonebot] 部分添加:
```python
plugins = ["nonebot_plugin_smms"]
```
## Driver 设置
需要参考 [driver](https://nonebot.dev/docs/appendices/config#driver) 配置项,添加 `HTTPClient` 支持(如 `~httpx`),在对应 env 文件(如 `.env` `.env.prod`)中,根据所用适配器的要求进行如下配置:
```text
DRIVER=~fastapi+~httpx
```
```text
DRIVER=~httpx+~websockets
```
## 插件环境配置
在对应 env 文件(如 `.env` `.env.prod`)中,可以设置如下参数。
sm.ms API token:
```text
SMMS_API_URL="https://smms.app/api/v2"
```
替换默认 sm.ms API 地址(https://sm.ms/api/v2):
```text
SMMS_TOKEN="your_token"
```
## 使用说明
如需在其他插件中使用上传图片等功能,可以从本插件导入。
导入方式:
```python
from nonebot import require
require("nonebot_plugin_smms")
from nonebot_plugin_smms import SMMS
```
基本使用方式(以 QQ 适配器为例):
```python
smms = SMMS()
image = ... # bytes, BytesIO, Path
file = await smms.upload(image)
if file:
await matcher.send(MessageSegment.image(file.url))
await smms.delete(file.hash)
await matcher.finish("图片上传并删除成功")
else:
await matcher.finish("图片上传失败")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/mobyw/nonebot-plugin-smms",
"name": "nonebot-plugin-smms",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "nonebot2,qq,plugin",
"author": "mobyw",
"author_email": "mobyw66@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/56/36/6268cce37832a72e9ac65d36df810b494d75b1e042ffa52b986624fee439/nonebot_plugin_smms-0.1.0.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable MD033 MD036 MD041-->\n<div align=\"center\">\n\n# nonebot-plugin-smms\n\n_\u2728 sm.ms \u56fe\u5e8a\u63d2\u4ef6 \u2728_\n\n</div>\n\n<p align=\"center\">\n <a href=\"https://raw.githubusercontent.com/mobyw/nonebot-plugin-smms/master/LICENSE\">\n <img src=\"https://img.shields.io/github/license/mobyw/nonebot-plugin-smms.svg\" alt=\"license\">\n </a>\n <a href=\"https://pypi.python.org/pypi/nonebot-plugin-smms\">\n <img src=\"https://img.shields.io/pypi/v/nonebot-plugin-smms.svg\" alt=\"pypi\">\n </a>\n <img src=\"https://img.shields.io/badge/python-3.8+-blue.svg\" alt=\"python\">\n</p>\n\n## \u7b80\u4ecb\n\n\u672c\u63d2\u4ef6\u63d0\u4f9b [sm.ms](https://sm.ms/) \u56fe\u5e8a\u7684\u4e0a\u4f20\u3001\u5220\u9664\u3001\u67e5\u8be2\u4e0a\u4f20\u5386\u53f2\u529f\u80fd\u3002\n\n## \u5b89\u88c5\n\n### \u4f7f\u7528 `nb-cli` \u5b89\u88c5\uff08\u63a8\u8350\uff09\n\n```bash\nnb plugin install nonebot-plugin-smms\n```\n\n### \u4f7f\u7528 `pip` \u5b89\u88c5\n\n```bash\npip install nonebot-plugin-smms\n```\n\n\u9700\u8981\u5728 bot \u6839\u76ee\u5f55 `pyproject.toml` \u6587\u4ef6\u4e2d [tool.nonebot] \u90e8\u5206\u6dfb\u52a0\uff1a\n\n```python\nplugins = [\"nonebot_plugin_smms\"]\n```\n\n## Driver \u8bbe\u7f6e\n\n\u9700\u8981\u53c2\u8003 [driver](https://nonebot.dev/docs/appendices/config#driver) \u914d\u7f6e\u9879\uff0c\u6dfb\u52a0 `HTTPClient` \u652f\u6301\uff08\u5982 `~httpx`\uff09\uff0c\u5728\u5bf9\u5e94 env \u6587\u4ef6\uff08\u5982 `.env` `.env.prod`\uff09\u4e2d\uff0c\u6839\u636e\u6240\u7528\u9002\u914d\u5668\u7684\u8981\u6c42\u8fdb\u884c\u5982\u4e0b\u914d\u7f6e\uff1a\n\n```text\nDRIVER=~fastapi+~httpx\n```\n\n```text\nDRIVER=~httpx+~websockets\n```\n\n## \u63d2\u4ef6\u73af\u5883\u914d\u7f6e\n\n\u5728\u5bf9\u5e94 env \u6587\u4ef6\uff08\u5982 `.env` `.env.prod`\uff09\u4e2d\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u5982\u4e0b\u53c2\u6570\u3002\n\nsm.ms API token:\n\n```text\nSMMS_API_URL=\"https://smms.app/api/v2\"\n```\n\n\u66ff\u6362\u9ed8\u8ba4 sm.ms API \u5730\u5740\uff08https://sm.ms/api/v2\uff09:\n\n```text\nSMMS_TOKEN=\"your_token\"\n```\n\n## \u4f7f\u7528\u8bf4\u660e\n\n\u5982\u9700\u5728\u5176\u4ed6\u63d2\u4ef6\u4e2d\u4f7f\u7528\u4e0a\u4f20\u56fe\u7247\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u4ece\u672c\u63d2\u4ef6\u5bfc\u5165\u3002\n\n\u5bfc\u5165\u65b9\u5f0f\uff1a\n\n```python\nfrom nonebot import require\nrequire(\"nonebot_plugin_smms\")\nfrom nonebot_plugin_smms import SMMS\n```\n\n\u57fa\u672c\u4f7f\u7528\u65b9\u5f0f\uff08\u4ee5 QQ \u9002\u914d\u5668\u4e3a\u4f8b\uff09\uff1a\n\n```python\nsmms = SMMS()\nimage = ... # bytes, BytesIO, Path\nfile = await smms.upload(image)\nif file:\n await matcher.send(MessageSegment.image(file.url))\n await smms.delete(file.hash)\n await matcher.finish(\"\u56fe\u7247\u4e0a\u4f20\u5e76\u5220\u9664\u6210\u529f\")\nelse:\n await matcher.finish(\"\u56fe\u7247\u4e0a\u4f20\u5931\u8d25\")\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "sm.ms \u56fe\u5e8a\u63d2\u4ef6",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/mobyw/nonebot-plugin-smms/blob/main/README.md",
"Homepage": "https://github.com/mobyw/nonebot-plugin-smms",
"Repository": "https://github.com/mobyw/nonebot-plugin-smms"
},
"split_keywords": [
"nonebot2",
"qq",
"plugin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "15cdef41f5fe7afe52d8e8317c370db7689abd3c2231d00f62c5676e55080a02",
"md5": "2818d2f9346c98fd21392298eb3d61bd",
"sha256": "757da94071aebc2bbef079e47f46e4cd879756662489c387a746a73eb9627f1d"
},
"downloads": -1,
"filename": "nonebot_plugin_smms-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2818d2f9346c98fd21392298eb3d61bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 5779,
"upload_time": "2023-11-23T15:24:16",
"upload_time_iso_8601": "2023-11-23T15:24:16.507383Z",
"url": "https://files.pythonhosted.org/packages/15/cd/ef41f5fe7afe52d8e8317c370db7689abd3c2231d00f62c5676e55080a02/nonebot_plugin_smms-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "56366268cce37832a72e9ac65d36df810b494d75b1e042ffa52b986624fee439",
"md5": "d13b0f9ab8719382c234390f924dd73b",
"sha256": "f568fda6f796198b72a1e621664db432875a6d1b4e288491182b32c6ef9b1f6c"
},
"downloads": -1,
"filename": "nonebot_plugin_smms-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "d13b0f9ab8719382c234390f924dd73b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 4770,
"upload_time": "2023-11-23T15:24:18",
"upload_time_iso_8601": "2023-11-23T15:24:18.039532Z",
"url": "https://files.pythonhosted.org/packages/56/36/6268cce37832a72e9ac65d36df810b494d75b1e042ffa52b986624fee439/nonebot_plugin_smms-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-23 15:24:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mobyw",
"github_project": "nonebot-plugin-smms",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nonebot-plugin-smms"
}