Skip to main content

用于查询实时金价、绘制历史金价的NoneBot2插件

Project description

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.2.0

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

0.1.9

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

0.1.8

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

0.1.7

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

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_gold_price-0.2.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_gold_price-0.2.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_gold_price-0.2.0.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_gold_price-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e9c1a1a6ba4259484f7d78641330ec2ae10a924cdae5d3a1fb3f57c5026bd895
MD5 46ec2bdfed627c1a8f578fe84a03ce0b
BLAKE2b-256 a6d92975d33d04c63a56cd4b86536c13aaba70d84857bd42a2615d985fe0a06b

See more details on using hashes here.

File details

Details for the file nonebot_plugin_gold_price-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_gold_price-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73dfc393537f826b856a7637e5000d28763bb72156b3a9a535083a19234a4e50
MD5 48b4ea73411d6c3c060875541ec91a57
BLAKE2b-256 aa194106bec8b827845cc2756b55dae62e4a6fa886cb286d2a1a2301b33788af

See more details on using hashes here.

Supported by

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