轻量文字转图片插件
Project description
nonebot-plugin-txt2img
✨ 轻量文字转图片插件 ✨
简介
本插件由使用 PIL(Pillow)
库将纯文字消息转为图片,启动时会检测所需资源是否存在,若不存在会自动下载到对应位置。生成的图片以 base64
格式发送,不保存到磁盘。
安装步骤
安装 NoneBot2
完整文档可以在 这里 查看。
请在创建项目时选用 onebot v11
适配器,并且按照文档完成最小实例的创建。
安装 nonebot-plugin-txt2img
使用 nb-cli
安装
nb plugin install nonebot-plugin-txt2img
使用 pip
安装
pip install nonebot-plugin-txt2img
需要在 bot.py
文件添加以下代码加载插件:
nonebot.load_plugin("nonebot_plugin_txt2img")
指令说明
指令匹配方式添加了 to_me()
规则,在群聊中使用时需要在命令首部或尾部添加 @机器人 (@{bot_self_id}
) 或 机器人昵称 ({bot_nickname}
)。
使用指令:txt2img
发送指令后根据提示输入标题、内容与字体大小,即可完成图片生成。
- 标题:以
1.5
倍字体大小排版在首行居中位置。 - 内容:以
1
倍字体大小左对齐排版。 - 字体大小:位于
10~120
之间的数字。
跨插件使用
如需在其他插件中使用文本转图片功能,可以从本插件导入。
导入方式:
from nonebot.adapters.onebot.v11 import MessageSegment
from nonebot_plugin_txt2img import Txt2Img
使用方式:
font_size = 32
# 标题设置为 '' 或 ' ' 可以去除标题行
title = '标题'
text = '正文内容'
img = Txt2Img(font_size)
pic = img.save(title, text)
msg = MessageSegment.image(pic)
项目致谢
本项目基于以下项目或服务实现,排名不分先后。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for nonebot-plugin-txt2img-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa966ceaaeb96edf1977a310857808fbf72bc91b21162c9e8f29168a5d031808 |
|
MD5 | 1fdbb5f38448a99f3cada8db58d91756 |
|
BLAKE2b-256 | efc0c88696376c6299e8886556c5fdd94b1d1a3a651c4b01c4f5fe0672ecedd6 |
Close
Hashes for nonebot_plugin_txt2img-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f422504ffe8d91e1b74bbc835b5f6c33a9f222f5be3b607c31b7bcd155a5375 |
|
MD5 | b031637a4a6d7574d06685c671ff1aa0 |
|
BLAKE2b-256 | 7d9c997cc08146cf1ad3087d50e14d6fa856b3f453c7cd2d2eda3f2e7ee3f514 |