Skip to main content
logo

✨ nonebot-plugin-sues-bill ✨

LICENSE pypi python uv
ruff pre-commit

📖 介绍

SUES 校园服务插件,支持查询上海工程技术大学电费和校园卡余额。

主要功能:

  • 🔌 电费查询 — 查询宿舍剩余电量,定时宿舍可独立设置
  • 💳 电费充值 — 从校园卡余额直接为宿舍充值电费
  • 📊 耗电历史 — 自动结算昨日耗电量,支持最近 N 天统计与缴费流水校正
  • 💳 校园卡查询 — 查询校园卡账户余额和冻结余额

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-sues-bill --upgrade

使用 pypi 源安装

nb plugin install nonebot-plugin-sues-bill --upgrade -i "https://pypi.org/simple"

使用清华源安装

nb plugin install nonebot-plugin-sues-bill --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
uv
uv add nonebot-plugin-sues-bill

安装仓库 master 分支

uv add git+https://github.com/noel-psc/nonebot-plugin-sues-bill@main
pdm
pdm add nonebot-plugin-sues-bill

安装仓库 master 分支

pdm add git+https://github.com/noel-psc/nonebot-plugin-sues-bill@main
poetry
poetry add nonebot-plugin-sues-bill

安装仓库 master 分支

poetry add git+https://github.com/noel-psc/nonebot-plugin-sues-bill@main

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

plugins = ["nonebot_plugin_sues_bill"]
使用 nbr 安装(使用 uv 管理依赖可用)

nbr 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2

nbr plugin install nonebot-plugin-sues-bill

使用 pypi 源安装

nbr plugin install nonebot-plugin-sues-bill -i "https://pypi.org/simple"

使用清华源安装

nbr plugin install nonebot-plugin-sues-bill -i "https://pypi.tuna.tsinghua.edu.cn/simple"

⚙️ 配置

在 nonebot2 项目的.env文件中添加下表中的配置项(可选)

配置项 必填 默认值 说明
sues_base_url 否 https://epay.sues.edu.cn SUES 一卡通系统地址
sues_electricity_price_per_kwh 否 0.617 每度电价格(元),用于计算昨日电费

🎉 使用

指令表

电费查询

指令 权限 需要@ 范围 说明
#电费 群员 否 私聊/群聊 即时查询记录宿舍的当前余额
#电费 区域 楼栋 房间号 群员 否 私聊/群聊 即时查询指定宿舍,不修改定时设置
#电费 缴费 区域 楼栋 房间号 金额 群员 否 私聊/群聊 从校园卡余额为指定宿舍充值电费
#电费 记录 区域 楼栋 房间号 群员 否 私聊/群聊 设置或修改自动日结宿舍
#电费 统计 0 群员 否 私聊/群聊 查询今天截至当前的耗电估算
#电费 统计 [天数] 群员 否 私聊/群聊 查询指定天数已结束自然日的耗电统计,省略时为 30 天
#电费 记录 状态 群员 否 私聊/群聊 查看当前宿舍和账户校正状态
#电费 记录 停止 群员 否 私聊/群聊 停止自动日结,保留历史记录
#电费 记录 绑定 群员 否 私聊/群聊 将已设置校园卡账户绑定到当前记录宿舍
#电费 记录 解绑 群员 否 私聊/群聊 停止使用校园卡缴费流水校正
#电费 管理 读数 区域 楼栋 房间号 日期 [时间] 剩余电量 管理员 否 私聊/群聊 手动录入日界读数并重算前一日
#电费 管理 缴费 区域 楼栋 房间号 日期 [时间] 金额 管理员 否 私聊/群聊 手动录入缴费并重算该日
#电费帮助 群员 否 私聊/群聊 查看电费查询帮助
#电费详细帮助 群员 否 私聊/群聊 查看详细参数说明
支持的区域和楼栋

三期学生公寓:10-26栋 四期学生公寓:20、21、23、24、27-30、33-36、39-42栋

示例:

#电费 三期 21 1001
#电费 四期 28 1021

昨日耗电

先使用 #电费 记录 三期 21 1001 设置宿舍。每天会在上海时区 00:00 查询一次剩余电量,并结算前一自然日的耗电量和电费。同一宿舍被多个用户设置时仍只会查询一次。

