Skip to main content
NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-gold-price

✨ 查询实时金价 ✨

license pypi python

🤔为什么会有该插件

一个发小想买黄金, 650的时候没买, 总说会跌,现在700多了, 还是没买, 仍然说会跌, 于是有了该插件, 让他能够随时后悔

📖 介绍

查询实时金价;存储查询时的金价到数据库中;绘制历史价格走势对比图;设置价格预警阈值(没什么用);定时推送群聊金价

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-gold-price
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-gold-price
pdm
pdm add nonebot-plugin-gold-price
poetry
poetry add nonebot-plugin-gold-price
conda
conda install nonebot-plugin-gold-price

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_gold_price"]

⚙️ 配置

在 nonebot2 项目的.env文件中添加下表中的必填配置

配置项 必填 默认值 说明
gold_api_token 是 无 金价查询的API令牌,TOKEN申请地址
gold_api_interval 否 1 API请求间隔(秒)
gold_default_days 否 30 默认查询历史天数
gold_threshold_high 否 800 上预警阈值
gold_threshold_low 否 650 下预警阈值
gold_target_groups 否 无 定时推送的群号列表,例["123", "456"]
gold_schedule_hour 否 18 定时任务的小时
gold_schedule_minute 否 30 定时任务的分钟
gold_chart_font 否 "" 渲染图表时的字体,支持系统字体名称或字体文件路径(如:'Microsoft YaHei' 或 './fonts/MiSans-Regular.ttf'),若不配置会自动尝试系统中存在的中文字体

🎉 使用

Tips: 别忘了命令前缀,图中没有前缀是因为我使用了空前缀,如果您使用nonebot2的默认配置,应使用"/"前缀,例如"/金价"

指令表

指令 权限 需要@ 范围 说明
金价 群员 否 群聊 查询实时金价,并返回默认查询历史天数的价格折线图
金价 x天 群员 否 群聊 查询实时金价,并返回历史x天的价格折线图
金价 x年 群员 否 群聊 查询实时金价,并返回历史x年的价格折线图,可为浮点数,例0.1

效果图

image1 image2

更新计划

  • 增加"补充历史数据"的功能(#1)

更新日志

0.3.0

  • 图表绘制改用 matplotlib.figure.Figure + FigureCanvasAgg,彻底脱离 pyplot 全局状态,命令查询与定时任务并发触发时不再有竞态
  • 现代化图表样式:双色(靛蓝 / 琥珀)折线、上/右 spine 去除、横向轻量网格、关键点(最新价 / 最高 / 最低)自动标注、折线下渐变填充
  • 字体处理改为返回 FontProperties 注入到各个绘图调用,不再污染 rcParams
  • 抽取 _dispatch_report 等辅助函数,消除 send_price_report 与 daily_report 的重复流程
  • get_bot() 改为 _safe_get_bot():bot 未连接时记录日志而非抛栈,定时任务对单群推送失败做异常隔离
  • 接入 nonebot.log.logger 替代静默 pass,关键路径的失败可见
  • 补充类型注解、统一市场名称映射 MARKET_DISPLAY

0.2.0

  • 修复跨主机部署时图片落盘后协议端无法读取的问题,改为完全在内存中生成图表并通过 base64 直接发送
  • 升级 aiohttp 超时配置为 ClientTimeout,避免后续版本的弃用警告
  • 代码清理:将 re 模块的导入提到文件顶部

0.1.9

  • 修复配置错误的BUG(#1)

0.1.8

  • 增加自定义渲染字体功能

0.1.7

  • API返回0价格时使用上次非零数据,可能在节假日发生

Metadata

Release files for nonebot-plugin-gold-price 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-gold-price 0.3.0
File Size Uploaded Provenance Actions
nonebot_plugin_gold_price-0.3.0.tar.gz 25.9 kB Without provenance Details for nonebot_plugin_gold_price-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-gold-price 0.3.0
File Interpreter ABI Platform Actions
nonebot_plugin_gold_price-0.3.0-py3-none-any.whl Python 3 none any Details for nonebot_plugin_gold_price-0.3.0-py3-none-any.whl

Total release size: 50.2 kB

Release files / nonebot_plugin_gold_price-0.3.0.tar.gz

Download URL nonebot_plugin_gold_price-0.3.0.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1351c3bd496bcc73180615c9570b45958500da37a8823766cf1c7d552a0100df
BLAKE2b-256 checksum
How to use checksums
23080711a8300bd3f210b051cf49c83e37c5c1b40666daf2f8a9d6306d2c7f0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / nonebot_plugin_gold_price-0.3.0-py3-none-any.whl

Download URL nonebot_plugin_gold_price-0.3.0-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8aad8c5535160a2fe278295b37eb8073a7692ad02861c9a4ceb80eabf4d04b11
BLAKE2b-256 checksum
How to use checksums
0998092e5444a7dbdd65925fc5c2a19addaafc83d5082a1e815da335c89695e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for nonebot-plugin-gold-price 0.3.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page