适用于 NoneBot2 的词云插件
Project description
NoneBot Plugin WordCloud
✨ NoneBot 词云插件 ✨
安装
nb plugin install nonebot-plugin-wordcloud
Note
如需通过命令设置词云形状,则需使用支持 http 请求的驱动器,如 httpx 和 aiohttp。
请参考 配置驱动器 文档进行设置。
例如:
DRIVER=~httpx
DRIVER=~aiohttp
DRIVER=~fastapi+~httpx
命令
- 查看帮助
待插件启动完成后,发送 /词云 可获取插件使用方法。
- 查看词云
| 功能 | 命令 | 权限 | 说明 |
|---|---|---|---|
| 查看今日词云 | /今日词云 |
所有人 | 获取今日的词云 |
| 查看昨日词云 | /昨日词云 |
所有人 | 获取昨日的词云 |
| 查看本周词云 | /本周词云 |
所有人 | 获取本周的词云 |
| 查看上周词云 | /上周词云 |
所有人 | 获取上周的词云 |
| 查看本月词云 | /本月词云 |
所有人 | 获取本月的词云 |
| 查看上月词云 | /上月词云 |
所有人 | 获取上月的词云 |
| 查看年度词云 | /年度词云 |
所有人 | 获取年度的词云 |
| 查看历史词云 | /历史词云 |
所有人 | 获取指定时间段的词云 |
数据范围说明:
-
当
wordcloud_default_personal配置为False(默认)时,上述命令默认获取群组数据 -
当
wordcloud_default_personal配置为True时,上述命令默认获取个人数据 -
可以使用前缀明确指定数据范围:
- 添加
我的前缀获取个人词云,如/我的今日词云 - 添加
本群前缀获取群组词云,如/本群今日词云
- 添加
-
管理词云
| 功能 | 命令 | 权限 | 说明 |
|---|---|---|---|
| 设置词云形状 | /设置词云形状 |
超级用户/群主/管理员 | 发送一张图片作为当前群词云形状,每个群各自独立 |
| 删除词云形状 | /删除词云形状 |
超级用户/群主/管理员 | 删除本群词云形状 |
| 设置词云默认形状 | /设置词云默认形状 |
超级用户 | 发送一张图片作为所有词云的默认形状,每个群都会改变 |
| 删除词云默认形状 | /删除词云默认形状 |
超级用户 | 删除默认词云形状,继续使用词云默认的矩形 |
| 开启词云定时发送 | /开启词云<类型>定时发送 或/开启词云<类型>定时发送 + [时间] |
超级用户/群主/管理员 | 开启本群定时发送词云,类型支持 每日、每周、每月、每年。默认发送上一完整周期:每日发送昨日词云;每周在周一发送上周词云;每月在 1 日发送上月词云;每年在 1 月 1 日发送去年词云。添加 --last 或使用 开启词云每周周期末定时发送 这样的快捷命令,可在周期最后一天发送截至触发时间的词云;添加 --complete 或使用 开启词云每周完整周期定时发送 可显式使用完整周期模式。没有指定模式时使用 wordcloud_default_schedule_mode。没有指定时间时,完整周期默认在 00:00 发送,周期末默认在 23:59:59 发送;如果配置了 wordcloud_default_schedule_time,则使用该配置。如果时间没有包含时区信息,则根据 wordcloud_timezone 配置项确定时区。时间的格式为 ISO 8601,例如: 开启词云每周定时发送 23:59:59 |
| 关闭词云定时发送 | /关闭词云<类型>定时发送 |
超级用户/群主/管理员 | 关闭本群指定类型的词云定时发送 |
| 查看词云定时发送状态 | /词云<类型>定时发送状态 |
超级用户/群主/管理员 | 查看指定类型的定时发送状态 |
配置项
配置方式:直接在 NoneBot 全局配置文件(.env) 中添加以下配置项
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| wordcloud_width | int | 1920 |
生成图片的宽度 |
| wordcloud_height | int | 1200 |
生成图片的高度 |
| wordcloud_background_color | str | black |
生成图片的背景颜色 |
| wordcloud_colormap | Union[str, List[str]] | viridis |
生成图片的字体 色彩映射表(当值为列表时会随机选择其中之一) |
| wordcloud_font_path | str | 自带的字体(思源黑体) | 生成图片的字体文件位置 |
| wordcloud_stopwords_path | str | None | 结巴分词的 停用词表 位置, 用来屏蔽某些词语 例如: "./wordcloud_extra_dict/stopword.txt"表示屏蔽 stopword.txt 中的词语, 格式参考 stop_words.txt |
| wordcloud_userdict_path | str | None | 结巴分词的自定义词典 位置 |
| wordcloud_timezone | str | None | 用户自定义的 时区, 留空则使用系统时区,具体数值可参考:时区列表, 例如: Asia/Shanghai |
| wordcloud_default_schedule_mode | str | 完整周期 |
默认定时发送模式,可选 完整周期 或 周期末 |
| wordcloud_default_schedule_time | str | 根据发送模式决定 | 默认定时发送时间,当开启词云定时发送时没有提供具体时间,将会在这个时间发送词云。 未配置时,完整周期默认为 00:00,周期末默认为 23:59:59;配置后会覆盖所有默认发送模式的时间 |
| wordcloud_options | Dict[str, Any] |
{} |
向 WordCloud 传递的参数。 拥有最高优先级,将会覆盖以上词云的配置项, 例如: {"background_color":"black","max_words":2000,"contour_width":3, "contour_color":"steelblue"} |
| wordcloud_exclude_user_ids | Set[str] |
set() |
排除的用户 ID 列表(全局,不区分平台), 例如: ["123456","456789"] |
| wordcloud_reply_message | bool | False |
发送词云图片时是否回复触发它的消息 |
| wordcloud_default_personal | bool | False |
是否默认获取个人数据,设为 True 时默认生成个人词云,设为 False 时默认生成群组词云 |
许可证
项目代码使用 MIT License 发布。包内自带的默认字体 SourceHanSans.otf
来自 Source Han Sans,
按 SIL Open Font License 1.1 许可随包分发;完整字体许可证见
nonebot_plugin_wordcloud/SourceHanSans.LICENSE.txt。
鸣谢
插件依赖 nonebot-plugin-chatrecorder 提供消息存储。
感谢以下开发者作出的贡献:
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_wordcloud-0.10.0.tar.gz.
File metadata
- Download URL: nonebot_plugin_wordcloud-0.10.0.tar.gz
- Upload date:
- Size: 7.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6a6d3c7508e5f875b0ccf3113b78cafcc15457bfceef90a215beff84f6f7bb0
|
|
| MD5 |
758fa87d9312799669a4332ab10c41f8
|
|
| BLAKE2b-256 |
d755b69a1f24eb06f7884736d80727c936ac8a9095840132de3c53eaa9e53f21
|
Provenance
The following attestation bundles were made for nonebot_plugin_wordcloud-0.10.0.tar.gz:
Publisher:
release.yml on he0119/nonebot-plugin-wordcloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_wordcloud-0.10.0.tar.gz -
Subject digest:
f6a6d3c7508e5f875b0ccf3113b78cafcc15457bfceef90a215beff84f6f7bb0 - Sigstore transparency entry: 1628040685
- Sigstore integration time:
-
Permalink:
he0119/nonebot-plugin-wordcloud@e56c62fe37712ef35244bc9dc6c1d5b63ea2ffdb -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/he0119
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e56c62fe37712ef35244bc9dc6c1d5b63ea2ffdb -
Trigger Event:
push
-
Statement type:
File details
Details for the file nonebot_plugin_wordcloud-0.10.0-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_wordcloud-0.10.0-py3-none-any.whl
- Upload date:
- Size: 7.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e6d24dcf985a65e45f23176f5954ea00600e7469d6a4777f0120d12953183a
|
|
| MD5 |
6b8afac609acb629e02bd041f37f4eff
|
|
| BLAKE2b-256 |
8de59cf779078831077e3de5609855ccfdd3c29be9a5aab82f20befd74190a6d
|
Provenance
The following attestation bundles were made for nonebot_plugin_wordcloud-0.10.0-py3-none-any.whl:
Publisher:
release.yml on he0119/nonebot-plugin-wordcloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nonebot_plugin_wordcloud-0.10.0-py3-none-any.whl -
Subject digest:
34e6d24dcf985a65e45f23176f5954ea00600e7469d6a4777f0120d12953183a - Sigstore transparency entry: 1628040688
- Sigstore integration time:
-
Permalink:
he0119/nonebot-plugin-wordcloud@e56c62fe37712ef35244bc9dc6c1d5b63ea2ffdb -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/he0119
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e56c62fe37712ef35244bc9dc6c1d5b63ea2ffdb -
Trigger Event:
push
-
Statement type: