Skip to main content

sm.ms 图床插件

Project description

nonebot-plugin-smms

✨ sm.ms 图床插件 ✨

license pypi python

简介

本插件提供 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("图片上传失败")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_smms-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

nonebot_plugin_smms-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_smms-0.1.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_smms-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Windows/10

File hashes

Hashes for nonebot_plugin_smms-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f568fda6f796198b72a1e621664db432875a6d1b4e288491182b32c6ef9b1f6c
MD5 d13b0f9ab8719382c234390f924dd73b
BLAKE2b-256 56366268cce37832a72e9ac65d36df810b494d75b1e042ffa52b986624fee439

See more details on using hashes here.

File details

Details for the file nonebot_plugin_smms-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_smms-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 757da94071aebc2bbef079e47f46e4cd879756662489c387a746a73eb9627f1d
MD5 2818d2f9346c98fd21392298eb3d61bd
BLAKE2b-256 15cdef41f5fe7afe52d8e8317c370db7689abd3c2231d00f62c5676e55080a02

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page