每次成功执行 #电费 查询都会记录查询时间、宿舍和当前余额,但不会覆盖日界快照。

  • 已设置校园卡账号后,发送 #电费 记录 绑定 才会读取当天成功的“电费缴费”流水,按 昨日 00:00 余额 + 缴费购电量 - 今日 00:00 余额 校正耗电量。一个校园卡账户只能绑定一个宿舍,一个宿舍也只能绑定一个校园卡账户。
  • 未绑定账户时,按两次余额差显示估算值;若发现余额增加,会提示当天可能发生缴费,且该日不计入统计。
  • 首次记录需要等待两个日界快照后才能得到昨日耗电。
  • 为降低对学校系统的集中访问,日界采样会有最多十分钟的边界误差。

发送 #电费 统计 0 可按今日首次和最新查询余额查看截至当前的耗电估算;至少需要两次成功查询,若余额增加则会提示当天可能已缴费。该估算不会写入日结数据。

发送 #电费 统计 [天数] 可查看指定数量已结束自然日的总耗电、日均、最高耗电日及准确性统计;省略时默认为 30,回复会按实际已记录天数显示。例如:#电费 统计7天。

机器人回复会遮蔽房间号,避免在群聊中泄露宿舍隐私。管理员可使用 #电费 管理 读数/缴费 区域 楼栋 房间号 日期 [时间] 数值 手动补录;时间可省略,默认 00:00。手动读数会作为该日期的日界快照并重算前一日,手动缴费会参与该日结算。

电费充值

先私聊设置校园卡账号(#设置校园卡账号 学号 密码),再发送 #电费 缴费 区域 楼栋 房间号 金额 发起缴费,机器人会返回待确认提示;回复 #电费 缴费 确认 才从校园卡余额扣除,#电费 缴费 取消 放弃(5 分钟内有效)。无需额外密码,例如:

#电费 缴费 三期 21 1001 50
→ 即将为三期2*栋1001 充值 50.00 元,将从校园卡余额中扣除。
   回复 #电费 缴费 确认 完成支付,或 #电费 缴费 取消 放弃。(5 分钟内有效)
#电费 缴费 确认
→ 缴费成功:三期2*栋1001 充值 50.00 元,已从校园卡余额扣除。

单次缴费金额不超过 999 元(与学校充值页一致,仅整数)。缴费成功后,该笔订单号(billno)会记录归属宿舍:即使你的校园卡给其他宿舍缴费,日结同步流水时也会按订单号归入对应宿舍,不会虚增你自己绑定宿舍的耗电;仅在机器人内完成的缴费有此归属记录,网页等其他渠道的缴费仍按「一卡一房」假设归入绑定宿舍。

数据保存在 nonebot-plugin-localstore 的插件专属目录中的 SQLite 数据库。旧版本若曾将数据保存到全局 data/,升级后会先迁移用户配置及加密密钥,再一次性导入旧 JSON 历史;原 JSON 会保留,不存储 cookie。

校园卡查询

指令 权限 需要@ 范围 说明
#校园卡 群员 否 私聊/群聊 查询校园卡余额
#校园卡帮助 群员 否 私聊/群聊 查看校园卡帮助
#设置校园卡账号 学号 密码 群员 否 仅私聊 设置校园卡账号(密码加密存储)

⚠️ 安全提示:校园卡账号仅限私聊设置(#设置校园卡账号),密码使用 Fernet 加密后存储在本地。

🎨 效果图

电费查询:

剩余电量: 128.5 度

昨日耗电:

昨日耗电:2.5 度
昨日电费:1.54 元

校园卡查询:

💳 校园卡余额
━━━━━━━━━━━━
账户余额: ¥128.50
冻结余额: ¥0.00

Metadata

Release files for nonebot-plugin-sues-bill 1.2.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-sues-bill 1.2.0
File Size Uploaded Provenance
nonebot_plugin_sues_bill-1.2.0.tar.gz 211.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-sues-bill 1.2.0
File Interpreter ABI Platform
nonebot_plugin_sues_bill-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 252.8 kB

Release files / nonebot_plugin_sues_bill-1.2.0.tar.gz

Download URL nonebot_plugin_sues_bill-1.2.0.tar.gz
Size 211.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8795b91c5da89787e5c7c2a388f083d5897e8a7ced7f997c5b73b20af007d739
BLAKE2b-256 checksum
How to use checksums
fc87c726f35c2f8301b14c925b4bae183e873b2a013556cd4817b223499df323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nonebot_plugin_sues_bill-1.2.0-py3-none-any.whl

Download URL nonebot_plugin_sues_bill-1.2.0-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52060957224bbe166e399ef9e1f78912dcba01b0058f9c76beff131bc10cadce
BLAKE2b-256 checksum
How to use checksums
a7e579516332c9e9f1ae00963656d3ebddca4146a8a07f70f84cc9d778a48431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.2 {"installer":{"name":"uv","version":"0.12.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nonebot-plugin-sues-bill 1.2.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