简介
本插件提供 sm.ms 图床的上传、删除、查询上传历史功能。
安装
使用 nb-cli 安装(推荐)
nb plugin install nonebot-plugin-smms
使用 pip 安装
pip install nonebot-plugin-smms
需要在 bot 根目录 pyproject.toml 文件中 [tool.nonebot] 部分添加:
plugins = ["nonebot_plugin_smms"]
Driver 设置
需要参考 driver 配置项,添加 HTTPClient 支持(如 ~httpx),在对应 env 文件(如 .env .env.prod)中,根据所用适配器的要求进行如下配置:
DRIVER=~fastapi+~httpx
DRIVER=~httpx+~websockets
插件环境配置
在对应 env 文件(如 .env .env.prod)中,可以设置如下参数。
sm.ms API token:
SMMS_API_URL="https://smms.app/api/v2"
替换默认 sm.ms API 地址(https://sm.ms/api/v2):
SMMS_TOKEN="your_token"
使用说明
如需在其他插件中使用上传图片等功能,可以从本插件导入。
导入方式:
from nonebot import require
require("nonebot_plugin_smms")
from nonebot_plugin_smms import SMMS
基本使用方式(以 QQ 适配器为例):
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("图片上传失败")
Metadata
Release files for nonebot-plugin-smms 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nonebot_plugin_smms-0.1.0.tar.gz | 4.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nonebot_plugin_smms-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / nonebot_plugin_smms-0.1.0.tar.gz
| Download URL | nonebot_plugin_smms-0.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f568fda6f796198b72a1e621664db432875a6d1b4e288491182b32c6ef9b1f6c
|
|
BLAKE2b-256 checksum How to use checksums |
56366268cce37832a72e9ac65d36df810b494d75b1e042ffa52b986624fee439
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.10 Windows/10
|
Release files / nonebot_plugin_smms-0.1.0-py3-none-any.whl
| Download URL | nonebot_plugin_smms-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
757da94071aebc2bbef079e47f46e4cd879756662489c387a746a73eb9627f1d
|
|
BLAKE2b-256 checksum How to use checksums |
15cdef41f5fe7afe52d8e8317c370db7689abd3c2231d00f62c5676e55080a02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.0 CPython/3.10.10 Windows/10
|
Security for nonebot-plugin-smms 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.