Compare commits

..

328 Commits
0.1.0 ... 1.1.1

Author SHA1 Message Date
83bcd14012 🔖 1.1.1 2024-05-10 11:30:08 +08:00
70f53a2c76 🐛 修复 init_templates 和 mount assets 的运行顺序问题 2024-05-10 11:29:46 +08:00
6df70f621e 🔖 1.1.0 2024-05-10 11:14:38 +08:00
8ba3f3c3f4 🎨 拆分函数 2024-05-10 11:13:39 +08:00
a5c4e7df5c 🐛 修正 TETR.IO Badge 模型定义 2024-05-10 09:46:09 +08:00
66db7a8a28 🚨 判断 cookie 是否拥有对应字段 2024-05-10 09:42:15 +08:00
呵呵です
716e392a3a 使用新版模板 (#313)
* 🔥 删除现有模板

*  自动克隆模板仓库

* 🔥 删除 identicon 相关代码

* 🚚 修改静态文件路径

*  使用新模板进行渲染

*  每次渲染都获取一次模板, 以应对实时更新

*  TETR.IO 绑定图使用新模板

* 🚚 修改网络路径

*  TOP 绑定图使用新模板

*  TOS 绑定图使用新模板

* 🐛 防止截图超时

* 🐛 Pydantic V1 会把 float 转换成 int

* ✏️ 模板字段名写错了

*  兼容 Pydantic V1

*  TETR.IO 查询图使用新模板

* 🐛 在查询的用户没有历史记录时不去查询更多记录
2024-05-10 09:41:05 +08:00
呵呵です
e47f1bb6f9 渲染 历史tr 曲线图 (#312) 2024-05-08 18:26:08 +08:00
03d34c5572 🔖 1.0.4 2024-05-07 17:22:46 +08:00
04b480ef52 🗃️ HistoricalData 添加 user_unique_identifier 字段 2024-05-07 17:21:52 +08:00
5563b01937 Revert " 为使用了 alias 的 pydantic model 设置 populate_by_name"
This reverts commit 17690e673f.
2024-05-07 08:51:55 +08:00
504edb08de 🔖 1.0.3 2024-05-07 08:50:53 +08:00
c283f1ca49 🗃️ 更正 HistoricalData 中的数据 2024-05-07 08:50:29 +08:00
0171953264 修改 PydanticType raise 的 Error 类型 2024-05-07 08:48:33 +08:00
7515daccc7 添加依赖 rich 2024-05-07 08:33:03 +08:00
17690e673f 为使用了 alias 的 pydantic model 设置 populate_by_name 2024-05-07 08:32:39 +08:00
e9b3c30a13 🎨 优化模型定义 2024-05-07 06:47:34 +08:00
42484b9c2c 适配 Pydantic V2 2024-05-07 06:47:34 +08:00
42828f23f6 PydanticType dump model 的时候会使用 by_alias=True 2024-05-07 06:47:34 +08:00
d0af2e83c4 更新 Metadata 的 homepage 2024-05-07 06:47:33 +08:00
5534456b22 ⬇️ 错误的使用了 Python3.11 的新特性 2024-05-07 06:47:25 +08:00
dependabot[bot]
1928506021 ⬆️ Bump nonebot-adapter-satori from 0.11.4 to 0.11.5 (#309)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.11.4 to 0.11.5.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.11.4...v0.11.5)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-07 06:20:54 +08:00
dependabot[bot]
67da935849 ⬆️ Bump ruff from 0.4.2 to 0.4.3 (#308)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.4.2...v0.4.3)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-07 06:19:33 +08:00
dependabot[bot]
e1e8743c48 ⬆️ Bump jinja2 from 3.1.3 to 3.1.4 (#307)
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.3...3.1.4)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-07 06:17:34 +08:00
e5556bad1d 🔖 1.0.2 2024-05-04 22:10:35 +08:00
889405ea6b 💄 更新数据图样式 2024-05-04 22:06:58 +08:00
66e1850297 使用 UniMessage.finish 2024-05-04 07:54:35 +08:00
f39faced7e 🔖 1.0.1 2024-05-04 07:05:47 +08:00
fffa07dc03 IO查数据使用图片回复 2024-05-04 07:04:57 +08:00
0467b3e5df 💄 微调页脚 2024-05-04 07:04:57 +08:00
f6cc0229ba 💄 新增雷达图数据的 tips 2024-05-04 07:04:57 +08:00
e2708b661d 💄 将雷达图的 OR 替换成 DSPS 2024-05-04 07:04:56 +08:00
65d019a6d3 💄 暂时禁用 TR 折线图 2024-05-04 06:58:31 +08:00
be1b07d5dc 查询图支持处理没有签名的情况 2024-05-04 00:43:06 +08:00
c92bc3aaad 添加开发依赖 types-Pillow 2024-05-03 05:48:39 +08:00
d4b887ef83 💄 css 统一使用 class 2024-05-03 02:12:36 +08:00
dependabot[bot]
695ff13aa2 ⬆️ Bump nonebot-plugin-alconna from 0.45.2 to 0.45.3 (#306)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.45.2 to 0.45.3.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.45.2...v0.45.3)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-03 00:16:06 +08:00
ec1001b3bb query 也使用 UniMessage 进行发送 2024-05-02 21:29:49 +08:00
b545b12255 将 generate_message 合并到 handle_query 2024-05-02 21:01:50 +08:00
b2505e0979 🔧 更新 ruff 配置 2024-05-02 20:53:27 +08:00
38defe37cd 🚨 删除不需要的 noqa 2024-05-02 20:52:00 +08:00
7a3d7c908c 添加 override 标记 2024-05-02 20:51:27 +08:00
bc37a015d6 🔖 1.0.0 2024-05-02 01:24:29 +08:00
呵呵です
fd85140c99 绑定使用图片回复 #61 (#305)
* 🚧 查数据图初版测试

Co-authored-by: C1ystal <m17687496044@163.com>
Co-authored-by: C29H25N3O5 <michaelgu495@gmail.com>

* 🙈 添加一些 ignore 文件

* 🎨 格式化代码

* 🐛 修复格式化导致的样式爆炸

* 💄 优化曲线图观感

* 💄 将雷达图的指示器名称旋转显示

* 💄 查数据图第二版

Co-authored-by: C29H25N3O5 <michaelgu495@gmail.com>

* ✏️ 修复 typo

* 💄 把用户头像文件的引用放到 html 里

* 💄 账户绑定图第一版

Co-authored-by: C1ystal <m17687496044@163.com>
Co-authored-by: C29H25N3O5 <michaelgu495@gmail.com>

* 🚧 模板化测试

*  添加依赖 fastapi

*  通过 FastAPI 提供静态文件

*  添加依赖 jinja2

* 💄 更新数据图模板 (#291)

* feat(template): show actual value

* feat(template): add user avatar

* feat(template): fix radar

* feat(style): fix name container width fixed caused display misplacement

* feat(style): fix vs value wrap display

* feat(template): make check data length in template

* feat(template): update radar data

* feat(jinja): update data

* fix(template): fix typo

* feat(style): prevent sign too long

* feat(template): turn off echarts animation

* chore(deps): add identicon.js

* fix(template): fix typo

* 🙈 更新.gitignore

* 🏗️ 大部分重构为 flex 布局

---------

Co-authored-by: shoucandanghehe <wallfjjd@gmail.com>
Co-authored-by: 呵呵です <51957264+shoucandanghehe@users.noreply.github.com>

*  添加依赖 nonebot_plugin_userinfo

*  通过 FastAPI 托管渲染后的模板

*  新增头像 api 使用 playwright 生成

*  修正模板资源文件引用路径
被托管后的正确路径

* 💄 将绑定图模板化

* 💄 重命名变量

* 🚚 重命名资源

*  使用 jinja2 渲染模板

*  使用 playwright 渲染网页

* 🩹 渲染模板时对 IO 进行一些额外处理

*  添加依赖 pillow

* 🚚 修改托管页面的路由路径

* 💬 优化绑定图文案

*  新增获取自身网络位置的方法

* 🍱 更新 unknown.svg

*  新增获取用户头像的方法

*  绑定消息使用图片回复

*  为 identicon api 添加缓存

* 🔥 删除旧文件

* 🚚 重命名模板

* 📄 添加字体 License

* 🙈 更新.gitignore

---------

Co-authored-by: C1ystal <m17687496044@163.com>
Co-authored-by: C29H25N3O5 <michaelgu495@gmail.com>
Co-authored-by: 渣渣120 <WOSHIZHAZHA120@qq.com>
2024-05-02 01:22:33 +08:00
dependabot[bot]
80f4316564 ⬆️ Bump nonebot2 from 2.2.1 to 2.3.0 (#304)
Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.2.1...v2.3.0)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-02 00:31:44 +08:00
dependabot[bot]
3b9c0c89b1 ⬆️ Bump nonebot-adapter-satori from 0.11.3 to 0.11.4 (#302)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.11.3 to 0.11.4.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.11.3...v0.11.4)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-30 23:25:33 +08:00
c02fdfc47f 🔖 1.0.0.a17 2024-04-30 02:27:31 +08:00
93b169fa40 🐛 修复对 Pydantic V1 的适配 2024-04-30 02:27:08 +08:00
5cb428ed71 🔖 1.0.0.a16 2024-04-30 02:09:34 +08:00
呵呵です
ec392ee384 支持茶服多个api地址的故障转移 (#301)
*  RequestError 新增 status_code 参数

*  新增支持故障转移的请求方法

*  支持茶服多个api地址的故障转移
2024-04-30 01:52:41 +08:00
dependabot[bot]
d037cf6d44 ⬆️ Bump nonebot-adapter-satori from 0.11.2 to 0.11.3 (#300)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.11.2 to 0.11.3.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.11.2...v0.11.3)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-30 00:02:36 +08:00
dependabot[bot]
6964e9b655 ⬆️ Bump nonebot-plugin-orm from 0.7.1 to 0.7.2 (#298)
Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.7.1 to 0.7.2.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.7.1...v0.7.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-29 23:56:55 +08:00
dependabot[bot]
7a032bf947 ⬆️ Bump nonebot-adapter-kaiheila from 0.3.3 to 0.3.4 (#299)
Bumps [nonebot-adapter-kaiheila](https://github.com/Tian-que/nonebot-adapter-kaiheila) from 0.3.3 to 0.3.4.
- [Release notes](https://github.com/Tian-que/nonebot-adapter-kaiheila/releases)
- [Commits](https://github.com/Tian-que/nonebot-adapter-kaiheila/compare/v0.3.3...v0.3.4)

---
updated-dependencies:
- dependency-name: nonebot-adapter-kaiheila
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-29 23:56:31 +08:00
dependabot[bot]
9a91e5ef5b ⬆️ Bump nonebot-plugin-alconna from 0.44.0 to 0.45.0 (#297)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.44.0 to 0.45.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.44.0...v0.45.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-29 23:56:20 +08:00
dependabot[bot]
5b58697fce ⬆️ Bump nonebot-adapter-satori from 0.11.0 to 0.11.2 (#296)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.11.0 to 0.11.2.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.11.0...v0.11.2)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-28 15:38:57 +08:00
dependabot[bot]
b14cebe832 ⬆️ Bump ruff from 0.4.1 to 0.4.2 (#295)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.1 to 0.4.2.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.4.1...v0.4.2)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-28 15:38:48 +08:00
dependabot[bot]
4306195ee5 ⬆️ Bump nonebot-plugin-alconna from 0.43.0 to 0.44.0 (#294)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.43.0 to 0.44.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.43.0...v0.44.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-28 15:38:39 +08:00
dependabot[bot]
ac9c6e79d9 ⬆️ Bump nonebot-adapter-satori from 0.10.5 to 0.11.0 (#293)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.10.5 to 0.11.0.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.10.5...v0.11.0)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-25 15:53:32 +08:00
dependabot[bot]
ed035c65c1 ⬆️ Bump mypy from 1.9.0 to 1.10.0 (#292)
Bumps [mypy](https://github.com/python/mypy) from 1.9.0 to 1.10.0.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/1.9.0...v1.10.0)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-25 02:29:20 +08:00
dc8bc9b306 🚨 添加一些type: ignore) 2024-04-24 17:56:24 +08:00
454dd57007 🐛 mode写错了 2024-04-24 17:55:17 +08:00
b396a6d450 存储历史IO Rank数据至本地 2024-04-24 17:28:40 +08:00
7f584a46eb 添加依赖 zstandard 2024-04-24 16:56:44 +08:00
27518c0408 适配 Pydantic V2 2024-04-24 16:49:01 +08:00
dependabot[bot]
d2a3801dac ⬆️ Bump nonebot-plugin-alconna from 0.42.5 to 0.43.0 (#290)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.42.5 to 0.43.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.42.5...v0.43.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-24 00:53:44 +08:00
563564ac8d 适配 Pydantic V2 2024-04-24 00:52:32 +08:00
87c87ad231 🗃️ 重命名字段 2024-04-24 00:52:31 +08:00
30515d1907 🚨 ruff auto fix 2024-04-23 22:52:04 +08:00
dependabot[bot]
bd0a8ea447 ⬆️ Bump nonebot-plugin-alconna from 0.42.4 to 0.42.5 (#289)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.42.4 to 0.42.5.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.42.4...v0.42.5)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 22:28:43 +08:00
dependabot[bot]
1db1e6dbba ⬆️ Bump nonebot-adapter-satori from 0.10.4 to 0.10.5 (#288)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.10.4 to 0.10.5.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.10.4...v0.10.5)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 22:28:21 +08:00
dependabot[bot]
9040aa9fba ⬆️ Bump ruff from 0.3.7 to 0.4.1 (#287)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.7 to 0.4.1.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.3.7...v0.4.1)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-23 22:27:59 +08:00
呵呵です
3a5f1eb266 🔖 1.0.0.a15 2024-04-17 14:11:45 +08:00
MianSoft
43e927430a 👽️ 修改茶服api地址 (#286) 2024-04-17 14:09:59 +08:00
e1b0918a52 🔖 1.0.0.a14 2024-04-15 17:42:31 +08:00
c86b2eb31b ⬆️ 更新依赖 2024-04-15 17:41:39 +08:00
dependabot[bot]
47b3f3e881 ⬆️ Bump nonebot-plugin-alconna from 0.37.0 to 0.38.2 (#268)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.37.0 to 0.38.2.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.37.0...v0.38.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-14 08:53:59 +08:00
dependabot[bot]
7caee587b4 ⬆️ Bump pandas from 2.2.0 to 2.2.1 (#266)
Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](https://github.com/pandas-dev/pandas/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-14 08:53:44 +08:00
dependabot[bot]
28ae564e59 ⬆️ Bump nonebot-plugin-orm from 0.6.3 to 0.7.1 (#264)
Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.6.3 to 0.7.1.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.6.3...v0.7.1)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 14:06:04 +08:00
dependabot[bot]
90dee8402d ⬆️ Bump httpx from 0.26.0 to 0.27.0 (#263)
Bumps [httpx](https://github.com/encode/httpx) from 0.26.0 to 0.27.0.
- [Release notes](https://github.com/encode/httpx/releases)
- [Changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md)
- [Commits](https://github.com/encode/httpx/compare/0.26.0...0.27.0)

---
updated-dependencies:
- dependency-name: httpx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 12:02:53 +08:00
dependabot[bot]
8b560e55cb ⬆️ Bump pandas-stubs from 2.1.4.231227 to 2.2.0.240218 (#259)
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.1.4.231227 to 2.2.0.240218.
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.1.4.231227...v2.2.0.240218)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 11:53:08 +08:00
dependabot[bot]
3080531503 ⬆️ Bump nonebot-adapter-satori from 0.9.1 to 0.9.3 (#258)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.9.1 to 0.9.3.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.9.1...v0.9.3)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 11:52:54 +08:00
dependabot[bot]
fae0088533 ⬆️ Bump ruff from 0.2.1 to 0.3.0 (#265)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.2.1 to 0.3.0.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.2.1...v0.3.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-04 11:48:09 +08:00
dependabot[bot]
db9286a369 ⬆️ Bump nonebot-adapter-onebot from 2.4.0 to 2.4.1 (#257)
Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.4.0 to 2.4.1.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.4.0...v2.4.1)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-17 22:14:59 +08:00
dependabot[bot]
420fb29318 ⬆️ Bump nonebot-adapter-kaiheila from 0.3.0 to 0.3.1 (#256)
Bumps [nonebot-adapter-kaiheila](https://github.com/Tian-que/nonebot-adapter-kaiheila) from 0.3.0 to 0.3.1.
- [Release notes](https://github.com/Tian-que/nonebot-adapter-kaiheila/releases)
- [Commits](https://github.com/Tian-que/nonebot-adapter-kaiheila/compare/v0.03...v0.3.1)

---
updated-dependencies:
- dependency-name: nonebot-adapter-kaiheila
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-17 21:31:20 +08:00
dependabot[bot]
433a6edd3b ⬆️ Bump nonebot-adapter-satori from 0.9.0 to 0.9.1 (#255)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.9.0 to 0.9.1.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.9.0...v0.9.1)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-17 20:56:27 +08:00
dependabot[bot]
fa81231f78 ⬆️ Bump nonebot-plugin-alconna from 0.36.2 to 0.37.0 (#253)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.36.2 to 0.37.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.36.2...v0.37.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-17 19:22:12 +08:00
dependabot[bot]
c474cf0af2 ⬆️ Bump nonebot-plugin-apscheduler from 0.3.0 to 0.4.0 (#252)
Bumps [nonebot-plugin-apscheduler](https://github.com/nonebot/plugin-apscheduler) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/nonebot/plugin-apscheduler/releases)
- [Commits](https://github.com/nonebot/plugin-apscheduler/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-apscheduler
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-17 10:09:27 +08:00
dependabot[bot]
e38eb5cdff ⬆️ Bump types-lxml from 2023.10.21 to 2024.2.9 (#251)
Bumps [types-lxml](https://github.com/abelcheung/types-lxml) from 2023.10.21 to 2024.2.9.
- [Release notes](https://github.com/abelcheung/types-lxml/releases)
- [Commits](https://github.com/abelcheung/types-lxml/compare/2023.10.21...2024.02.09)

---
updated-dependencies:
- dependency-name: types-lxml
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-14 16:39:41 +08:00
dependabot[bot]
7bacf89840 ⬆️ Bump nonebot-adapter-onebot from 2.3.1 to 2.4.0 (#254)
Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-14 14:44:14 +08:00
dependabot[bot]
4622e90995 ⬆️ Bump nonebot-adapter-satori from 0.8.1 to 0.9.0 (#250)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.8.1 to 0.9.0.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.8.1...v0.9.0)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 22:42:50 +08:00
dependabot[bot]
fa8c2b11e6 ⬆️ Bump nonebot-plugin-localstore from 0.5.1 to 0.6.0 (#249)
Bumps [nonebot-plugin-localstore](https://github.com/nonebot/plugin-localstore) from 0.5.1 to 0.6.0.
- [Release notes](https://github.com/nonebot/plugin-localstore/releases)
- [Commits](https://github.com/nonebot/plugin-localstore/compare/v0.5.1...v0.6.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-localstore
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 19:54:44 +08:00
dependabot[bot]
2123b747af ⬆️ Bump playwright from 1.41.1 to 1.41.2 (#246)
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.41.1 to 1.41.2.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.41.1...v1.41.2)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 08:38:07 +08:00
dependabot[bot]
e65233d09f ⬆️ Bump viztracer from 0.16.1 to 0.16.2 (#245)
Bumps [viztracer](https://github.com/gaogaotiantian/viztracer) from 0.16.1 to 0.16.2.
- [Release notes](https://github.com/gaogaotiantian/viztracer/releases)
- [Commits](https://github.com/gaogaotiantian/viztracer/compare/0.16.1...0.16.2)

---
updated-dependencies:
- dependency-name: viztracer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 08:03:30 +08:00
dependabot[bot]
7e81bf6b8b ⬆️ Bump ruff from 0.2.0 to 0.2.1 (#243)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.2.0 to 0.2.1.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.2.0...v0.2.1)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 07:41:37 +08:00
dependabot[bot]
c4614aa006 ⬆️ Bump nonebot2 from 2.1.3 to 2.2.0 (#248)
Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.1.3 to 2.2.0.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.1.3...v2.2.0)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-12 07:30:30 +08:00
dependabot[bot]
79a657b9f5 ⬆️ Bump playwright from 1.40.0 to 1.41.1 (#237)
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.40.0 to 1.41.1.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.40.0...v1.41.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 07:07:21 +08:00
dependabot[bot]
0164f29c1e ⬆️ Bump pandas from 2.1.4 to 2.2.0 (#235)
Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.1.4 to 2.2.0.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](https://github.com/pandas-dev/pandas/compare/v2.1.4...v2.2.0)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 07:00:41 +08:00
dependabot[bot]
8db56366df ⬆️ Bump nonebot-plugin-alconna from 0.35.1 to 0.36.2 (#239)
Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.35.1 to 0.36.2.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.35.1...v0.36.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 07:00:12 +08:00
dependabot[bot]
de0a1e4c73 ⬆️ Bump nonebot-plugin-orm from 0.6.2 to 0.6.3 (#233)
Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.6.2 to 0.6.3.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.6.2...v0.6.3)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 05:52:35 +08:00
dependabot[bot]
3670ce7221 ⬆️ Bump ruff from 0.1.13 to 0.2.0 (#240)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.13 to 0.2.0.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.13...v0.2.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 05:51:32 +08:00
dependabot[bot]
101ed737ab ⬆️ Bump fastapi from 0.103.0 to 0.109.1 (#241)
Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.103.0 to 0.109.1.
- [Release notes](https://github.com/tiangolo/fastapi/releases)
- [Commits](https://github.com/tiangolo/fastapi/compare/0.103.0...0.109.1)

---
updated-dependencies:
- dependency-name: fastapi
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-06 05:51:11 +08:00
呵呵です
1611bf47fa 🔖 1.0.0.a13 2024-01-15 18:51:38 +08:00
dependabot[bot]
e084cdb145 ⬆️ Bump lxml from 5.0.0 to 5.1.0 (#230)
Bumps [lxml](https://github.com/lxml/lxml) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](https://github.com/lxml/lxml/compare/lxml-5.0.0...lxml-5.1.0)

---
updated-dependencies:
- dependency-name: lxml
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-15 18:51:05 +08:00
呵呵です
27258ab744 👽️ 修改茶服api地址 2024-01-15 18:40:20 +08:00
dependabot[bot]
07324825e6 ⬆️ Bump ruff from 0.1.11 to 0.1.13 (#231)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.11 to 0.1.13.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.11...v0.1.13)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-15 18:35:27 +08:00
dependabot[bot]
472becdfe0 ⬆️ Bump types-aiofiles from 23.2.0.0 to 23.2.0.20240106 (#229)
Bumps [types-aiofiles](https://github.com/python/typeshed) from 23.2.0.0 to 23.2.0.20240106.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-aiofiles
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-15 12:15:09 +08:00
dependabot[bot]
bc87e4b16d ⬆️ Bump ruff from 0.1.9 to 0.1.11 (#228)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.9 to 0.1.11.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.9...v0.1.11)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-04 06:21:11 +08:00
dependabot[bot]
28e2a46303 ⬆️ Bump nonebot-plugin-orm from 0.6.0 to 0.6.2 (#227)
Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.6.0 to 0.6.2.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.6.0...v0.6.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-04 06:20:58 +08:00
1324015d58 🔖 1.0.0.a12 2024-01-03 09:52:25 +08:00
e6eae023e7 🐛 修复茶服pb数据处理错误的bug 2024-01-03 09:51:56 +08:00
67cfb07246 🔖 1.0.0.a11 2024-01-03 09:37:36 +08:00
12145a614f ⬇️ 错误的使用了Python3.11的新特性 2024-01-03 09:37:10 +08:00
0b07882a16 🐛 修复事件没有正确结束的bug 2024-01-03 09:27:26 +08:00
呵呵です
9073bf5d0b 🔖 1.0.0.a10 2024-01-03 09:02:22 +08:00
dependabot[bot]
f4dd5fe76f ⬆️ Bump nonebot-plugin-alconna from 0.34.1 to 0.35.1 (#226) 2024-01-03 09:02:20 +08:00
dependabot[bot]
1f44fc9884 ⬆️ Bump nonebot2 from 2.1.2 to 2.1.3 (#225) 2024-01-03 09:02:18 +08:00
dependabot[bot]
44dee7f200 ⬆️ Bump types-ujson from 5.8.0.1 to 5.9.0.0 (#224)
Bumps [types-ujson](https://github.com/python/typeshed) from 5.8.0.1 to 5.9.0.0.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-ujson
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-03 09:02:14 +08:00
dependabot[bot]
dc5ade6ffc ⬆️ Bump pandas from 2.1.3 to 2.1.4 (#223)
Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.1.3 to 2.1.4.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](https://github.com/pandas-dev/pandas/compare/v2.1.3...v2.1.4)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-03 09:02:12 +08:00
dependabot[bot]
05ce329976 ⬆️ Bump pandas-stubs from 2.1.1.230928 to 2.1.4.231227 (#222)
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.1.1.230928 to 2.1.4.231227.
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.1.1.230928...v2.1.4.231227)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-03 09:02:07 +08:00
dependabot[bot]
43cabf2135 ⬆️ Bump nonebot-adapter-discord from 0.1.2 to 0.1.3 (#218) 2024-01-03 09:02:06 +08:00
dependabot[bot]
6767136850 ⬆️ Bump lxml from 4.9.3 to 5.0.0 (#221) 2024-01-03 09:02:06 +08:00
dependabot[bot]
65999b4625 ⬆️ Bump nonebot-adapter-satori from 0.8.0 to 0.8.1 (#217) 2024-01-03 09:02:06 +08:00
dependabot[bot]
9fde62ac9e ⬆️ Bump ujson from 5.8.0 to 5.9.0 (#219) 2024-01-03 09:02:05 +08:00
dependabot[bot]
c74d8b70aa ⬆️ Bump ruff from 0.1.6 to 0.1.9 (#220)
Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.6 to 0.1.9.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.6...v0.1.9)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-03 09:02:05 +08:00
dependabot[bot]
0e29b38f9d ⬆️ Bump playwright from 1.39.0 to 1.40.0 (#205) 2024-01-03 09:01:45 +08:00
dependabot[bot]
d040c7dca2 ⬆️ Bump viztracer from 0.16.0 to 0.16.1 (#211) 2024-01-03 09:00:06 +08:00
dependabot[bot]
68ace3a715 ⬆️ Bump httpx from 0.25.1 to 0.26.0 (#214) 2024-01-03 09:00:00 +08:00
dependabot[bot]
e63ac69e0f ⬆️ Bump mypy from 1.7.0 to 1.8.0 (#215) 2024-01-03 08:59:18 +08:00
4afda62782 添加状态码检查 2023-12-30 06:52:45 +08:00
呵呵です
abf4410a00 👽️ 适配 茶服 新赛季 (#216)
* 👽️ 适配 茶服 新赛季

* ✏️ 少个-

*  添加开发依赖 nonebot-adapter-kaiheila

*  适配 kook 茶服查target

* 🐛 修复 onebotv11 查自己 找不到用户的bug

* 🐛 修复 茶服 查绑定 找不到用户的bug

*  kook 茶服查target 添加后备方案

*  添加开发依赖 nonebot-adapter-discord

*  适配 discord 茶服查target
2023-12-30 06:43:06 +08:00
88c2915251 🐛 修复 pydantic model 不能被正确反序列化的bug 2023-11-29 11:43:00 +08:00
546369241a 添加冗余 platform 字段 2023-11-29 11:41:48 +08:00
d59bccbd4d 细化异常 2023-11-29 11:29:46 +08:00
75a6989a7f 使用上下文管理器管理页面 2023-11-29 11:00:55 +08:00
ad635bd37d 🎨 修改错误处理逻辑 2023-11-29 10:59:58 +08:00
呵呵です
b6d63c9e7f 🐛 修复 io record 解析错误的bug (#207) 2023-11-23 20:07:57 +08:00
805da8cd36 🔖 1.0.0.a9 2023-11-22 18:34:07 +08:00
4a13d7807a 🐛 修复计算时间时区不正确的bug 2023-11-22 18:33:42 +08:00
7bbdeacc5e 🔖 1.0.0.a8 2023-11-22 16:11:57 +08:00
dependabot[bot]
782792e455 ⬆️ Bump nonebot-plugin-orm from 0.5.1 to 0.6.0 (#203) 2023-11-22 08:11:15 +00:00
dependabot[bot]
bd10549b4c ⬆️ Bump ruff from 0.1.5 to 0.1.6 (#202) 2023-11-22 08:02:43 +00:00
dependabot[bot]
035e6d4782 ⬆️ Bump nonebot-plugin-alconna from 0.33.3 to 0.33.6 (#201) 2023-11-22 08:02:33 +00:00
003e6619d8 iorank 指令不再去尝试更新数据 2023-11-22 15:58:55 +08:00
c0fa92df30 🚨 fix Incompatible overrides 2023-11-22 15:57:04 +08:00
7cdb0f3547 为 IO Rank 添加重试机制 2023-11-22 15:49:33 +08:00
b773fb44a1 ️ 为 IO 添加缓存 2023-11-22 13:22:18 +08:00
c75c6b73bd 🙈 更新.gitignore 2023-11-22 13:02:17 +08:00
67782c3156 添加依赖 aiocache 2023-11-22 13:01:41 +08:00
1e02858913 💥 🗃️ 将 pydantic 模型序列化后再存数据库 2023-11-21 20:47:56 +08:00
60605d0dca 🐛 修复 IO Z段位 不显示glicko和rd的bug 2023-11-21 13:58:39 +08:00
0d589450bd 将处理过程中的 dataclass 换成 pydantic 2023-11-21 00:50:32 +08:00
dependabot[bot]
2f144acf0c ⬆️ Bump nonebot-adapter-satori from 0.7.0 to 0.8.0 (#200)
Bumps [nonebot-adapter-satori](https://github.com/nonebot/adapter-satori) from 0.7.0 to 0.8.0.
- [Release notes](https://github.com/nonebot/adapter-satori/releases)
- [Commits](https://github.com/nonebot/adapter-satori/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: nonebot-adapter-satori
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-17 01:49:57 +08:00
87e6a544a2 🔖 1.0.0.a7 2023-11-16 21:34:41 +08:00
74db1931fd 🐛 修复在多个无效参数时 Alconna 自动回复的bug 2023-11-16 21:33:24 +08:00
1ca6d1f86a 使用 zoneinfo 处理时区,并优化数据库查询逻辑 2023-11-16 16:27:06 +08:00
dependabot[bot]
7361789245 ⬆️ Bump nonebot-plugin-orm from 0.5.0 to 0.5.1 (#199) 2023-11-15 15:44:10 +00:00
fe69d8d2fe 🔖 1.0.0.a6 2023-11-15 14:37:41 +08:00
2737119865 🐛 修复 茶服 命令参数设置错误的bug 2023-11-15 14:36:54 +08:00
34a654b5df 🐛 修复只输入主命令时不发送帮助提示的bug 2023-11-15 14:34:27 +08:00
f9f39618a1 💚 修复Release CI 2023-11-15 14:02:22 +08:00
81a3c9cb79 🔖 1.0.0.a5 2023-11-15 11:44:23 +08:00
4a15c45e0a 💚 修复Release CI 2023-11-15 11:44:23 +08:00
e90ad53ee6 🐛 修复在事件响应器异常退出后 Recorder 继续执行的bug 2023-11-15 11:37:12 +08:00
0c968be163 避免 Alconna 在 ParamsUnmatched 时自动回复
🎨 将通用 handle 封装一下
2023-11-15 11:04:09 +08:00
bfadac4f79 添加配置项 请求超时时间 2023-11-15 00:43:12 +08:00
89f09cd66c 🔥 删除配置项 db_url 2023-11-15 00:37:04 +08:00
777703362e 🎨 先断开连接再删文件 2023-11-15 00:28:54 +08:00
ea5308877c 🎨 🔥 去除一个没什么用的函数 2023-11-15 00:26:55 +08:00
3cc93925a6 🐛 修复迁移旧数据库时拿错config字段的bug 2023-11-15 00:14:03 +08:00
e0bd0a9252 🐛 修复 io user info 解析错误的bug 2023-11-15 00:07:05 +08:00
d31ce48a18 💚 修复Release CI 2023-11-14 13:15:51 +08:00
7da38e0346 🔖 Release 1.0.0.a4 2023-11-14 13:11:46 +08:00
呵呵です
84368a16c3 👷 更改 dependabot 推送分支 2023-11-14 13:44:58 +08:00
6a10ede5ba 👷 更新Release CI 2023-11-14 12:56:06 +08:00
4c205e516f 🔥 去除命令解析失败时发送提醒 2023-11-14 12:54:42 +08:00
c1feccd608 🔖 1.0.0.a3 2023-11-14 09:07:08 +08:00
f27d7b4440 🐛 修复 io record 解析错误的bug 2023-11-14 09:02:22 +08:00
7fa498de48 👽️ io record 添加一个pentas字段 2023-11-14 09:00:35 +08:00
ff7c5847a3 🐛 修复 io record 解析错误的bug 2023-11-14 08:59:44 +08:00
呵呵です
b75c42987d 🔀 Merge pull request #198 from shoucandanghehe/dev
🔖 1.0.0.a2
2023-11-14 01:46:27 +08:00
0daea46eea 🔖 1.0.0.a2 2023-11-14 01:45:40 +08:00
ccb0bae32c 🐛 修复 io record 解析错误的bug 2023-11-14 01:44:56 +08:00
dependabot[bot]
63afcf9ad1 ⬆️ Bump pandas from 2.1.1 to 2.1.3 (#195) 2023-11-13 17:42:40 +00:00
dependabot[bot]
6d3d2a38b0 ⬆️ Bump nonebot-plugin-alconna from 0.32.0 to 0.33.3 (#196) 2023-11-13 17:42:30 +00:00
1b7e51b773 🔖 1.0.0.a1.post1 2023-11-14 00:47:52 +08:00
c09d10b799 🐛 修复排行榜 Users.League 的部分字段为 None 时 错误处理的错误 2023-11-14 00:47:52 +08:00
呵呵です
ca8ab5871b 🔖 Release 1.0.0.a1 (#80)
* 使用 `pathlib` 替代 `os`

* 防止建立多个数据库连接对象

* 调整数据库结构 # 破坏性更新

* 格式化代码

*  去除依赖Brotli
 去除开发依赖autopep8 pylint
 添加开发依赖ruff black
🔥 删除.pylintrc
🎨 使用black格式化代码

* 📝 一些很赞的小牌子

* ✏️ 修正`config`变量名

* 🐛 修复OperationalError语法错误

*  添加 debug 依赖 objprint

* 🚧 数据记录器demo

* 🔥 这个init好像没什么用(

* 💡 ✏️ 修改错误的注释

* 📝 🍱 添加一个logo

* 📝 添加logo的悬浮提示

* 🙈 更新 .gitignore

* 🚨 消除了一些 init 文件中的错误警告

* ♻️ 💩 重构 IO 的 processor 模块
🐛 修复了 bind user_id 不能正确处理的bug
🎨 使用一些自定义类型和基于异常的编程(

* 🐛 忘记写try了

* 👷 将 Release CI 切换到 Python 3.11 版本

* 🎨 修改 Exception 类的变量名

* 🎨 修改捕获的 aiohttp 的错误类型

* 🎨 将 AsyncCallable 放进 typing 模块

* 🏗️ 将 recorder 装饰器中执行函数的部分放在 collector 函数中
🚧 完善数据收集部分

* 🚧 receive 记录添加 message_id 以辅助消息上下文识别

*  添加依赖 tortoise-orm

* ♻️ 🗃️ 将数据库操作替换成 tortoise-orm

* 🎨 显式传递 locals 字典

* 🎨 将装饰器封装到类里

* 🐛 忘记 exec 需要拿变量了

* 🗃️ 微调数据类型

* 🗃️ 调整数据库索引

* Bump playwright from 1.29.0 to 1.30.0 (#72)

* Bump ujson from 5.6.0 to 5.7.0 (#69)

* Bump pandas-stubs from 1.5.2.221213 to 1.5.2.230105 (#57)

* Bump types-ujson from 5.6.0.0 to 5.7.0.0 (#68)

*  存储命令历史 #58

* Bump nonebot2 from 2.0.0rc2 to 2.0.0rc3 (#73)

* Bump nonebot-adapter-onebot from 2.2.0 to 2.2.1 (#74)

* Bump tortoise-orm from 0.19.2 to 0.19.3 (#75)

* Bump black from 23.1a1 to 23.1.0 (#77)

* Bump pandas from 1.5.2 to 1.5.3 (#76)

* ⬆️ 更新 ruff

* 🔧 启用更多的检查规则

* 🎨 使用单引号编写配置文件

* 💡 为 ignore 添加注释

* 🎨 使用 ruff 规范化引号

* 🔧 启用 PEP8 命名规范检查

* 🚨 添加一些 noqa(

* 💡 添加和修改了一些注释

* 🔊 添加一条日志

* 🎨 🚨 使用 replace 替换 strip

* 🎨 🚨 规范化命名

* 🎨 格式化代码

* 🔊 修改日志等级

* 🎨 去除重复的 get_driver() 调用

*  自动安装 playwright 浏览器 close #71

* 🙈 更新 gitignore

*  将所有 playwright 相关整合进 BrowserManager 类

* 📝 更换开源许可证 (#78)

* 📝 更新 README

* Bump pandas-stubs from 1.5.2.230105 to 1.5.3.230203 (#79)

*  添加依赖 nonebot-plugin-datastore

*  使用 nonebot_plugin_datastore 提供的路径存储缓存

* Bump nonebot-plugin-datastore from 0.5.7 to 0.5.8 (#81)

* ⬆️ Bump aiohttp from 3.8.3 to 3.8.4 (#82)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.8.3 to 3.8.4.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.8.3...v3.8.4)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump pandas-stubs from 1.5.3.230203 to 1.5.3.230214 (#84)

Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.5.3.230203 to 1.5.3.230214.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.5.3.230203...v1.5.3.230214)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ruff from 0.0.239 to 0.0.253 (#90)

* ⬆️ Bump playwright from 1.30.0 to 1.31.1 (#89)

* ⬆️ Bump types-ujson from 5.7.0.0 to 5.7.0.1 (#86)

* ⬆️ Bump pandas-stubs from 1.5.3.230214 to 1.5.3.230227 (#88)

* ⬆️ Bump ruff from 0.0.253 to 0.0.254 (#91)

* ⬆️ Bump pandas-stubs from 1.5.3.230227 to 1.5.3.230304 (#92)

* ⬆️ Bump mypy from 0.991 to 1.0.1 (#93)

* ⬆️ Bump mypy from 1.0.1 to 1.1.1 (#94)

* ⬆️ Bump ruff from 0.0.254 to 0.0.284 (#139)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.254 to 0.0.284.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.0.254...v0.0.284)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-adapter-onebot from 2.2.1 to 2.2.4 (#137)

Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.2.1 to 2.2.4.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.2.1...v2.2.4)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump playwright from 1.31.1 to 1.36.0 (#133)

Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.31.1 to 1.36.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.31.1...v1.36.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump pandas-stubs from 1.5.3.230304 to 2.0.2.230605 (#124)

* ⬆️ Bump mypy from 1.1.1 to 1.5.1 (#144)

Bumps [mypy](https://github.com/python/mypy) from 1.1.1 to 1.5.1.
- [Commits](https://github.com/python/mypy/compare/v1.1.1...v1.5.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump types-ujson from 5.7.0.1 to 5.8.0.1 (#142)

Bumps [types-ujson](https://github.com/python/typeshed) from 5.7.0.1 to 5.8.0.1.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-ujson
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot2 from 2.0.0rc3 to 2.0.1 (#141)

Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.0.0rc3 to 2.0.1.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.0.0rc3...v2.0.1)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump lxml from 4.9.2 to 4.9.3 (#140)

Bumps [lxml](https://github.com/lxml/lxml) from 4.9.2 to 4.9.3.
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](https://github.com/lxml/lxml/compare/lxml-4.9.2...lxml-4.9.3)

---
updated-dependencies:
- dependency-name: lxml
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump black from 23.1.0 to 23.9.1 (#148)

Bumps [black](https://github.com/psf/black) from 23.1.0 to 23.9.1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.1.0...23.9.1)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump pandas-stubs from 2.0.2.230605 to 2.0.3.230814 (#149)

Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.0.2.230605 to 2.0.3.230814.
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.0.2.230605...v2.0.3.230814)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump pandas from 1.5.3 to 2.1.1 (#152)

Bumps [pandas](https://github.com/pandas-dev/pandas) from 1.5.3 to 2.1.1.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](https://github.com/pandas-dev/pandas/compare/v1.5.3...v2.1.1)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump aiohttp from 3.8.4 to 3.8.5 (#155)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.8.4 to 3.8.5.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/v3.8.5/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.8.4...v3.8.5)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ruff from 0.0.284 to 0.0.291 (#154)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.284 to 0.0.291.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.0.284...v0.0.291)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump playwright from 1.36.0 to 1.38.0 (#153)

Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.36.0 to 1.38.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.36.0...v1.38.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-plugin-datastore from 0.5.8 to 1.1.2 (#151)

Bumps [nonebot-plugin-datastore](https://github.com/he0119/nonebot-plugin-datastore) from 0.5.8 to 1.1.2.
- [Release notes](https://github.com/he0119/nonebot-plugin-datastore/releases)
- [Changelog](https://github.com/he0119/nonebot-plugin-datastore/blob/main/CHANGELOG.md)
- [Commits](https://github.com/he0119/nonebot-plugin-datastore/compare/v0.5.8...v1.1.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-datastore
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot2 from 2.0.1 to 2.1.0 (#156)

Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.0.1 to 2.1.0.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.0.1...v2.1.0)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ujson from 5.7.0 to 5.8.0 (#157)

Bumps [ujson](https://github.com/ultrajson/ultrajson) from 5.7.0 to 5.8.0.
- [Release notes](https://github.com/ultrajson/ultrajson/releases)
- [Commits](https://github.com/ultrajson/ultrajson/compare/5.7.0...5.8.0)

---
updated-dependencies:
- dependency-name: ujson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ️ 移除无意义的async

* 🎨 修正 type hint

*  添加依赖 aiofiles

* 🎨 将文件读写操作换成 aiofiles

* ️ 移除无意义的async

* 🎨 重命名一些函数

* 🎨 去除不需要的转换

* ⬆️ Bump pandas-stubs from 2.0.3.230814 to 2.1.1.230928 (#158)

Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.0.3.230814 to 2.1.1.230928.
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.0.3.230814...v2.1.1.230928)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot2 from 2.1.0 to 2.1.1 (#159)

Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.1.0 to 2.1.1.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.1.0...v2.1.1)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

*  添加依赖 nonebot-plugin-orm
 添加依赖 nonebot-plugin-localstore
 移除依赖 nonebot-plugin-datastore

* 📌 取消 python 最高版本限制

* ⬆️ Bump objprint from 0.2.2 to 0.2.3 (#161)

Bumps [objprint](https://github.com/gaogaotiantian/objprint) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/gaogaotiantian/objprint/releases)
- [Commits](https://github.com/gaogaotiantian/objprint/compare/0.2.2...0.2.3)

---
updated-dependencies:
- dependency-name: objprint
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ruff from 0.0.291 to 0.0.292 (#160)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.291 to 0.0.292.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/BREAKING_CHANGES.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.0.291...v0.0.292)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump mypy from 1.5.1 to 1.6.0 (#163)

Bumps [mypy](https://github.com/python/mypy) from 1.5.1 to 1.6.0.
- [Commits](https://github.com/python/mypy/compare/v1.5.1...v1.6.0)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

*  添加依赖 httpx

* ⬆️ Bump nonebot-plugin-orm from 0.1.1 to 0.2.1 (#166)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.1.1 to 0.2.1.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.1.1...v0.2.1)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

*  添加开发依赖 nonebot2

* 🎨 改为直接使用 nonebot_plugin_localstore 提供缓存路径

* 🐛 忘记 require

* 🐛 顺序错了

* 🗃️ 使用 nb orm

* 🏗️ 再次重构 IO 模块

* 🐛 忘记 push 这个了

* 🏗️ 将 request 改成通用的

* ⬆️ Bump nonebot-plugin-orm from 0.2.1 to 0.2.2 (#167)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.2.1 to 0.2.2.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.2.1...v0.2.2)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ruff from 0.0.292 to 0.1.0 (#168)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.0.292 to 0.1.0.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.0.292...v0.1.0)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-adapter-onebot from 2.3.0 to 2.3.1 (#165)

Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.3.0 to 2.3.1.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.3.0...v2.3.1)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🏗️ 重构 TOS 模块

* 🩹 补充返回值类型标注

* 🐛 写错变量了

* 🐛 缺个 else

* 🐛 忘记声明变量

* 🐛 忘记初始化变量

* 🎨 去除不需要的 else

* 🎨 去除不需要的判断

* 🎨 减少一次函数调用

* 🐛 写错命令了

* ⬆️ Bump nonebot-plugin-orm from 0.2.2 to 0.2.3 (#170)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.2.2 to 0.2.3.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.2.2...v0.2.3)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump black from 23.9.1 to 23.10.0 (#171)

Bumps [black](https://github.com/psf/black) from 23.9.1 to 23.10.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/23.9.1...23.10.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump mypy from 1.6.0 to 1.6.1 (#172)

Bumps [mypy](https://github.com/python/mypy) from 1.6.0 to 1.6.1.
- [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/python/mypy/compare/v1.6.0...v1.6.1)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump playwright from 1.38.0 to 1.39.0 (#169)

Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.38.0 to 1.39.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.38.0...v1.39.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

*  去除开发依赖 lxml-stubs
 添加开发依赖 types-lxml

* 🏗️ 重构 TOP 模块

* 🐛 忘记传参了

* 🐛 忘记判断有没有绑定了

* 🎨 忘记用封好的函数了

* 📝 把 wakatime 的小牌牌放上去 并且格式化

* ⬆️ Bump ruff from 0.1.0 to 0.1.1 (#174)

Bumps [ruff](https://github.com/astral-sh/ruff) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](https://github.com/astral-sh/ruff/compare/v0.1.0...v0.1.1)

---
updated-dependencies:
- dependency-name: ruff
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-plugin-orm from 0.2.3 to 0.2.4 (#173)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.2.3 to 0.2.4.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.2.3...v0.2.4)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🏗️ 把 config 从 utils 里拿出来

* 🔥 orm 搞错用法了

* 🗃️ 创建新的迁移脚本

*  添加插件元数据

* 🐛 导包顺序又错了

*  添加依赖 nonebot-adapter-qq

*  添加依赖 nonebot-plugin-alconna

*  移除依赖 tortoise-orm

* ⬆️ Bump nonebot-plugin-orm from 0.2.4 to 0.3.0 (#175)

* ⬆️ Bump types-lxml from 2023.3.28 to 2023.10.21 (#176)

* ⬆️ Bump black from 23.10.0 to 23.10.1 (#177)

* ⬆️ Bump ruff from 0.1.1 to 0.1.2 (#178)

*  添加debug依赖 viztracer

*  添加开发依赖 nonebot-plugin-orm[default]

*  IO 基础查询功能适配所有平台

* ⬆️ Bump nonebot-plugin-alconna from 0.30.3 to 0.30.6 (#179)

Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.30.3 to 0.30.6.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.30.3...v0.30.6)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🩹 防止在使用其他命令的时候意外触发

* 🚧 暂时去除记录器 待重构

* 🐛 修正输出信息格式

*  TOP 基础查询功能适配所有平台

* ⬆️ Bump ruff from 0.1.2 to 0.1.3 (#180)

* ⬆️ Bump nonebot-plugin-alconna from 0.30.6 to 0.30.7 (#181)

*  TOS 基础查询功能适配所有平台

* 🐛 修复一些输出消息问题

* 🔥 删除一些不需要的常量

* 🔥 把手搓的解析器爆了

* 🏷️ 添加一个不知道有什么用的类型注释

* 🎨 从 black 迁移 到 ruff format
 删除开发依赖 black

*  启用 pyupgrade 规则

*  启用 flake8-2020 规则

*  启用 flake8-annotations 规则

*  启用 flake8-async 规则

*  启用 flake8-bandit 规则

*  启用 flake8-blind-except 规则

*  启用 flake8-boolean-trap 规则

*  启用 flake8-builtins 规则

*  启用 flake8-datetimez 规则

*  启用 flake8-future-annotations 规则

*  启用 flake8-implicit-str-concat 规则

*  启用 flake8-pie 规则

*  启用 flake8-print 规则

*  启用 flake8-raise 规则

*  启用 flake8-return 规则

*  启用 flake8-simplify 规则

*  启用 flake8-use-pathlib 规则

*  启用 pandas-vet 规则

*  启用 tryceratops 规则

*  启用 flynt 规则

*  启用 Perflint 规则

* ⬆️ Bump nonebot-plugin-alconna from 0.30.7 to 0.31.0 (#183)

Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.30.7 to 0.31.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.30.7...v0.31.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-plugin-orm from 0.3.0 to 0.4.0 (#182)

* ⬆️ Bump nonebot-plugin-orm from 0.4.0 to 0.4.1 (#186)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.4.0 to 0.4.1.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.4.0...v0.4.1)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot2 from 2.1.1 to 2.1.2 (#185)

Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.1.1...v2.1.2)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-plugin-alconna from 0.31.0 to 0.31.3 (#187)

Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.31.0 to 0.31.3.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.31.0...v0.31.3)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🐛 修复拼接 url 的 bug

* ⬆️ Bump nonebot-plugin-orm from 0.4.1 to 0.5.0 (#189)

Bumps [nonebot-plugin-orm](https://github.com/nonebot/plugin-orm) from 0.4.1 to 0.5.0.
- [Release notes](https://github.com/nonebot/plugin-orm/releases)
- [Commits](https://github.com/nonebot/plugin-orm/compare/v0.4.1...v0.5.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-orm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump nonebot-plugin-alconna from 0.31.3 to 0.31.7 (#191)

Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.31.3 to 0.31.7.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.31.3...v0.31.7)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump ruff from 0.1.3 to 0.1.4 (#190)

* ⬆️ Bump httpx from 0.25.0 to 0.25.1 (#188)

*  绑定适配所有平台

* ⬆️ Bump nonebot-plugin-alconna from 0.31.7 to 0.32.0 (#192)

Bumps [nonebot-plugin-alconna](https://github.com/nonebot/plugin-alconna) from 0.31.7 to 0.32.0.
- [Release notes](https://github.com/nonebot/plugin-alconna/releases)
- [Commits](https://github.com/nonebot/plugin-alconna/compare/v0.31.7...v0.32.0)

---
updated-dependencies:
- dependency-name: nonebot-plugin-alconna
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ♻️ 重构 recorder

*  添加依赖 nonebot-plugin-apscheduler

* ⬆️ Bump mypy from 1.6.1 to 1.7.0 (#194)

* ⬆️ Bump ruff from 0.1.4 to 0.1.5 (#193)

*  将数据库内存储时间时区切换为UTC

*  添加 iorank 指令

* 🎨 将行长限制改为120

* 🥚 :fkosk:

* 🗃️ 迁移旧版本 sqlite 中的数据

* 🚨 添加 type: ignore

*  更新 PluginMetadata

*  移除所有 nonebot-adapter 依赖

*  移除依赖 aiohttp

*  移除依赖 asyncio
(为什么会有这个)

*  添加开发依赖 nonebot-adapter-onebot

*  添加开发依赖 nonebot-adapter-satori

* 📝 更新 readme

* 🔖 1.0.0.a1

* 🔒️ 修复 Incomplete URL substring sanitization

* 🔒️ 修复 Incomplete URL substring sanitization

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-13 23:37:51 +08:00
cced0ca1d5 🙈 添加 .pyc 到 gnore 2023-09-28 18:41:32 +08:00
2cfcba9b07 🔖 0.4.4 2023-09-21 22:33:55 +08:00
86adf2621a 🐛 修复使用 ID 绑定账号错误的bug 2023-09-21 22:32:27 +08:00
1219aeda8f 🔖 0.4.3 2023-09-21 11:58:21 +08:00
0d78007262 👽️ 由于 osk 封了 aiohttp 所以换 httpx 2023-09-21 11:57:53 +08:00
5dbd01b15c 添加依赖 httpx 2023-09-21 11:55:37 +08:00
scdhh
2a5dd35087 🔖 0.4.2 2023-09-01 00:44:39 +08:00
渣渣120
564c6a8fba 🐛 修复错误判断问题并优化代码 (#145)
* 修复错误判断问题并优化代码

* 修改成 elif

* Update database.py

---------

Co-authored-by: scdhh <51957264+shoucandanghehe@users.noreply.github.com>
2023-09-01 00:41:51 +08:00
dependabot[bot]
1576338383 ⬆️ Bump aiohttp from 3.8.3 to 3.8.5 (#134)
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.8.3 to 3.8.5.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/v3.8.5/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.8.3...v3.8.5)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-13 23:48:32 +08:00
8141b2fec7 🔖 0.4.1.post1 2023-06-12 00:26:09 +08:00
dependabot[bot]
720de49c83 ⬆️ Bump starlette from 0.25.0 to 0.27.0 (#118)
Bumps [starlette](https://github.com/encode/starlette) from 0.25.0 to 0.27.0.
- [Release notes](https://github.com/encode/starlette/releases)
- [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md)
- [Commits](https://github.com/encode/starlette/compare/0.25.0...0.27.0)

---
updated-dependencies:
- dependency-name: starlette
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-06-12 00:19:47 +08:00
scdhh
f600060b9e 🔖 0.4.1 2023-05-31 06:23:39 +08:00
渣渣120
a808bfb7f8 🐛 修复趋势对比错误的数据 (#123) 2023-05-31 06:22:42 +08:00
e5354d39c9 🔖 0.4.0.post1 2023-05-30 06:14:58 +08:00
9d37d05b24 💬 小改段位查询消息样式 2023-05-30 06:08:39 +08:00
d7b6e3cb17 🔖 0.4.0 2023-05-30 04:59:33 +08:00
渣渣120
32d34c93d7 新增查分段指令 (#121)
* 忽略 .idea 文件夹

* 新增查分段指令

* 修复未知段位可能导致程序无限死循环的异常

* 我 keys 呢

* 🎨 整理 import

* 🎨 规范引号

* 🐛 记得await

* ️ 一些优化

* 🐛 多个逗号

* 🚨 修正typing hint

* 🐛 返回值是 tuple 哦

* 🐛 少个逗号

* 🐛 你得删前缀啊

* 🐛 怎么能用 is 呢

* 🐛 记得await

* 试图匹配查询格式

* 💬 小改返回消息样式

* 🎨 修改变量名

* 🐛 修复查询大写问题

* 🐛 使用 get_db 获取数据库对象

---------

Co-authored-by: scdhh <wallfjjd@gmail.com>
2023-05-30 04:57:31 +08:00
972f7e90d2 🔖 0.3.3.post1 2023-02-15 07:52:04 +08:00
dependabot[bot]
fe412d5acd ⬆️ Bump starlette from 0.22.0 to 0.25.0 (#83)
Bumps [starlette](https://github.com/encode/starlette) from 0.22.0 to 0.25.0.
- [Release notes](https://github.com/encode/starlette/releases)
- [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md)
- [Commits](https://github.com/encode/starlette/compare/0.22.0...0.25.0)

---
updated-dependencies:
- dependency-name: starlette
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-15 07:37:31 +08:00
scdhh
ac8d332e69 👷 更改 dependabot 推送分支 2023-01-29 04:56:47 +08:00
2015917ca0 版本推进 2022-12-25 14:59:45 +08:00
dependabot[bot]
264c5c04e9 Bump playwright from 1.28.0 to 1.29.0 (#55)
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.28.0 to 1.29.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.28.0...v1.29.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-25 14:54:45 +08:00
14d646a2d0 允许使用python3.11 2022-12-20 13:26:35 +08:00
dependabot[bot]
d2a33ec5f8 Bump pandas-stubs from 1.5.1.221024 to 1.5.2.221213 (#53) 2022-12-20 04:16:50 +00:00
dependabot[bot]
c4c0faf64b Bump nonebot2 from 2.0.0rc1 to 2.0.0rc2 (#48) 2022-12-20 04:16:01 +00:00
dependabot[bot]
a8e769866f Bump pandas from 1.5.1 to 1.5.2 (#46)
Bumps [pandas](https://github.com/pandas-dev/pandas) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Changelog](https://github.com/pandas-dev/pandas/blob/main/RELEASE.md)
- [Commits](https://github.com/pandas-dev/pandas/compare/v1.5.1...v1.5.2)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-20 12:02:41 +08:00
dependabot[bot]
38595d46b9 Bump ujson from 5.5.0 to 5.6.0 (#51)
Bumps [ujson](https://github.com/ultrajson/ultrajson) from 5.5.0 to 5.6.0.
- [Release notes](https://github.com/ultrajson/ultrajson/releases)
- [Commits](https://github.com/ultrajson/ultrajson/compare/5.5.0...5.6.0)

---
updated-dependencies:
- dependency-name: ujson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-20 12:02:13 +08:00
scdhh
bd08166f45 Merge pull request #54 from shoucandanghehe/dependabot/pip/pylint-2.15.9
Bump pylint from 2.15.5 to 2.15.9
2022-12-20 12:01:34 +08:00
dependabot[bot]
5b1e2a1e28 Bump pylint from 2.15.5 to 2.15.9
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.5 to 2.15.9.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.15.5...v2.15.9)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-19 15:17:51 +00:00
scdhh
903fe34302 Merge pull request #45 from shoucandanghehe/dependabot/pip/playwright-1.28.0
Bump playwright from 1.27.1 to 1.28.0
2022-11-18 10:25:40 +08:00
scdhh
0ea597809f Merge pull request #44 from shoucandanghehe/dependabot/pip/mypy-0.991
Bump mypy from 0.990 to 0.991
2022-11-18 10:25:29 +08:00
dependabot[bot]
58b4c8ab9a Bump playwright from 1.27.1 to 1.28.0
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.27.1 to 1.28.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.27.1...v1.28.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-17 15:24:30 +00:00
dependabot[bot]
e82a9d4747 Bump mypy from 0.990 to 0.991
Bumps [mypy](https://github.com/python/mypy) from 0.990 to 0.991.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.990...v0.991)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-16 15:21:47 +00:00
scdhh
6125190fe0 Merge pull request #43 from shoucandanghehe/dependabot/pip/mypy-0.990
Bump mypy from 0.982 to 0.990
2022-11-08 23:32:13 +08:00
dependabot[bot]
402c30b32a Bump mypy from 0.982 to 0.990
Bumps [mypy](https://github.com/python/mypy) from 0.982 to 0.990.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.982...v0.990)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-08 15:14:02 +00:00
scdhh
4d51afa726 Merge pull request #42 from shoucandanghehe/dependabot/pip/autopep8-2.0.0
Bump autopep8 from 1.7.0 to 2.0.0
2022-11-02 08:53:18 +08:00
dependabot[bot]
4af6170470 Bump autopep8 from 1.7.0 to 2.0.0
Bumps [autopep8](https://github.com/hhatto/autopep8) from 1.7.0 to 2.0.0.
- [Release notes](https://github.com/hhatto/autopep8/releases)
- [Commits](https://github.com/hhatto/autopep8/compare/v1.7.0...v2.0.0)

---
updated-dependencies:
- dependency-name: autopep8
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-02 00:49:14 +00:00
scdhh
98244eed60 Merge pull request #40 from shoucandanghehe/dependabot/pip/pandas-stubs-1.5.1.221024
Bump pandas-stubs from 1.5.0.221012 to 1.5.1.221024
2022-11-02 08:45:54 +08:00
dependabot[bot]
2e222ed6f5 Bump pandas-stubs from 1.5.0.221012 to 1.5.1.221024
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.5.0.221012 to 1.5.1.221024.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.5.0.221012...v1.5.1.221024)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-02 00:42:33 +00:00
scdhh
c224a0f880 Merge pull request #39 from shoucandanghehe/dependabot/pip/pylint-2.15.5
Bump pylint from 2.15.4 to 2.15.5
2022-11-02 08:39:06 +08:00
dependabot[bot]
7df6cb3396 Bump pylint from 2.15.4 to 2.15.5
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.4 to 2.15.5.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.15.4...v2.15.5)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-24 16:34:20 +00:00
scdhh
ee9da6a5e8 Merge pull request #38 from shoucandanghehe/dependabot/pip/nonebot-adapter-onebot-2.1.5
Bump nonebot-adapter-onebot from 2.1.3 to 2.1.5
2022-10-24 00:37:12 +08:00
scdhh
cc3a53aa3b Merge pull request #37 from shoucandanghehe/dependabot/pip/pandas-1.5.1
Bump pandas from 1.5.0 to 1.5.1
2022-10-24 00:36:49 +08:00
scdhh
ea767291a2 Merge pull request #35 from shoucandanghehe/dependabot/pip/playwright-1.27.1
Bump playwright from 1.26.1 to 1.27.1
2022-10-24 00:36:39 +08:00
scdhh
cffe472ad3 Merge pull request #34 from shoucandanghehe/dependabot/pip/pandas-stubs-1.5.0.221012
Bump pandas-stubs from 1.5.0.221003 to 1.5.0.221012
2022-10-24 00:36:29 +08:00
scdhh
6e6b16c6f3 Merge pull request #31 from shoucandanghehe/dependabot/pip/pylint-2.15.4
Bump pylint from 2.15.3 to 2.15.4
2022-10-24 00:36:14 +08:00
dependabot[bot]
bdb0139cf1 Bump nonebot-adapter-onebot from 2.1.3 to 2.1.5
Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.1.3 to 2.1.5.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.1.3...v2.1.5)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-20 15:52:02 +00:00
dependabot[bot]
ad9c7b24a6 Bump pandas from 1.5.0 to 1.5.1
Bumps [pandas](https://github.com/pandas-dev/pandas) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Changelog](https://github.com/pandas-dev/pandas/blob/main/RELEASE.md)
- [Commits](https://github.com/pandas-dev/pandas/compare/v1.5.0...v1.5.1)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-19 15:49:58 +00:00
dependabot[bot]
6285900e16 Bump playwright from 1.26.1 to 1.27.1
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.26.1 to 1.27.1.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.26.1...v1.27.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-13 16:13:02 +00:00
dependabot[bot]
a1d882c122 Bump pandas-stubs from 1.5.0.221003 to 1.5.0.221012
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.5.0.221003 to 1.5.0.221012.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.5.0.221003...v1.5.0.221012)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-12 15:47:18 +00:00
dependabot[bot]
f6d5be7cc0 Bump pylint from 2.15.3 to 2.15.4
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.3 to 2.15.4.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.15.3...v2.15.4)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-10 16:44:25 +00:00
09e18c526a 整理代码 2022-10-09 13:37:16 +08:00
af8fa05394 补回查bot本身的特判 2022-10-09 13:20:19 +08:00
scdhh
e099beeb6b Merge pull request #29 from shoucandanghehe/dependabot/pip/mypy-0.982
Bump mypy from 0.981 to 0.982
2022-10-09 08:55:37 +08:00
scdhh
5f8f8b67b2 Merge pull request #30 from shoucandanghehe/dependabot/pip/pandas-stubs-1.5.0.221003
Bump pandas-stubs from 1.5.0.220926 to 1.5.0.221003
2022-10-09 08:55:11 +08:00
scdhh
a0b6c85637 Merge pull request #28 from shoucandanghehe/dependabot/pip/nonebot2-2.0.0rc1
Bump nonebot2 from 2.0.0b5 to 2.0.0rc1
2022-10-09 08:54:57 +08:00
scdhh
163f0e139a Merge pull request #27 from shoucandanghehe/dependabot/pip/playwright-1.26.1
Bump playwright from 1.26.0 to 1.26.1
2022-10-09 08:54:44 +08:00
dependabot[bot]
9a02eb5cce Bump pandas-stubs from 1.5.0.220926 to 1.5.0.221003
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.5.0.220926 to 1.5.0.221003.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.5.0.220926...v1.5.0.221003)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 15:51:59 +00:00
dependabot[bot]
2f9849c74e Bump mypy from 0.981 to 0.982
Bumps [mypy](https://github.com/python/mypy) from 0.981 to 0.982.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.981...v0.982)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 15:51:25 +00:00
dependabot[bot]
650dfb0669 Bump nonebot2 from 2.0.0b5 to 2.0.0rc1
Bumps [nonebot2](https://github.com/nonebot/nonebot2) from 2.0.0b5 to 2.0.0rc1.
- [Release notes](https://github.com/nonebot/nonebot2/releases)
- [Changelog](https://github.com/nonebot/nonebot2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nonebot/nonebot2/compare/v2.0.0-beta.5...v2.0.0-rc.1)

---
updated-dependencies:
- dependency-name: nonebot2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 15:50:51 +00:00
dependabot[bot]
a0e0ff2fa3 Bump playwright from 1.26.0 to 1.26.1
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.26.0 to 1.26.1.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.26.0...v1.26.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-29 16:14:50 +00:00
scdhh
f5188594f1 Merge pull request #24 from shoucandanghehe/dependabot/pip/mypy-0.981
Bump mypy from 0.971 to 0.981
2022-09-28 09:35:40 +08:00
scdhh
26374a96fb Merge pull request #25 from shoucandanghehe/dependabot/pip/playwright-1.26.0
Bump playwright from 1.25.2 to 1.26.0
2022-09-28 09:35:31 +08:00
scdhh
67ccf465ce Merge pull request #26 from shoucandanghehe/dependabot/pip/aiohttp-3.8.3
Bump aiohttp from 3.8.1 to 3.8.3
2022-09-28 09:35:22 +08:00
dependabot[bot]
6bcde5cf74 Bump playwright from 1.25.2 to 1.26.0
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.25.2 to 1.26.0.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.25.2...v1.26.0)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:31:49 +00:00
dependabot[bot]
1fffa560fb Bump aiohttp from 3.8.1 to 3.8.3
Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.8.1 to 3.8.3.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](https://github.com/aio-libs/aiohttp/compare/v3.8.1...v3.8.3)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:31:49 +00:00
dependabot[bot]
d995bfe74f Bump mypy from 0.971 to 0.981
Bumps [mypy](https://github.com/python/mypy) from 0.971 to 0.981.
- [Release notes](https://github.com/python/mypy/releases)
- [Commits](https://github.com/python/mypy/compare/v0.971...v0.981)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:31:44 +00:00
scdhh
9437d99ec4 Merge pull request #18 from shoucandanghehe/dependabot/pip/types-ujson-5.5.0
Bump types-ujson from 5.4.0 to 5.5.0
2022-09-28 09:28:24 +08:00
dependabot[bot]
4aed7862a3 Bump types-ujson from 5.4.0 to 5.5.0
Bumps [types-ujson](https://github.com/python/typeshed) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/python/typeshed/releases)
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-ujson
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:22:32 +00:00
scdhh
8ee6648d2a Merge pull request #19 from shoucandanghehe/dependabot/pip/ujson-5.5.0
Bump ujson from 5.4.0 to 5.5.0
2022-09-28 09:16:50 +08:00
scdhh
1e0ca7149d Merge pull request #20 from shoucandanghehe/dependabot/pip/pandas-1.5.0
Bump pandas from 1.4.4 to 1.5.0
2022-09-28 09:16:33 +08:00
scdhh
dafb4352fa Merge pull request #21 from shoucandanghehe/dependabot/pip/pylint-2.15.3
Bump pylint from 2.15.0 to 2.15.3
2022-09-28 09:16:20 +08:00
dependabot[bot]
ae74cdbc0c Bump pandas from 1.4.4 to 1.5.0
Bumps [pandas](https://github.com/pandas-dev/pandas) from 1.4.4 to 1.5.0.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Changelog](https://github.com/pandas-dev/pandas/blob/main/RELEASE.md)
- [Commits](https://github.com/pandas-dev/pandas/compare/v1.4.4...v1.5.0)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:08:28 +00:00
dependabot[bot]
364717f049 Bump ujson from 5.4.0 to 5.5.0
Bumps [ujson](https://github.com/ultrajson/ultrajson) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/ultrajson/ultrajson/releases)
- [Commits](https://github.com/ultrajson/ultrajson/compare/5.4.0...5.5.0)

---
updated-dependencies:
- dependency-name: ujson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:08:04 +00:00
dependabot[bot]
a05260ba4a Bump pylint from 2.15.0 to 2.15.3
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.15.0 to 2.15.3.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.15.0...v2.15.3)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 01:07:52 +00:00
scdhh
a80d9586ff Merge pull request #23 from shoucandanghehe/dependabot/pip/pandas-stubs-1.5.0.220926
Bump pandas-stubs from 1.4.4.220906 to 1.5.0.220926
2022-09-28 09:04:42 +08:00
d0a0baa275 拆分io部分 2022-09-28 09:04:21 +08:00
dependabot[bot]
625fc895ea Bump pandas-stubs from 1.4.4.220906 to 1.5.0.220926
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.4.220906 to 1.5.0.220926.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.4.220906...v1.5.0.220926)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 15:57:19 +00:00
scdhh
3b12d74193 Merge pull request #15 from shoucandanghehe/dependabot/pip/pandas-stubs-1.4.4.220906
Bump pandas-stubs from 1.4.3.220829 to 1.4.4.220906
2022-09-07 01:14:45 +08:00
scdhh
359f3964fb Merge pull request #14 from shoucandanghehe/dependabot/pip/pandas-1.4.4
Bump pandas from 1.4.3 to 1.4.4
2022-09-07 01:14:36 +08:00
dependabot[bot]
e655737935 Bump pandas-stubs from 1.4.3.220829 to 1.4.4.220906
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.3.220829 to 1.4.4.220906.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.3.220829...v1.4.4.220906)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-06 15:52:21 +00:00
dependabot[bot]
98cdf6a529 Bump pandas from 1.4.3 to 1.4.4
Bumps [pandas](https://github.com/pandas-dev/pandas) from 1.4.3 to 1.4.4.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Changelog](https://github.com/pandas-dev/pandas/blob/main/RELEASE.md)
- [Commits](https://github.com/pandas-dev/pandas/compare/v1.4.3...v1.4.4)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-01 15:59:37 +00:00
scdhh
53379eb951 Merge pull request #13 from shoucandanghehe/dependabot/pip/pandas-stubs-1.4.3.220829
Bump pandas-stubs from 1.4.3.220822 to 1.4.3.220829
2022-08-30 16:40:55 +08:00
scdhh
4567764079 Merge pull request #12 from shoucandanghehe/dependabot/pip/pylint-2.15.0
Bump pylint from 2.14.5 to 2.15.0
2022-08-30 16:40:47 +08:00
scdhh
60d6e487d2 Merge pull request #11 from shoucandanghehe/dependabot/pip/playwright-1.25.2
Bump playwright from 1.25.1 to 1.25.2
2022-08-30 16:40:38 +08:00
dependabot[bot]
09c57f52ea Bump pandas-stubs from 1.4.3.220822 to 1.4.3.220829
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.3.220822 to 1.4.3.220829.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.3.220822...v1.4.3.220829)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-29 16:06:46 +00:00
dependabot[bot]
bab4b06de0 Bump pylint from 2.14.5 to 2.15.0
Bumps [pylint](https://github.com/PyCQA/pylint) from 2.14.5 to 2.15.0.
- [Release notes](https://github.com/PyCQA/pylint/releases)
- [Commits](https://github.com/PyCQA/pylint/compare/v2.14.5...v2.15.0)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-26 15:46:36 +00:00
dependabot[bot]
175daafe5d Bump playwright from 1.25.1 to 1.25.2
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.25.1 to 1.25.2.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.25.1...v1.25.2)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 15:53:19 +00:00
scdhh
a2d8bc55cc Merge pull request #10 from shoucandanghehe/dependabot/pip/pandas-stubs-1.4.3.220822
Bump pandas-stubs from 1.4.3.220815 to 1.4.3.220822
2022-08-23 00:14:47 +08:00
dependabot[bot]
d1a2a20e13 Bump pandas-stubs from 1.4.3.220815 to 1.4.3.220822
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.3.220815 to 1.4.3.220822.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.3.220815...v1.4.3.220822)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 15:49:43 +00:00
scdhh
e32a32dee0 Merge pull request #8 from shoucandanghehe/dependabot/pip/pandas-stubs-1.4.3.220815
Bump pandas-stubs from 1.4.3.220807 to 1.4.3.220815
2022-08-22 16:51:46 +08:00
scdhh
540b01649d Merge pull request #9 from shoucandanghehe/dependabot/pip/playwright-1.25.1
Bump playwright from 1.24.1 to 1.25.1
2022-08-22 16:51:34 +08:00
dependabot[bot]
f224af7aa4 Bump playwright from 1.24.1 to 1.25.1
Bumps [playwright](https://github.com/Microsoft/playwright-python) from 1.24.1 to 1.25.1.
- [Release notes](https://github.com/Microsoft/playwright-python/releases)
- [Commits](https://github.com/Microsoft/playwright-python/compare/v1.24.1...v1.25.1)

---
updated-dependencies:
- dependency-name: playwright
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-19 15:56:06 +00:00
dependabot[bot]
c5db3fef3f Bump pandas-stubs from 1.4.3.220807 to 1.4.3.220815
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.3.220807 to 1.4.3.220815.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.3.220807...v1.4.3.220815)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-16 15:50:27 +00:00
scdhh
884cc08d77 Merge pull request #6 from shoucandanghehe/dependabot/pip/nonebot-adapter-onebot-2.1.3
Bump nonebot-adapter-onebot from 2.1.2 to 2.1.3
2022-08-12 10:10:38 +08:00
dependabot[bot]
b30d5e008d Bump nonebot-adapter-onebot from 2.1.2 to 2.1.3
Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.1.2...v2.1.3)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-11 15:51:37 +00:00
scdhh
0a3e265272 Merge pull request #5 from shoucandanghehe/dependabot/pip/nonebot-adapter-onebot-2.1.2
Bump nonebot-adapter-onebot from 2.1.1 to 2.1.2
2022-08-11 00:30:54 +08:00
dependabot[bot]
b32c2f1895 Bump nonebot-adapter-onebot from 2.1.1 to 2.1.2
Bumps [nonebot-adapter-onebot](https://github.com/nonebot/adapter-onebot) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/nonebot/adapter-onebot/releases)
- [Commits](https://github.com/nonebot/adapter-onebot/compare/v2.1.1...v2.1.2)

---
updated-dependencies:
- dependency-name: nonebot-adapter-onebot
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-10 16:26:14 +00:00
d62c53031e 只在bot结束运行的时候写入缓存 2022-08-10 15:20:37 +08:00
61b671354b 版本推进 2022-08-10 14:11:17 +08:00
3f24dc2f1d Add Release CI 2022-08-10 14:10:13 +08:00
scdhh
c63bb52540 Merge pull request #4 from shoucandanghehe/dependabot/pip/autopep8-1.7.0
Bump autopep8 from 1.6.0 to 1.7.0
2022-08-10 04:37:38 +08:00
dependabot[bot]
a0bc307aa6 Bump autopep8 from 1.6.0 to 1.7.0
Bumps [autopep8](https://github.com/hhatto/autopep8) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/hhatto/autopep8/releases)
- [Commits](https://github.com/hhatto/autopep8/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: autopep8
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-09 15:50:44 +00:00
d3258c2bb7 整理代码 2022-08-09 02:50:06 +08:00
b320a23c77 将数据库操作封装成类,并添加数据库路径的config选项 2022-08-09 02:12:29 +08:00
69e4cb97e3 import config 2022-08-09 01:39:45 +08:00
c6f83230c8 修复写入缓存时 传递了错误的变量的bug 2022-08-08 13:44:16 +08:00
e473dca4df 对于io_data_processor:
1.将请求相关封装成了Request类
2.新增了获取cookies后使用aiohttp请求的机制,理论上可以提速+减少不必要的性能开销,并且将cookies存储至cache
3.整理代码
新增config.py,用于配置cache路径
添加依赖项Brotli
2022-08-08 13:32:31 +08:00
scdhh
68028cf3d9 Merge pull request #3 from shoucandanghehe/dependabot/pip/pandas-stubs-1.4.3.220807
Bump pandas-stubs from 1.4.3.220801 to 1.4.3.220807
2022-08-08 13:22:22 +08:00
dependabot[bot]
10929bab03 Bump pandas-stubs from 1.4.3.220801 to 1.4.3.220807
Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 1.4.3.220801 to 1.4.3.220807.
- [Release notes](https://github.com/pandas-dev/pandas-stubs/releases)
- [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md)
- [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v1.4.3.220801...v1.4.3.220807)

---
updated-dependencies:
- dependency-name: pandas-stubs
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-08 01:27:02 +00:00
scdhh
8e5e7d3c33 Create dependabot.yml 2022-08-08 08:56:40 +08:00
ec04af21d6 版本推进 2022-08-07 00:43:31 +08:00
2aef281e8c 修复正确请求到api后没有正确关闭浏览器标签页导致内存溢出的bug 2022-08-07 00:42:59 +08:00
2be62140ac 修复关闭数据库时错误使用await的错误 2022-08-07 00:39:42 +08:00
scdhh
88ba7cd3af 引入pylint对代码进行检查
代码规范:使用PEP8推荐的命名规范
删除Request模块,改为每个游戏的processor单独实现,因为每个游戏的api请求都不太一样
对于io_data_processor:
1. 引入了playwright以应对api套的cloudflare五秒盾
对于top_data_processor:
1. 添加了lxml和pandas的stubs库,并修复了所有type hint错误
对于sql:
1. 使用全局变量保存数据库连接对象,理论上运行一次只会连接一次数据库
2. 移动初始化数据库的hook函数到sql.py
其他:
优化代码
版本推进
2022-08-06 00:56:05 +00:00
5807a8c5fc 更新依赖 2022-07-29 04:48:54 +08:00
18b0d0033c 删除空行 2022-07-29 04:18:07 +08:00
9478ce9c71 修复top绑定时错误处理不存在的用户名的bug 2022-07-29 04:17:04 +08:00
f336b725d0 删除.pop 2022-07-29 04:03:04 +08:00
1d4b24a22b 修复top错误判断用户存在的bug 2022-07-29 04:02:42 +08:00
92619a9692 添加一些自称 2022-07-29 03:46:36 +08:00
35f799ee89 添加TOP查询的支持 2022-07-29 03:46:27 +08:00
scdhh
8fdffca530 Merge pull request #2 from Richard969/main
添加一些自称
2022-07-28 04:27:55 +08:00
Richard969
fd6e2e2367 添加一些自称 2022-07-28 02:18:37 +08:00
8ed1c20feb 修复tos查询游戏数据时没有有效记录会爆炸的bug 2022-07-25 04:11:42 +08:00
e5abc99590 tos增加一种命令前缀 2022-07-25 04:10:23 +08:00
d6449ddf8c 删除不需要的import 2022-07-24 17:35:41 +08:00
dcbab47833 修复命令前缀大写不能正确识别的bug 2022-07-24 17:25:06 +08:00
scdhh
e65c50e107 Update README.md 2022-07-24 17:25:06 +08:00
4525b84fc4 修复查AT时不能正确识别的bug 2022-07-24 17:25:06 +08:00
6207cdb3d9 修复IO输入用户名时大写查询爆炸的bug 2022-07-24 17:25:06 +08:00
f1291a9923 修复所有type hint(当时写的时候mypy炸了
使用神秘新架构
独立request模块
版本推进
fixed #1 [BUG] 茶服无法查询用户名内带有大写字母的用户
2022-07-24 17:24:37 +08:00
scdhh
0d2b37e78a Create codeql-analysis.yml 2022-05-26 07:38:53 +08:00
scdhh
a8998b01a7 Create LICENSE 2022-05-26 07:35:48 +08:00
df6cb71e3f 添加了对查bot自身的情况的特判 2022-05-25 18:00:09 +08:00
2a19b9fe4c 修复IO绑定用户时 用户不存在导致报错和错误绑定的bug 2022-05-25 14:27:27 +08:00
a77e190cf7 版本推进 2022-05-24 19:01:58 +08:00
c9e7923243 格式化代码 2022-05-24 18:58:19 +08:00
1569e71da9 更新README 2022-05-24 18:49:08 +08:00
da4c3c01a6 移除依赖项nb-cli,并添加nonebot2作为新依赖 2022-05-24 18:48:32 +08:00
9786a1325b 添加开发依赖autopep8 2022-05-24 18:42:55 +08:00
66 changed files with 7619 additions and 1578 deletions

12
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
target-branch: "main"
schedule:
interval: "daily"

49
.github/workflows/Release.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: Release CI
on:
push:
tags:
- "*"
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
shell: bash
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: "poetry"
- run: poetry install
shell: bash
- name: Get Version
id: version
run: |
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
echo "TAG_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Check Version
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION
run: exit 1
- name: Build Package
run: poetry build
- name: Publish Package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish Package to GitHub Release
run: gh release create ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl -t "🔖 ${{ steps.version.outputs.TAG_NAME }}" --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

72
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '17 6 * * 5'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

20
.gitignore vendored
View File

@@ -1 +1,21 @@
.idea
dist
test_*
Untitled*
*copy*
.vscode
*dev*
*_cache*
*backup*
*.pyc
node_modules
.prettier*
package.json
pnpm-lock.yaml
*.drawio.svg
package-lock.json
*Zone.Identifier
.env*
bot.py
TODO
*.fish

661
LICENSE Normal file
View File

@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

101
README.md
View File

@@ -1,40 +1,89 @@
TETRIS Stats
============
<div align="center">
一个基于nonebot2的用于查询TETRIS相关游戏玩家数据的插件
目前支持
* [TETR.IO](https://tetr.io/)
* [茶服](https://teatube.cn/tos/)
<p align="center">
<img src="img/logo.svg" width="200" height="200" alt="logo" title="Tetris Stats"></a>
</p>
计划支持
* [TOP](http://tetrisonline.pl/)
# Tetris Stats
安装
----
✨ 一款基于 [NoneBot2](https://github.com/nonebot/nonebot2) 的用于查询 Tetris 相关游戏玩家数据的插件 ✨
* 使用 pip
</div>
<p align="center">
<a href="https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats/blob/main/LICENSE">
<img
src="https://img.shields.io/github/license/shoucandanghehe/nonebot-plugin-tetris-stats"
alt="License"
/>
</a>
<a href="https://www.python.org/">
<img
src="https://img.shields.io/badge/Python-3.10+-blue"
alt="Python"
/>
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-tetris-stats">
<img
src="https://img.shields.io/pypi/v/nonebot-plugin-tetris-stats"
alt="PyPi"
/>
</a>
<a href="https://github.com/charliermarsh/ruff">
<img
src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json"
alt="Ruff"
/>
</a>
<a href="https://gitmoji.dev">
<img
src="https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat-square"
alt="Gitmoji"
/>
</a>
<a href="https://wakatime.com/badge/user/138b2226-8e02-42be-b99d-35c05198836f/project/65f5bdf7-45ec-479a-8dd2-18c498c910ca">
<img
src="https://wakatime.com/badge/user/138b2226-8e02-42be-b99d-35c05198836f/project/65f5bdf7-45ec-479a-8dd2-18c498c910ca.svg"
alt="wakatime"
/>
</a>
</p>
## ✨ 目前支持的游戏
- [TETR.IO](https://tetr.io/)
- [茶服](https://teatube.cn/tos/)
- [TOP](http://tetrisonline.pl/)
## 🚀 安装
- 使用 nb-cli
```bash
nb plugin install nonebot-plugin-tetris-stats
```
- 使用 poetry
```bash
poetry add nonebot-plugin-tetris-stats
```
- 使用 pip ~~不推荐~~
```bash
pip install nonebot-plugin-tetris-stats
```
使用
----
## ♿️ 使用
参考NoneBot2文档 [加载插件](https://v2.nonebot.dev/docs/tutorial/plugin/load-plugin/)
- 参考 NoneBot2 文档 [加载插件](https://nonebot.dev/docs/tutorial/create-plugin#%E5%8A%A0%E8%BD%BD%E6%8F%92%E4%BB%B6)
依赖
----
## 🎉 鸣谢
目前只支持 `OneBot V11` 协议
- [NoneBot2](https://v2.nonebot.dev/)
- 所有为机器人生态做出贡献的人❤️
鸣谢
----
## 📝 开源
* [NoneBot2](https://v2.nonebot.dev/)
* [OneBot](https://onebot.dev/)
开源
----
本项目使用[MIT](https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats/blob/main/LICENSE)许可证开源
本项目使用 [AGPL-3.0](https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats/blob/main/LICENSE) 许可证开源

7
img/logo.svg Normal file
View File

@@ -0,0 +1,7 @@
<svg width="71" height="71" viewBox="0 0 71 71" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M53.1133 39.2642L42.3935 49.9446C41.8086 50.5274 41.5161 50.8188 41.1788 50.928C40.8822 51.024 40.5626 51.024 40.2659 50.928C39.9287 50.8188 39.6362 50.5274 39.0512 49.9446L30.2776 41.2032L21.5041 49.9446C20.9191 50.5274 20.6266 50.8188 20.2893 50.928C19.9927 51.024 19.6731 51.024 19.3764 50.928C19.0392 50.8188 18.7467 50.5274 18.1617 49.9446L16.1772 47.9673L30.2776 33.9187L39.2299 42.8381C40.0952 43.7002 41.498 43.7002 42.3633 42.8381L53.1133 32.1276V39.2642Z" fill="#EA5252"/>
<path d="M57.5446 34.8491L59.9407 32.4618C60.5256 31.879 60.8181 31.5876 60.9277 31.2516C61.0241 30.956 61.0241 30.6376 60.9277 30.342C60.8181 30.006 60.5256 29.7146 59.9407 29.1318L57.5439 26.7438C57.5444 26.7619 57.5446 26.78 57.5446 26.7982L57.5446 34.8491Z" fill="#EA5252"/>
<path d="M55.3835 24.5913C55.3653 24.5908 55.3472 24.5906 55.3289 24.5906L46.9514 24.5906L49.4959 22.0554C50.0809 21.4726 50.3734 21.1812 50.7107 21.072C51.0073 20.976 51.3269 20.976 51.6236 21.072C51.9608 21.1812 52.2533 21.4726 52.8383 22.0554L55.3835 24.5913Z" fill="#EA5252"/>
<path d="M42.5201 29.0057L40.7224 30.7968L31.9488 22.0554C31.3638 21.4726 31.0714 21.1812 30.7341 21.072C30.4374 20.976 30.1179 20.976 29.8212 21.072C29.4839 21.1812 29.1914 21.4726 28.6065 22.0554L11.0593 39.5382C10.4744 40.121 10.1819 40.4124 10.0723 40.7484C9.9759 41.044 9.9759 41.3624 10.0723 41.658C10.1819 41.994 10.4744 42.2854 11.0593 42.8682L13.0438 44.8454L28.7109 29.2358C29.5762 28.3737 30.9791 28.3737 31.8443 29.2358L40.7966 38.1552L49.9799 29.0057H42.5201Z" fill="#EA5252"/>
<circle cx="35.5" cy="35.5" r="29.5" stroke="#EA5252" stroke-width="2"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -1,137 +0,0 @@
from nonebot.log import logger
from asyncio import gather
import aiohttp
# 封装请求函数
async def request(Url: str) -> dict[str, bool|dict[str, any]]:
data = {}
try:
async with aiohttp.ClientSession() as session:
async with session.get(Url) as resp:
data['Status'] = True
data['Data'] = await resp.json()
data['Success'] = data['Data']['success']
except aiohttp.client_exceptions.ClientConnectorError as e:
logger.error(f'[TETRIS STATS] IODataProcessing.request: 请求错误\n{e}')
data['Status'] = False
finally:
return data
# 获取用户数据
async def getUserData(userName: str = None, userID: str = None) -> dict[str, dict[str, any]]:
if userName is not None and userID is None:
userDataUrl = f'https://ch.tetr.io/api/users/{userName}'
userData = await request(Url=userDataUrl)
elif userName is None and userID is not None:
userDataUrl = f'https://ch.tetr.io/api/users/{userID}'
userData = await request(Url=userDataUrl)
else:
raise ValueError('[TETRIS STATS] IODataProcessing.getUserData: 参数错误')
return userData
# 获取Solo数据
async def getSoloData(userName: str = None, userID: str = None) -> dict[str, dict[str, any]]:
if userName is not None and userID is None:
userSoloUrl = f'https://ch.tetr.io/api/users/{userName}/records'
soloData = await request(Url = userSoloUrl)
elif userName is None and userID is not None:
userSoloUrl = f'https://ch.tetr.io/api/users/{userID}/records'
soloData = await request(Url = userSoloUrl)
else:
raise ValueError('[TETRIS STATS] IODataProcessing.getSoloData: 参数错误')
return soloData
# 获取用户ID
async def getUserID(userData: dict = None, userName: str = None) -> str:
if userName is not None and userData is None:
userData = await getUserData(userName=userName)
elif userData is None and userName is None:
raise ValueError('[TETRIS STATS] IODataProcessing.getUserID: 参数错误')
return userData['Data']['data']['user']['_id']
# 获取排位统计数据
async def getLeagueStats(userData: dict) -> dict[str, bool|int|str|float]:
league = userData['Data']['data']['user']['league']
leagueStats = {}
if league['gamesplayed'] == 0:
leagueStats['Played'] = False
else:
leagueStats['Played'] = True
leagueStats['PPS'] = league['pps']
leagueStats['APM'] = league['apm']
leagueStats['VS'] = 0 if league['vs'] is None else league['vs']
leagueStats['Rank'] = False if league['rank'] == 'z' else league['rank'].upper()
if league['rating'] != -1:
leagueStats['Ranked'] = True
leagueStats['Rating'] = round(league['rating'], 2)
leagueStats['Glicko'] = round(league['glicko'], 2)
leagueStats['RD'] = round(league['rd'], 2)
else:
leagueStats['Ranked'] = False
leagueStats['Standing'] = league['standing']
leagueStats['LPM'] = round((league['pps'] * 24), 2)
leagueStats['APL'] = round((leagueStats['APM'] / leagueStats['LPM']), 2)
leagueStats['ADPM'] = round((leagueStats['VS'] * 0.6), 2)
leagueStats['ADPL'] = round((leagueStats['ADPM'] / leagueStats['LPM']), 2)
return leagueStats
# 获取40L统计数据
async def getSprintStats(soloData: dict) -> dict[str, bool|int|float]:
sprintStats = {}
if soloData['Data']['data']['records']['40l']['record'] is None:
sprintStats['Played'] = False
else:
sprintStats['Played'] = True
sprintStats['Rank'] = False if soloData['Data']['data']['records']['40l']['rank'] is None else soloData['Data']['data']['records']['40l']['rank']
sprintStats['Time'] = round(soloData['Data']['data']['records']['40l']['record']['endcontext']['finalTime'] / 1000, 2)
return sprintStats
# 获取Blitz统计数据
async def getBlitzStats(soloData: dict) -> dict[str, bool|int]:
blitzStats = {}
if soloData['Data']['data']['records']['blitz']['record'] is None:
blitzStats['Played'] = False
else:
blitzStats['Played'] = True
blitzStats['Rank'] = False if soloData['Data']['data']['records']['blitz']['rank'] is None else soloData['Data']['data']['records']['blitz']['rank']
blitzStats['Score'] = soloData['Data']['data']['records']['blitz']['record']['endcontext']['score']
return blitzStats
# 生成消息
async def generateMessage(userName: str = None, userID: str = None) -> str:
userData, soloData = await gather(getUserData(userName = userName, userID = userID), getSoloData(userName = userName, userID = userID))
if userData['Status'] is False:
return '用户信息请求失败'
if userData['Success'] is False:
return f'用户信息请求错误:\n{userData["Data"]["error"]}'
userName = userData['Data']['data']['user']['username'].upper()
leagueStats = await getLeagueStats(userData)
message = ''
if leagueStats['Played'] is False:
message += f'用户 {userName} 没有排位统计数据'
else:
if leagueStats['Rank'] is False and leagueStats['Ranked'] is False:
message += f'用户 {userName} 暂未完成定级赛'
elif leagueStats['Rank'] is False and leagueStats['Ranked'] is True:
message += f'用户 {userName} 暂无段位, {leagueStats["Rating"]} TR'
else:
message += f'{leagueStats["Rank"]} 段用户 {userName} {leagueStats["Rating"]} TR (#{leagueStats["Standing"]})'
message += f', 段位分 {leagueStats["Glicko"]}±{leagueStats["RD"]}, 最近十场的数据:' if leagueStats['Ranked'] is True else ', 最近十场的数据:'
message += f'\nL\'PM: {leagueStats["LPM"]} ( {leagueStats["PPS"]} pps )'
message += f'\nAPM: {leagueStats["APM"]} ( x{leagueStats["APL"]} )'
if leagueStats["VS"] != 0:
message += f'\nADPM: {leagueStats["ADPM"]} ( x{leagueStats["ADPL"]} ) ( {leagueStats["VS"]}vs )'
if soloData['Status'] is False:
return f'{message}\nSolo统计数据请求失败'
sprintStats = await getSprintStats(soloData)
blitzStats = await getBlitzStats(soloData)
if sprintStats['Played'] is True:
message += f'\n40L: {sprintStats["Time"]}s'
if sprintStats['Rank'] is not False:
message += f' ( #{sprintStats["Rank"]} )'
if blitzStats['Played'] is True:
message += f'\nBlitz: {blitzStats["Score"]}'
if blitzStats['Rank'] is not False:
message += f' ( #{blitzStats["Rank"]} )'
return message

View File

@@ -1,69 +0,0 @@
from re import match
# userBind
async def handleBindMessage(message: str, gameType: str) -> dict[str, bool | str]:
_CMD_ALIASES = {'IO': ['io绑定', 'iobind'],
'TOP': ['top绑定', 'topbind']}
# 剔除命令前缀
for i in _CMD_ALIASES[gameType]:
if message.startswith(i):
message = message.replace(i, '')
message = message.strip()
break
if message == '' or message.isspace():
return {'Success': False, 'Type': None, 'Message': '用户名为空'}
else:
return await checkName(message, gameType)
# statsQuery
async def handleStatsQueryMessage(message: str, gameType: str) -> dict[str, bool | str]:
_CMD_ALIASES = {'IO': ['io查', 'iostats'],
'TOS': ['tos查', 'tostats', '茶服查', '茶服stats'],
'TOP': ['top查', 'topstats']}
_ME = ['', '自己', '', '', 'me']
message = (message.strip()).lower()
# 剔除命令前缀
for i in _CMD_ALIASES[gameType]:
if message.startswith(i):
message = message.replace(i, '')
message = message.strip()
break
if message == '' or message.isspace():
return {'Success': False, 'Type': None, 'Message': '用户名为空'}
else:
if message.startswith('[cq:at,qq='):
try:
QQNumber = int((str(message)).split(
'[cq:at,qq=')[1].split(']')[0])
except ValueError:
return {'Success': False, 'Type': None, 'Message': 'QQ号码不合法'}
else:
return {'Success': True, 'Type': 'AT', 'Message': None, 'QQNumber': QQNumber}
elif message in _ME:
return {'Success': True, 'Type': 'ME', 'Message': None}
else:
return await checkName(message, gameType)
async def checkName(name: str, gameType: str) -> dict[str, bool | str]:
if gameType == 'IO':
if match(r'^[a-f0-9]{24}$', name):
return {'Success': True, 'Type': 'ID', 'Message': None, 'User': name}
elif match(r'^[a-zA-Z0-9_-]{3,16}$', name):
return {'Success': True, 'Type': 'Name', 'Message': None, 'User': name}
else:
return {'Success': False, 'Type': None, 'Message': '用户名不合法'}
elif gameType == 'TOP':
if match(r'^[a-zA-Z0-9_]{1,16}$', name):
return {'Success': True, 'Type': 'Name', 'Message': None, 'User': name}
else:
return {'Success': False, 'Type': None, 'Message': '用户名不合法'}
elif gameType == 'TOS':
if (match(r'^(?!\.)(?!com[0-9]$)(?!con$)(?!lpt[0-9]$)(?!nul$)(?!prn$)[^\-][^\+][^\|\*\?\\\s\!:<>/$"]*[^\.\|\*\?\\\s\!:<>/$"]+$', name)
and name.isdigit() is False
and 2 <= len(name) <= 18):
# 虽然我也不想这么长 但是似乎确实得这么长
return {'Success': True, 'Type': 'Name', 'Message': None, 'User': name}
elif name.isdigit() is True:
return {'Success': True, 'Type': 'QQ', 'Message': None, 'QQNumber': name}
else:
return {'Success': False, 'Type': None, 'Message': '用户名不合法'}

View File

@@ -1,52 +0,0 @@
from nonebot.log import logger
import sqlite3
import os
_DB_FILE = 'data/nonebot-plugin-tetris-stats/data.db'
# 初始化数据库
async def initDB():
if not os.path.exists(os.path.dirname(_DB_FILE)):
os.makedirs(os.path.dirname(_DB_FILE))
db = sqlite3.connect(_DB_FILE)
cursor = db.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS IOBIND
(QQ INTEGER NOT NULL,
USER TEXT NOT NULL)''')
cursor.execute('''CREATE TABLE IF NOT EXISTS TOPBIND
(QQ INTEGER NOT NULL,
USER TEXT NOT NULL)''')
db.commit()
db.close()
logger.info('数据库初始化完成')
# 查询绑定信息
async def queryBindInfo(QQNumber: int, gameType: str) -> dict:
db = sqlite3.connect(_DB_FILE)
cursor = db.cursor()
cursor.execute(f'SELECT USER FROM {gameType}BIND WHERE QQ = {QQNumber}')
user = cursor.fetchone()
db.commit()
db.close()
if user is None:
return {'Hit': False, 'User': None}
else:
return {'Hit': True, 'User': user[0]}
# 写入绑定信息
async def writeBindInfo(QQNumber: int, user: str, gameType: str) -> str:
info = await queryBindInfo(QQNumber, gameType)
db = sqlite3.connect(_DB_FILE)
cursor = db.cursor()
if info['Hit'] is True:
cursor.execute(
f'UPDATE {gameType}BIND SET USER = ? WHERE QQ = ?', (user, QQNumber))
message = '更新成功'
elif info['Hit'] is False:
cursor.execute(
f'INSERT INTO {gameType}BIND (QQ, USER) VALUES (?, ?)', (QQNumber, user))
message = '绑定成功'
db.commit()
db.close()
return message

View File

@@ -1,143 +0,0 @@
from nonebot.log import logger
from asyncio import gather
import aiohttp
# 封装请求函数
async def request(Url: str) -> dict[str, bool|dict[str, any]]:
data = {}
try:
async with aiohttp.ClientSession() as session:
async with session.get(Url) as resp:
data['Status'] = True
data['Data'] = await resp.json()
data['Success'] = data['Data']['success']
except aiohttp.client_exceptions.ClientConnectorError as e:
logger.error(f'[TETRIS STATS] TOSDataProcessing.request: 请求错误\n{e}')
data['Status'] = False
finally:
return data
# 获取用户信息
async def getUserInfo(userName: str = None, teaID: int = None) -> dict[str, bool|dict[str, any]]:
if userName is not None and teaID is None:
userDataUrl = f'https://teatube.cn:8888/getUsernameInfo?username={userName}'
userInfo = await request(Url=userDataUrl)
elif teaID is not None and userName is None:
userDataUrl = f'https://teatube.cn:8888/getTeaIdInfo?teaId={teaID}'
userInfo = await request(Url=userDataUrl)
else:
raise ValueError('[TETRIS STATS] TOSDataProcessing.getUserInfo: 参数错误')
return userInfo
# 获取用户数据
async def getUserData(userName: str = None, teaID: int = None, otherParameter: str = '') -> dict[str, bool|dict[str, any]]:
if userName is not None and teaID is None:
userDataUrl = f'https://teatube.cn:8888/getProfile?id={userName}{otherParameter}'
userData = await request(Url=userDataUrl)
elif teaID is not None and userName is None:
userDataUrl = f'https://teatube.cn:8888/getProfile?id={teaID}{otherParameter}'
userData = await request(Url=userDataUrl)
else:
raise ValueError('[TETRIS STATS] TOSDataProcessing.getUserData: 参数错误')
return userData
# 获取Rank数据
async def getRankStats(userInfo: dict) -> dict[str, bool|float]:
rankStats = {}
if int(userInfo['Data']['data']['rankedGames']) == 0:
rankStats['Played'] = False
else:
rankStats['Played'] = True
rankStats['Rating'] = round(float(userInfo['Data']['data']['ratingNow']), 2)
rankStats['RD'] = round(float(userInfo['Data']['data']['rdNow']), 2)
rankStats['Vol'] = round(float(userInfo['Data']['data']['volNow']), 3)
return rankStats
# 获取游戏数据
async def getGameData(userData: dict) -> dict[str, bool|int|float]:
gameData = {}
if userData['Data']['data'] == []:
gameData['Played'] = False
else:
gameData['Played'] = True
weightedTotalLpm = weightedTotalApm = weightedTotalAdpm = weightedTotalTime = num = 0
for i in userData['Data']['data']:
# 排除单人局和时间为0的游戏
if i['num_players'] == 1 or i['time'] == 0:
continue
# 茶不计算没挖掘的局即使apm和lpm也如此
if i['dig'] is None:
break
# 加权计算
time = i['time'] / 1000
lpm = 24 * (i['pieces'] / time)
apm = (i['attack'] / time) * 60
adpm = ((i['attack'] + i['dig']) / time) * 60
weightedTotalLpm += lpm * time
weightedTotalApm += apm * time
weightedTotalAdpm += adpm * time
weightedTotalTime += time
num += 1
if num == 50:
break
gameData['NUM'] = num
gameData['LPM'] = round((weightedTotalLpm / weightedTotalTime), 2)
gameData['APM'] = round((weightedTotalApm / weightedTotalTime), 2)
gameData['ADPM'] = round((weightedTotalAdpm / weightedTotalTime), 2)
gameData['PPS'] = round((gameData['LPM'] / 24), 2)
gameData['APL'] = round((gameData['APM'] / gameData['LPM']), 2)
gameData['ADPL'] = round((gameData['ADPM'] / gameData['LPM']), 2)
gameData['VS'] = round((gameData['ADPM'] / 60 * 100), 2)
# TODO: 如果有效局数不满50, 没有无dig信息的局, 且userData['Data']['data']内有50个局, 则继续往前获取信息
return gameData
# 获取PB数据
async def getPBData(userInfo: dict) -> dict[str, bool|float|str]:
PBData = {}
if int(userInfo['Data']['data']['PBSprint']) == 2147483647:
PBData['Sprint'] = False
else:
PBData['Sprint'] = round(float(userInfo['Data']['data']['PBSprint']) / 1000, 2)
if int(userInfo['Data']['data']['PBMarathon']) == 0:
PBData['Marathon'] = False
else:
PBData['Marathon'] = userInfo['Data']['data']['PBMarathon']
if int(userInfo['Data']['data']['PBChallenge']) == 0:
PBData['Challenge'] = False
else:
PBData['Challenge'] = userInfo['Data']['data']['PBChallenge']
return PBData
# 生成消息
async def generateMessage(userName: str = None, teaID: int = None) -> str:
userInfo, userData = await gather(getUserInfo(userName=userName, teaID=teaID), getUserData(userName=userName, teaID=teaID))
if userInfo['Status'] is False:
return f'用户信息请求失败'
if userInfo['Success'] is False:
return f'用户信息请求错误:\n{userInfo["Data"]["error"]}'
rankStats = await getRankStats(userInfo)
PBData = await getPBData(userInfo)
message = ''
if rankStats['Played'] is False:
message += f'用户 {userInfo["Data"]["data"]["name"]}{userInfo["Data"]["data"]["teaId"]})暂无段位统计数据'
elif rankStats['Played'] is True:
message += f'用户 {userInfo["Data"]["data"]["name"]} ({userInfo["Data"]["data"]["teaId"]}) , 段位分 {rankStats["Rating"]}±{rankStats["RD"]} ({rankStats["Vol"]}) '
if userData['Status'] is False:
message = f'{message.rstrip()}\n游戏数据请求失败'
elif userData['Status'] is True:
gameData = await getGameData(userData)
if gameData['Played'] is False:
message += ', 暂无游戏数据'
elif gameData['Played'] is True:
message += f', 最近 {gameData["NUM"]} 局数据'
message += f'\nL\'PM: {gameData["LPM"]} ( {gameData["PPS"]} pps )'
message += f'\nAPM{gameData["APM"]} ( x{gameData["APL"]} )'
message += f'\nADPM{gameData["ADPM"]} ( x{gameData["ADPL"]} ) ( {gameData["VS"]}vs )'
if PBData['Sprint'] is not False:
message += f'\n40L: {PBData["Sprint"]}s'
if PBData['Marathon']is not False:
message += f'\nMarathon: {PBData["Marathon"]}'
if PBData['Challenge'] is not False:
message += f'\nChallenge: {PBData["Challenge"]}'
return message

View File

@@ -1,86 +1,23 @@
from re import I
from nonebot import require
from nonebot.plugin import PluginMetadata
from nonebot import get_driver, on_regex
from nonebot.adapters.onebot.v11 import GROUP, MessageEvent
from nonebot.matcher import Matcher
require('nonebot_plugin_localstore')
require('nonebot_plugin_orm')
require('nonebot_plugin_alconna')
require('nonebot_plugin_apscheduler')
from .MessageAnalyzer import *
from .SQL import *
from .config.config import migrations # noqa: E402
from .IODataProcessing import generateMessage as IOgenerateMessage
from .IODataProcessing import getUserID as IOgetUserID
from .TOSDataProcessing import generateMessage as TOSgenerateMessage
__plugin_meta__ = PluginMetadata(
name='Tetris Stats',
description='一个用于查询 Tetris 相关游戏玩家数据的插件',
usage='发送 {游戏名} --help 查询使用方法',
type='application',
homepage='https://github.com/A-minos/nonebot-plugin-tetris-stats',
extra={
'orm_version_location': migrations,
},
)
driver = get_driver()
@driver.on_startup
async def startUP():
await initDB()
ioBind = on_regex(pattern=r'^io绑定|^iobind', flags=I, permission=GROUP)
ioStats = on_regex(pattern=r'^io查|^iostats', flags=I, permission=GROUP)
tosStats = on_regex(pattern=r'^tos查|^tostats|^茶服查|^茶服stats',
flags=I, permission=GROUP)
topBind = on_regex(pattern=r'^top绑定|^topbind', flags=I, permission=GROUP)
topStats = on_regex(pattern=r'^top查|^topstats', flags=I, permission=GROUP)
@ioBind.handle()
async def bindIOUser(event: MessageEvent, matcher: Matcher):
decodedMessage = await handleBindMessage(message=str(event.get_message()), gameType='IO')
if decodedMessage['Success'] is True:
if decodedMessage['Type'] == 'ID':
user = decodedMessage['User']
elif decodedMessage['Type'] == 'Name':
user = await IOgetUserID(userName=decodedMessage['User'])
message = await writeBindInfo(QQNumber=event.sender.user_id, user=user, gameType='IO')
elif decodedMessage['Success'] is False:
message = decodedMessage['Message']
await matcher.send(message=message)
@ioStats.handle()
async def handleIOStatsQuery(event: MessageEvent, matcher: Matcher):
decodedMessage = await handleStatsQueryMessage(message=str(event.get_message()), gameType='IO')
if decodedMessage['Success'] is True:
if decodedMessage['Type'] == 'AT':
bindInfo = await queryBindInfo(QQNumber=decodedMessage['QQNumber'], gameType='IO')
if bindInfo['Hit'] is True:
message = (f'* 由于无法验证绑定信息,不能保证查询到的用户为本人\n{await IOgenerateMessage(userID=bindInfo["User"])}')
elif bindInfo['Hit'] is False:
message = '未查询到绑定信息'
elif decodedMessage['Type'] == 'ME':
bindInfo = await queryBindInfo(QQNumber=event.sender.user_id, gameType='IO')
if bindInfo['Hit'] is True:
message = (f'* 由于无法验证绑定信息,不能保证查询到的用户为本人\n{await IOgenerateMessage(userID=bindInfo["User"])}')
elif bindInfo['Hit'] is False:
message = '您还没有绑定账号'
elif decodedMessage['Type'] == 'ID':
message = await IOgenerateMessage(userID=decodedMessage['User'])
elif decodedMessage['Type'] == 'Name':
message = await IOgenerateMessage(userName=decodedMessage['User'])
elif decodedMessage['Success'] is False:
message = decodedMessage['Message']
await matcher.finish(message=message)
@tosStats.handle()
async def handleTOSStatsQuery(event: MessageEvent, matcher: Matcher):
decodedMessage = await handleStatsQueryMessage(message=str(event.get_message()), gameType='TOS')
if decodedMessage['Success'] is True:
if decodedMessage['Type'] == 'AT' or decodedMessage['Type'] == 'QQ':
message = await TOSgenerateMessage(teaID=decodedMessage['QQNumber'])
elif decodedMessage['Type'] == 'ME':
message = await TOSgenerateMessage(teaID=event.sender.user_id)
elif decodedMessage['Type'] == 'Name':
message = await TOSgenerateMessage(userName=decodedMessage['User'])
elif decodedMessage['Success'] is False:
message = decodedMessage['Message']
await matcher.finish(message=message)
@topBind.handle()
async def bindTOPUser(event: MessageEvent, matcher: Matcher):
await matcher.send(message='TODO')
@topStats.handle()
async def handleTOPStatsQuery(event: MessageEvent, matcher: Matcher):
await matcher.send(message='TODO')
from . import game_data_processor # noqa: F401, E402
from .utils import host # noqa: F401, E402

View File

@@ -0,0 +1,14 @@
from pathlib import Path
from nonebot_plugin_localstore import get_cache_dir # type: ignore[import-untyped]
from pydantic import BaseModel
from . import migrations # noqa: F401
CACHE_PATH: Path = get_cache_dir('nonebot_plugin_tetris_stats')
class Config(BaseModel):
"""配置类"""
tetris_req_timeout: float = 30.0

View File

@@ -0,0 +1,51 @@
"""Rename field
迁移 ID: 09d4bb60160d
父迁移: b9d65badc713
创建时间: 2024-04-23 23:42:04.541672
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = '09d4bb60160d'
down_revision: str | Sequence[str] | None = 'b9d65badc713'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.alter_column('create_time', new_column_name='update_time', existing_type=sa.DateTime())
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_iorank_create_time')
op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_update_time'),
'nonebot_plugin_tetris_stats_iorank',
['update_time'],
unique=False,
)
# ### end Alembic commands ###
def downgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.alter_column('update_time', new_column_name='create_time')
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_update_time'))
op.create_index(
'ix_nonebot_plugin_tetris_stats_iorank_create_time',
'nonebot_plugin_tetris_stats_iorank',
['create_time'],
unique=False,
)
# ### end Alembic commands ###

View File

@@ -0,0 +1,43 @@
"""add field
迁移 ID: 0d50142b780f
父迁移: 09d4bb60160d
创建时间: 2024-04-24 14:55:08.064098
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = '0d50142b780f'
down_revision: str | Sequence[str] | None = '09d4bb60160d'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.add_column(sa.Column('file_hash', sa.String(length=128), nullable=True))
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_file_hash'), ['file_hash'], unique=False
)
# ### end Alembic commands ###
def downgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_file_hash'))
batch_op.drop_column('file_hash')
# ### end Alembic commands ###

View File

@@ -0,0 +1,65 @@
"""Add redundant platform field
迁移 ID: 6c3206f90cc3
父迁移: 9f6582279ce2
创建时间: 2023-11-26 20:15:56.033892
"""
from __future__ import annotations
from collections.abc import Sequence
from alembic import op
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from ujson import dumps, loads
revision: str = '6c3206f90cc3'
down_revision: str | Sequence[str] | None = '9f6582279ce2'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
Base = automap_base() # noqa: N806
connection = op.get_bind()
Base.prepare(autoload_with=connection)
HistoricalData = Base.classes.nonebot_plugin_tetris_stats_historicaldata # noqa: N806
with Session(connection) as session:
for row in session.query(HistoricalData):
platform = row.game_platform
game_user = loads(row.game_user)
processed_data = loads(row.processed_data)
game_user['platform'] = platform
processed_data['platform'] = platform
row.game_user = dumps(game_user)
row.processed_data = dumps(processed_data)
session.add(row)
session.commit()
def downgrade(name: str = '') -> None:
if name:
return
Base = automap_base() # noqa: N806
connection = op.get_bind()
Base.prepare(autoload_with=connection)
HistoricalData = Base.classes.nonebot_plugin_tetris_stats_historicaldata # noqa: N806
with Session(connection) as session:
for row in session.query(HistoricalData):
game_user = loads(row.game_user)
processed_data = loads(row.processed_data)
game_user.pop('platform', None)
processed_data.pop('platform', None)
row.game_user = dumps(game_user)
row.processed_data = dumps(processed_data)
session.add(row)
session.commit()

View File

@@ -0,0 +1,92 @@
"""Correct the data in HistoricalData
迁移 ID: 8a91210ce14d
父迁移: 0d50142b780f
创建时间: 2024-05-06 08:16:38.487214
"""
from __future__ import annotations
from collections.abc import Sequence
from alembic import op
from nonebot.log import logger
from sqlalchemy import select
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
revision: str = '8a91210ce14d'
down_revision: str | Sequence[str] | None = '0d50142b780f'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
from nonebot_plugin_tetris_stats.version import __version__
if __version__ != '1.0.3':
logger.critical('本迁移需要1.0.3版本, 请先锁定版本至1.0.3版本再执行本迁移')
raise RuntimeError('本迁移需要1.0.3版本, 请先锁定版本至1.0.3版本再执行本迁移')
from nonebot.compat import PYDANTIC_V2, type_validate_json
from pydantic import BaseModel, ValidationError
from rich.progress import (
BarColumn,
MofNCompleteColumn,
Progress,
TaskProgressColumn,
TextColumn,
TimeRemainingColumn,
)
from nonebot_plugin_tetris_stats.game_data_processor.schemas import BaseProcessedData
Base = automap_base() # noqa: N806
Base.prepare(autoload_with=op.get_bind())
HistoricalData = Base.classes.nonebot_plugin_tetris_stats_historicaldata # noqa: N806
if PYDANTIC_V2:
def model_to_json(value: BaseModel) -> str:
return value.model_dump_json(by_alias=True)
else:
def model_to_json(value: BaseModel) -> str:
return value.json(by_alias=True)
models = BaseProcessedData.__subclasses__()
def json_to_model(value: str) -> BaseModel:
for i in models:
try:
return type_validate_json(i, value)
except ValidationError: # noqa: PERF203
...
raise ValueError
with Session(op.get_bind()) as session:
count = session.query(HistoricalData).count()
with Progress(
TextColumn('[progress.description]{task.description}'),
BarColumn(),
MofNCompleteColumn(),
TaskProgressColumn(),
TimeRemainingColumn(),
) as progress:
task_id = progress.add_task('[cyan]Updateing:', total=count)
for i in range(0, count, 100):
for j in session.scalars(
select(HistoricalData).where(HistoricalData.id > i).order_by(HistoricalData.id).limit(100)
):
model = json_to_model(j.processed_data)
j.processed_data = model_to_json(model)
progress.update(task_id, advance=1)
session.commit()
logger.success('Corrected HistoricalData')
def downgrade(name: str = '') -> None:
if name:
return

View File

@@ -0,0 +1,139 @@
"""init db
迁移 ID: 9866f53ce44f
父迁移:
创建时间: 2023-11-11 16:24:11.826667
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = '9866f53ce44f'
down_revision: str | Sequence[str] | None = None
branch_labels: str | Sequence[str] | None = ('nonebot_plugin_tetris_stats',)
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
'nonebot_plugin_tetris_stats_bind',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('chat_platform', sa.String(length=32), nullable=False),
sa.Column('chat_account', sa.String(), nullable=False),
sa.Column('game_platform', sa.String(length=32), nullable=False),
sa.Column('game_account', sa.String(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_bind')),
)
with op.batch_alter_table('nonebot_plugin_tetris_stats_bind', schema=None) as batch_op:
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_account'),
['chat_account'],
unique=False,
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_platform'),
['chat_platform'],
unique=False,
)
op.create_table(
'nonebot_plugin_tetris_stats_historicaldata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('trigger_time', sa.DateTime(), nullable=False),
sa.Column('bot_platform', sa.String(length=32), nullable=True),
sa.Column('bot_account', sa.String(), nullable=True),
sa.Column('source_type', sa.String(length=32), nullable=True),
sa.Column('source_account', sa.String(), nullable=True),
sa.Column('message', sa.PickleType(), nullable=True),
sa.Column('game_platform', sa.String(length=32), nullable=False),
sa.Column('command_type', sa.String(length=16), nullable=False),
sa.Column('command_args', sa.JSON(), nullable=False),
sa.Column('game_user', sa.PickleType(), nullable=False),
sa.Column('processed_data', sa.PickleType(), nullable=False),
sa.Column('finish_time', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_historicaldata')),
)
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'),
['command_type'],
unique=False,
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'),
['game_platform'],
unique=False,
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'),
['source_account'],
unique=False,
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'),
['source_type'],
unique=False,
)
op.create_table(
'nonebot_plugin_tetris_stats_iorank',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('rank', sa.String(length=2), nullable=False),
sa.Column('tr_line', sa.Float(), nullable=False),
sa.Column('player_count', sa.Integer(), nullable=False),
sa.Column('low_pps', sa.JSON(), nullable=False),
sa.Column('low_apm', sa.JSON(), nullable=False),
sa.Column('low_vs', sa.JSON(), nullable=False),
sa.Column('avg_pps', sa.Float(), nullable=False),
sa.Column('avg_apm', sa.Float(), nullable=False),
sa.Column('avg_vs', sa.Float(), nullable=False),
sa.Column('high_pps', sa.JSON(), nullable=False),
sa.Column('high_apm', sa.JSON(), nullable=False),
sa.Column('high_vs', sa.JSON(), nullable=False),
sa.Column('create_time', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_iorank')),
)
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_create_time'),
['create_time'],
unique=False,
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_rank'),
['rank'],
unique=False,
)
# ### end Alembic commands ###
def downgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_iorank', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_rank'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_iorank_create_time'))
op.drop_table('nonebot_plugin_tetris_stats_iorank')
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'))
op.drop_table('nonebot_plugin_tetris_stats_historicaldata')
with op.batch_alter_table('nonebot_plugin_tetris_stats_bind', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_platform'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_bind_chat_account'))
op.drop_table('nonebot_plugin_tetris_stats_bind')
# ### end Alembic commands ###

View File

@@ -0,0 +1,92 @@
"""Merge old db
迁移 ID: 9cd1647db502
父迁移: 9866f53ce44f
创建时间: 2023-11-11 16:51:30.718277
"""
from __future__ import annotations
from collections.abc import Sequence
from pathlib import Path
from shutil import copyfile
from alembic import op
from nonebot import get_driver
from nonebot.log import logger
from sqlalchemy import Connection, create_engine, inspect, text
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
revision: str = '9cd1647db502'
down_revision: str | Sequence[str] | None = '9866f53ce44f'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
driver = get_driver()
config = driver.config
def migrate_old_data(connection: Connection) -> None:
Base = automap_base() # noqa: N806
Base.prepare(autoload_with=op.get_bind())
Bind = Base.classes.nonebot_plugin_tetris_stats_bind # noqa: N806
def non_empty(obj: str) -> bool:
if obj != '' and not obj.isspace():
return True
return False
def is_int(obj: int | str) -> bool:
if isinstance(obj, int) or obj.isdigit():
return True
return False
bind_list = [
Bind(chat_platform='OneBot V11', chat_account=int(row.QQ), game_platform='IO', game_account=row.USER)
for row in connection.execute(text('select QQ, USER from IOBIND;'))
if is_int(row.QQ) and non_empty(row.USER)
]
bind_list.extend(
[
Bind(chat_platform='OneBot V11', chat_account=int(row.QQ), game_platform='TOP', game_account=row.USER)
for row in connection.execute(text('select QQ, USER from TOPBIND;'))
if is_int(row.QQ) and non_empty(row.USER)
]
)
with Session(op.get_bind()) as session:
session.add_all(bind_list)
session.commit()
logger.success('nonebot_plugin_tetris_stats: 迁移完成')
def upgrade(name: str = '') -> None:
if name:
return
try:
db_path = Path(config.db_url)
except AttributeError:
db_path = Path('data/nonebot_plugin_tetris_stats/data.db')
if db_path.exists() is False:
logger.warning('nonebot_plugin_tetris_stats: 未发现老版本的数据')
logger.success('nonebot_plugin_tetris_stats: 跳过迁移')
return
copyfile(db_path, db_path.parent / 'data.db.bak')
engine = create_engine(f'sqlite:///{db_path.absolute()!s}')
with engine.connect() as connection:
tables = inspect(connection).get_table_names()
if 'IOBIND' not in tables or 'TOPBIND' not in tables:
logger.warning('nonebot_plugin_tetris_stats: 未发现老版本的数据')
logger.success('nonebot_plugin_tetris_stats: 跳过迁移')
return
if 'IORANK' not in tables:
logger.warning('nonebot_plugin_tetris_stats: 发现过早版本的数据, 请先更新到 0.4.4 版本')
raise RuntimeError('nonebot_plugin_tetris_stats: 请先安装 0.4.4 版本完成迁移之后再升级')
logger.info('nonebot_plugin_tetris_stats: 发现来自老版本的数据, 正在迁移...')
migrate_old_data(connection)
db_path.unlink()
def downgrade(name: str = '') -> None:
if name:
return

View File

@@ -0,0 +1,112 @@
"""Recreate HistoricalData
迁移 ID: 9f6582279ce2
父迁移: 9cd1647db502
创建时间: 2023-11-21 08:35:50.393246
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import sqlite
from nonebot_plugin_tetris_stats.db.models import PydanticType
revision: str = '9f6582279ce2'
down_revision: str | Sequence[str] | None = '9cd1647db502'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_historicaldata_command_type')
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform')
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_historicaldata_source_account')
batch_op.drop_index('ix_nonebot_plugin_tetris_stats_historicaldata_source_type')
op.drop_table('nonebot_plugin_tetris_stats_historicaldata')
op.create_table(
'nonebot_plugin_tetris_stats_historicaldata',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('trigger_time', sa.DateTime(), nullable=False),
sa.Column('bot_platform', sa.String(length=32), nullable=True),
sa.Column('bot_account', sa.String(), nullable=True),
sa.Column('source_type', sa.String(length=32), nullable=True),
sa.Column('source_account', sa.String(), nullable=True),
sa.Column('message', sa.PickleType(), nullable=True),
sa.Column('game_platform', sa.String(length=32), nullable=False),
sa.Column('command_type', sa.String(length=16), nullable=False),
sa.Column('command_args', sa.JSON(), nullable=False),
sa.Column('game_user', PydanticType(list), nullable=False),
sa.Column('processed_data', PydanticType(list), nullable=False),
sa.Column('finish_time', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('pk_nonebot_plugin_tetris_stats_historicaldata')),
)
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'), ['command_type'], unique=False
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'), ['game_platform'], unique=False
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'), ['source_account'], unique=False
)
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'), ['source_type'], unique=False
)
# ### end Alembic commands ###
def downgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_type'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_source_account'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_game_platform'))
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_command_type'))
op.drop_table('nonebot_plugin_tetris_stats_historicaldata')
op.create_table(
'nonebot_plugin_tetris_stats_historicaldata',
sa.Column('id', sa.INTEGER(), nullable=False),
sa.Column('trigger_time', sa.DATETIME(), nullable=False),
sa.Column('bot_platform', sa.VARCHAR(length=32), nullable=True),
sa.Column('bot_account', sa.VARCHAR(), nullable=True),
sa.Column('source_type', sa.VARCHAR(length=32), nullable=True),
sa.Column('source_account', sa.VARCHAR(), nullable=True),
sa.Column('message', sa.BLOB(), nullable=True),
sa.Column('game_platform', sa.VARCHAR(length=32), nullable=False),
sa.Column('command_type', sa.VARCHAR(length=16), nullable=False),
sa.Column('command_args', sqlite.JSON(), nullable=False),
sa.Column('game_user', sa.BLOB(), nullable=False),
sa.Column('processed_data', sa.BLOB(), nullable=False),
sa.Column('finish_time', sa.DATETIME(), nullable=False),
sa.PrimaryKeyConstraint('id', name='pk_nonebot_plugin_tetris_stats_historicaldata'),
)
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.create_index(
'ix_nonebot_plugin_tetris_stats_historicaldata_source_type', ['source_type'], unique=False
)
batch_op.create_index(
'ix_nonebot_plugin_tetris_stats_historicaldata_source_account', ['source_account'], unique=False
)
batch_op.create_index(
'ix_nonebot_plugin_tetris_stats_historicaldata_game_platform', ['game_platform'], unique=False
)
batch_op.create_index(
'ix_nonebot_plugin_tetris_stats_historicaldata_command_type', ['command_type'], unique=False
)
# ### end Alembic commands ###

View File

@@ -0,0 +1,103 @@
"""Add user_unique_identifier field to HistoricalData
迁移 ID: b7fbdafc339a
父迁移: 8a91210ce14d
创建时间: 2024-05-07 16:55:29.527215
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
from nonebot.log import logger
revision: str = 'b7fbdafc339a'
down_revision: str | Sequence[str] | None = '8a91210ce14d'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
from nonebot_plugin_tetris_stats.version import __version__
if __version__ != '1.0.4':
logger.critical('本迁移需要1.0.4版本, 请先锁定版本至1.0.4版本再执行本迁移')
raise RuntimeError('本迁移需要1.0.4版本, 请先锁定版本至1.0.4版本再执行本迁移')
from nonebot.compat import type_validate_json
from pydantic import ValidationError
from rich.progress import (
BarColumn,
MofNCompleteColumn,
Progress,
TaskProgressColumn,
TextColumn,
TimeRemainingColumn,
)
from sqlalchemy import select
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from nonebot_plugin_tetris_stats.game_data_processor.schemas import BaseUser
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.add_column(sa.Column('user_unique_identifier', sa.String(length=32), nullable=True))
batch_op.create_index(
batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_user_unique_identifier'),
['user_unique_identifier'],
unique=False,
)
Base = automap_base() # noqa: N806
connection = op.get_bind()
Base.prepare(autoload_with=connection)
HistoricalData = Base.classes.nonebot_plugin_tetris_stats_historicaldata # noqa: N806
models: list[type[BaseUser]] = BaseUser.__subclasses__()
def json_to_model(value: str) -> BaseUser:
for i in models:
try:
return type_validate_json(i, value)
except ValidationError: # noqa: PERF203
...
raise ValueError
with Session(op.get_bind()) as session:
count = session.query(HistoricalData).count()
with Progress(
TextColumn('[progress.description]{task.description}'),
BarColumn(),
MofNCompleteColumn(),
TaskProgressColumn(),
TimeRemainingColumn(),
) as progress:
task_id = progress.add_task('[cyan]Updateing:', total=count)
for i in range(0, count, 100):
for j in session.scalars(
select(HistoricalData).where(HistoricalData.id > i).order_by(HistoricalData.id).limit(100)
):
model = json_to_model(j.game_user)
try:
j.user_unique_identifier = model.unique_identifier
except ValueError:
session.delete(j)
progress.update(task_id, advance=1)
session.commit()
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.alter_column('user_unique_identifier', existing_type=sa.VARCHAR(length=32), nullable=False)
logger.success('database upgrade success')
def downgrade(name: str = '') -> None:
if name:
return
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('nonebot_plugin_tetris_stats_historicaldata', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_nonebot_plugin_tetris_stats_historicaldata_user_unique_identifier'))
batch_op.drop_column('user_unique_identifier')
# ### end Alembic commands ###

View File

@@ -0,0 +1,38 @@
"""Del old TOS bind data
迁移 ID: b9d65badc713
父迁移: 6c3206f90cc3
创建时间: 2023-12-30 00:27:40.991704
"""
from __future__ import annotations
from collections.abc import Sequence
from alembic import op
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
revision: str = 'b9d65badc713'
down_revision: str | Sequence[str] | None = '6c3206f90cc3'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade(name: str = '') -> None:
if name:
return
Base = automap_base() # noqa: N806
connection = op.get_bind()
Base.prepare(autoload_with=connection)
Bind = Base.classes.nonebot_plugin_tetris_stats_bind # noqa: N806
with Session(connection) as session:
session.query(Bind).filter(Bind.game_platform == 'TOS').delete()
session.commit()
def downgrade(name: str = '') -> None:
if name:
return

View File

@@ -0,0 +1,57 @@
from enum import Enum, auto
from nonebot_plugin_orm import AsyncSession
from sqlalchemy import select
from ..utils.typing import GameType
from .models import Bind
class BindStatus(Enum):
SUCCESS = auto()
UPDATE = auto()
async def query_bind_info(
session: AsyncSession,
chat_platform: str,
chat_account: str,
game_platform: GameType,
) -> Bind | None:
return (
await session.scalars(
select(Bind)
.where(Bind.chat_platform == chat_platform)
.where(Bind.chat_account == chat_account)
.where(Bind.game_platform == game_platform)
)
).one_or_none()
async def create_or_update_bind(
session: AsyncSession,
chat_platform: str,
chat_account: str,
game_platform: GameType,
game_account: str,
) -> BindStatus:
bind = await query_bind_info(
session=session,
chat_platform=chat_platform,
chat_account=chat_account,
game_platform=game_platform,
)
if bind is None:
bind = Bind(
chat_platform=chat_platform,
chat_account=chat_account,
game_platform=game_platform,
game_account=game_account,
)
session.add(bind)
message = BindStatus.SUCCESS
else:
bind.game_account = game_account
message = BindStatus.UPDATE
await session.commit()
return message

View File

@@ -0,0 +1,78 @@
from collections.abc import Callable, Sequence
from datetime import datetime
from typing import Any
from nonebot.adapters import Message
from nonebot.compat import PYDANTIC_V2, type_validate_json
from nonebot_plugin_orm import Model
from pydantic import BaseModel, ValidationError
from sqlalchemy import JSON, DateTime, Dialect, PickleType, String, TypeDecorator
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
from typing_extensions import override
from ..game_data_processor.schemas import BaseProcessedData, BaseUser
from ..utils.typing import CommandType, GameType
class PydanticType(TypeDecorator):
impl = JSON
@override
def __init__(self, get_model: Callable[[], Sequence[type[BaseModel]]], *args: Any, **kwargs: Any):
self.get_model = get_model
super().__init__(*args, **kwargs)
if PYDANTIC_V2:
@override
def process_bind_param(self, value: Any | None, dialect: Dialect) -> str:
# 将 Pydantic 模型实例转换为 JSON
if isinstance(value, tuple(self.get_model())):
return value.model_dump_json(by_alias=True) # type: ignore[union-attr]
raise TypeError
else:
@override
def process_bind_param(self, value: Any | None, dialect: Dialect) -> str:
# 将 Pydantic 模型实例转换为 JSON
if isinstance(value, tuple(self.get_model())):
return value.json(by_alias=True) # type: ignore[union-attr]
raise TypeError
@override
def process_result_value(self, value: Any | None, dialect: Dialect) -> BaseModel:
# 将 JSON 转换回 Pydantic 模型实例
if isinstance(value, str | bytes):
for i in self.get_model():
try:
return type_validate_json(i, value)
except ValidationError: # noqa: PERF203
...
raise ValueError
class Bind(MappedAsDataclass, Model):
id: Mapped[int] = mapped_column(init=False, primary_key=True)
chat_platform: Mapped[str] = mapped_column(String(32), index=True)
chat_account: Mapped[str] = mapped_column(index=True)
game_platform: Mapped[GameType] = mapped_column(String(32))
game_account: Mapped[str]
class HistoricalData(MappedAsDataclass, Model):
id: Mapped[int] = mapped_column(init=False, primary_key=True)
trigger_time: Mapped[datetime] = mapped_column(DateTime)
bot_platform: Mapped[str | None] = mapped_column(String(32))
bot_account: Mapped[str | None]
source_type: Mapped[str | None] = mapped_column(String(32), index=True)
source_account: Mapped[str | None] = mapped_column(index=True)
message: Mapped[Message | None] = mapped_column(PickleType)
game_platform: Mapped[GameType] = mapped_column(String(32), index=True, init=False)
command_type: Mapped[CommandType] = mapped_column(String(16), index=True, init=False)
command_args: Mapped[list[str]] = mapped_column(JSON, init=False)
user_unique_identifier: Mapped[str] = mapped_column(String(32), index=True, init=False)
game_user: Mapped[BaseUser] = mapped_column(PydanticType(get_model=BaseUser.__subclasses__), init=False)
processed_data: Mapped[BaseProcessedData] = mapped_column(
PydanticType(get_model=BaseProcessedData.__subclasses__), init=False
)
finish_time: Mapped[datetime] = mapped_column(DateTime, init=False)

View File

@@ -0,0 +1,100 @@
from abc import ABC, abstractmethod
from datetime import datetime, timezone
from typing import Any
from nonebot.matcher import Matcher
from nonebot_plugin_alconna import AlcMatches, AlconnaMatcher
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_userinfo import UserInfo # type: ignore[import-untyped]
from ..utils.exception import MessageFormatError
from ..utils.recorder import Recorder
from ..utils.typing import CommandType, GameType
from .schemas import BaseProcessedData as ProcessedData
from .schemas import BaseRawResponse as RawResponse
from .schemas import BaseUser as User
UTC = timezone.utc
class Processor(ABC):
event_id: int
command_type: CommandType
command_args: list[str]
user: User
raw_response: RawResponse
processed_data: ProcessedData
@abstractmethod
def __init__(
self,
event_id: int,
user: User,
command_args: list[str],
) -> None:
self.event_id = event_id
self.user = user
self.command_args = command_args
@property
@abstractmethod
def game_platform(self) -> GameType:
"""游戏平台"""
raise NotImplementedError
@abstractmethod
async def handle_bind(
self,
platform: str,
account: str,
bot_info: UserInfo,
*args: Any, # noqa: ANN401
**kwargs: Any, # noqa: ANN401
) -> UniMessage:
"""处理绑定消息"""
raise NotImplementedError
@abstractmethod
async def handle_query(self) -> UniMessage:
"""处理查询消息"""
raise NotImplementedError
def __del__(self) -> None:
finish_time = datetime.now(tz=UTC)
if Recorder.is_error_event(self.event_id):
Recorder.del_error_event(self.event_id)
return
historical_data = Recorder.get_historical_data(self.event_id)
historical_data.game_platform = self.game_platform
historical_data.command_type = self.command_type
historical_data.command_args = self.command_args
historical_data.user_unique_identifier = self.user.unique_identifier
historical_data.game_user = self.user
historical_data.processed_data = self.processed_data
historical_data.finish_time = finish_time
Recorder.update_historical_data(self.event_id, historical_data)
def add_default_handlers(matcher: type[AlconnaMatcher]) -> None:
@matcher.handle()
async def _(matcher: Matcher, account: MessageFormatError):
await matcher.finish(str(account))
@matcher.handle()
async def _(matcher: Matcher, matches: AlcMatches):
if matches.head_matched and matches.options != {} or matches.main_args == {}:
await matcher.finish(
(f'{matches.error_info!r}\n' if matches.error_info is not None else '')
+ f'输入"{matches.header_result} --help"查看帮助'
)
@matcher.handle()
async def _(matcher: Matcher, other: Any): # noqa: ANN401
await matcher.finish()
from . import ( # noqa: F401, E402
io_data_processor,
top_data_processor,
tos_data_processor,
)

View File

@@ -0,0 +1,2 @@
BIND_COMMAND: list[str] = ['绑定', 'bind']
QUERY_COMMAND: list[str] = ['', '查询', 'query', 'stats']

View File

@@ -0,0 +1,196 @@
from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo
from arclet.alconna import Alconna, AllParam, Arg, ArgFlag, Args, CommandMeta, Option
from nonebot.adapters import Bot, Event
from nonebot.matcher import Matcher
from nonebot_plugin_alconna import At, on_alconna
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import BotUserInfo, UserInfo # type: ignore[import-untyped]
from sqlalchemy import func, select
from ...db import query_bind_info
from ...utils.exception import HandleNotFinishedError, NeedCatchError
from ...utils.metrics import get_metrics
from ...utils.platform import get_platform
from ...utils.typing import Me
from .. import add_default_handlers
from ..constant import BIND_COMMAND, QUERY_COMMAND
from .constant import GAME_TYPE
from .model import IORank
from .processor import Processor, User, identify_user_info
from .typing import Rank
UTC = timezone.utc
alc = on_alconna(
Alconna(
'io',
Option(
BIND_COMMAND[0],
Args(
Arg(
'account',
identify_user_info,
notice='IO 用户名 / ID',
flags=[ArgFlag.HIDDEN],
)
),
alias=BIND_COMMAND[1:],
compact=True,
dest='bind',
help_text='绑定 IO 账号',
),
Option(
QUERY_COMMAND[0],
Args(
Arg(
'target',
At | Me,
notice='@想要查询的人 | 自己',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
Arg(
'account',
identify_user_info,
notice='IO 用户名 / ID',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
),
alias=QUERY_COMMAND[1:],
compact=True,
dest='query',
help_text='查询 IO 游戏信息',
),
Option(
'rank',
Args(Arg('rank', Rank, notice='IO 段位')),
alias={'Rank', 'RANK', '段位'},
compact=True,
dest='rank',
help_text='查询 IO 段位信息',
),
Arg('other', AllParam, flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL]),
meta=CommandMeta(
description='查询 TETR.IO 的信息',
example='io绑定scdhh\nio查我\niorankx',
compact=True,
fuzzy_match=True,
),
),
skip_for_unmatch=False,
auto_send_output=True,
aliases={'IO'},
)
alc.shortcut('fkosk', {'command': 'io查', 'args': ['']})
@alc.assign('bind')
async def _(bot: Bot, event: Event, matcher: Matcher, account: User, bot_info: UserInfo = BotUserInfo()): # noqa: B008
proc = Processor(event_id=id(event), user=account, command_args=[])
try:
await (
await proc.handle_bind(platform=get_platform(bot), account=event.get_user_id(), bot_info=bot_info)
).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
async with get_session() as session:
bind = await query_bind_info(
session=session,
chat_platform=get_platform(bot),
chat_account=(target.target if isinstance(target, At) else event.get_user_id()),
game_platform=GAME_TYPE,
)
if bind is None:
await matcher.finish('未查询到绑定信息')
message = '* 由于无法验证绑定信息, 不能保证查询到的用户为本人\n'
proc = Processor(
event_id=id(event),
user=User(ID=bind.game_account),
command_args=[],
)
try:
await (UniMessage(message) + await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(event: Event, matcher: Matcher, account: User):
proc = Processor(
event_id=id(event),
user=account,
command_args=[],
)
try:
await (await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('rank')
async def _(matcher: Matcher, rank: Rank):
if rank == 'z':
await matcher.finish('暂不支持查询未知段位')
async with get_session() as session:
latest_data = (
await session.scalars(select(IORank).where(IORank.rank == rank).order_by(IORank.id.desc()).limit(1))
).one()
compare_data = (
await session.scalars(
select(IORank)
.where(IORank.rank == rank)
.order_by(
func.abs(
func.julianday(IORank.update_time)
- func.julianday(latest_data.update_time - timedelta(hours=24))
)
)
.limit(1)
)
).one()
message = ''
if (datetime.now(UTC) - latest_data.update_time.replace(tzinfo=UTC)) > timedelta(hours=7):
message += 'Warning: 数据超过7小时未更新, 请联系Bot主人查看后台\n'
message += f'{rank.upper()} 段 分数线 {latest_data.tr_line:.2f} TR, {latest_data.player_count} 名玩家\n'
if compare_data.id != latest_data.id:
message += f'对比 {(latest_data.update_time-compare_data.update_time).total_seconds()/3600:.2f} 小时前趋势: {f"{difference:.2f}" if (difference:=latest_data.tr_line-compare_data.tr_line) > 0 else f"{-difference:.2f}" if difference < 0 else ""}'
else:
message += '暂无对比数据'
avg = get_metrics(pps=latest_data.avg_pps, apm=latest_data.avg_apm, vs=latest_data.avg_vs)
low_pps = get_metrics(pps=latest_data.low_pps[1])
low_vs = get_metrics(vs=latest_data.low_vs[1])
max_pps = get_metrics(pps=latest_data.high_pps[1])
max_vs = get_metrics(vs=latest_data.high_vs[1])
message += (
'\n'
'平均数据:\n'
f"L'PM: {avg.lpm} ( {avg.pps} pps )\n"
f'APM: {avg.apm} ( x{avg.apl} )\n'
f'ADPM: {avg.adpm} ( x{avg.adpl} ) ( {avg.vs}vs )\n'
'\n'
'最低数据:\n'
f"L'PM: {low_pps.lpm} ( {low_pps.pps} pps ) By: {latest_data.low_pps[0]['name'].upper()}\n"
f'APM: {latest_data.low_apm[1]} By: {latest_data.low_apm[0]["name"].upper()}\n'
f'ADPM: {low_vs.adpm} ( {low_vs.vs}vs ) By: {latest_data.low_vs[0]["name"].upper()}\n'
'\n'
'最高数据:\n'
f"L'PM: {max_pps.lpm} ( {max_pps.pps} pps ) By: {latest_data.high_pps[0]['name'].upper()}\n"
f'APM: {latest_data.high_apm[1]} By: {latest_data.high_apm[0]["name"].upper()}\n'
f'ADPM: {max_vs.adpm} ( {max_vs.vs}vs ) By: {latest_data.high_vs[0]["name"].upper()}\n'
'\n'
f'数据更新时间: {latest_data.update_time.replace(tzinfo=UTC).astimezone(ZoneInfo("Asia/Shanghai")).strftime("%Y-%m-%d %H:%M:%S")}'
)
await matcher.finish(message)
add_default_handlers(alc)

View File

@@ -0,0 +1,30 @@
from datetime import datetime, timezone
from aiocache import Cache as ACache # type: ignore[import-untyped]
from nonebot.compat import type_validate_json
from nonebot.log import logger
from ...utils.request import Request
from .schemas.base import FailedModel, SuccessModel
UTC = timezone.utc
class Cache:
cache = ACache(ACache.MEMORY)
@classmethod
async def get(cls, url: str) -> bytes:
cached_data = await cls.cache.get(url)
if cached_data is None:
response_data = await Request.request(url)
parsed_data: SuccessModel | FailedModel = type_validate_json(SuccessModel | FailedModel, response_data) # type: ignore[arg-type]
if isinstance(parsed_data, SuccessModel):
await cls.cache.add(
url,
response_data,
(parsed_data.cache.cached_until - datetime.now(UTC)).total_seconds(),
)
return response_data
logger.debug(f'{url}: Cache hit!')
return cached_data

View File

@@ -0,0 +1,27 @@
from typing import Literal
from .typing import Rank
GAME_TYPE: Literal['IO'] = 'IO'
BASE_URL = 'https://ch.tetr.io/api/'
RANK_PERCENTILE: dict[Rank, float] = {
'x': 1,
'u': 5,
'ss': 11,
's+': 17,
's': 23,
's-': 30,
'a+': 38,
'a': 46,
'a-': 54,
'b+': 62,
'b': 70,
'b-': 78,
'c+': 84,
'c': 90,
'c-': 95,
'd+': 97.5,
'd': 100,
}
TR_MIN = 0
TR_MAX = 25000

View File

@@ -0,0 +1,30 @@
from datetime import datetime, timezone
from nonebot_plugin_orm import Model
from sqlalchemy import JSON, DateTime, String
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column
from .typing import Rank
UTC = timezone.utc
class IORank(MappedAsDataclass, Model):
id: Mapped[int] = mapped_column(init=False, primary_key=True)
rank: Mapped[Rank] = mapped_column(String(2), index=True)
tr_line: Mapped[float]
player_count: Mapped[int]
low_pps: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
low_apm: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
low_vs: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
avg_pps: Mapped[float]
avg_apm: Mapped[float]
avg_vs: Mapped[float]
high_pps: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
high_apm: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
high_vs: Mapped[tuple[dict[str, str], float]] = mapped_column(JSON)
update_time: Mapped[datetime] = mapped_column(
DateTime,
index=True,
)
file_hash: Mapped[str | None] = mapped_column(String(128), index=True)

View File

@@ -0,0 +1,458 @@
from asyncio import gather
from collections import defaultdict
from collections.abc import Callable
from datetime import datetime, timedelta, timezone
from hashlib import md5, sha512
from math import ceil, floor
from re import match
from statistics import mean
from typing import Literal
from urllib.parse import urlunparse
from zoneinfo import ZoneInfo
from aiofiles import open
from nonebot import get_driver
from nonebot.compat import type_validate_json
from nonebot.utils import run_sync
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_apscheduler import scheduler # type: ignore[import-untyped]
from nonebot_plugin_localstore import get_data_file # type: ignore[import-untyped]
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
from sqlalchemy import select
from typing_extensions import override
from zstandard import ZstdCompressor
from ...db import BindStatus, create_or_update_bind
from ...db.models import HistoricalData
from ...utils.avatar import get_avatar
from ...utils.exception import MessageFormatError, RequestError, WhatTheFuckError
from ...utils.host import HostPage, get_self_netloc
from ...utils.render import Bind, TETRIOInfo, render
from ...utils.request import splice_url
from ...utils.retry import retry
from ...utils.screenshot import screenshot
from .. import Processor as ProcessorMeta
from .cache import Cache
from .constant import BASE_URL, GAME_TYPE, RANK_PERCENTILE, TR_MAX, TR_MIN
from .model import IORank
from .schemas.base import FailedModel
from .schemas.league_all import LeagueAll
from .schemas.league_all import ValidUser as LeagueAllUser
from .schemas.response import ProcessedData, RawResponse
from .schemas.user import User
from .schemas.user_info import NeverPlayedLeague, NeverRatedLeague, RatedLeague, UserInfo
from .schemas.user_info import SuccessModel as InfoSuccess
from .schemas.user_records import MultiRecord, SoloRecord, UserRecords
from .schemas.user_records import SuccessModel as RecordsSuccess
from .typing import Rank
UTC = timezone.utc
driver = get_driver()
def identify_user_info(info: str) -> User | MessageFormatError:
if match(r'^[a-f0-9]{24}$', info):
return User(ID=info)
if match(r'^[a-zA-Z0-9_-]{3,16}$', info):
return User(name=info.lower())
return MessageFormatError('用户名/ID不合法')
def get_value_bounds(values: list[int | float]) -> tuple[int, int]:
value_max = 10 * ceil(max(values) / 10)
value_min = 10 * floor(min(values) / 10)
return value_max, value_min
def get_split(value_max: int, value_min: int) -> tuple[int, int]:
offset = 0
overflow = 0
while True:
if (new_max_value := value_max + offset + overflow) > TR_MAX:
overflow -= 1
continue
if (new_min_value := value_min - offset + overflow) < TR_MIN:
overflow += 1
continue
if ((new_max_value - new_min_value) / 40).is_integer():
split_value = int((value_max + offset - (value_min - offset)) / 4)
break
offset += 1
return split_value, offset + overflow
def get_specified_point(
previous_point: TETRIOInfo.TetraLeagueHistory.Data,
behind_point: TETRIOInfo.TetraLeagueHistory.Data,
point_time: datetime,
) -> TETRIOInfo.TetraLeagueHistory.Data:
"""根据给出的 previous_point 和 behind_point, 推算 point_time 点处的数据
Args:
previous_point (TETRIOInfo.TetraLeagueHistory.Data): 前面的数据点
behind_point (TETRIOInfo.TetraLeagueHistory.Data): 后面的数据点
point_time (datetime): 要推算的点的位置
Returns:
TETRIOInfo.TetraLeagueHistory.Data: 要推算的点的数据
"""
# 求两个点的斜率
slope = (behind_point.tr - previous_point.tr) / (
datetime.timestamp(behind_point.record_at) - datetime.timestamp(previous_point.record_at)
)
return TETRIOInfo.TetraLeagueHistory.Data(
record_at=point_time,
tr=previous_point.tr + slope * (datetime.timestamp(point_time) - datetime.timestamp(previous_point.record_at)),
)
class Processor(ProcessorMeta):
user: User
raw_response: RawResponse
processed_data: ProcessedData
@override
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
super().__init__(event_id, user, command_args)
self.raw_response = RawResponse()
self.processed_data = ProcessedData()
@property
@override
def game_platform(self) -> Literal['IO']:
return GAME_TYPE
@override
async def handle_bind(self, platform: str, account: str, bot_info: NBUserInfo) -> UniMessage:
"""处理绑定消息"""
self.command_type = 'bind'
await self.get_user()
if self.user.ID is None:
raise # FIXME: 不知道怎么才能把这类型给变过来了
async with get_session() as session:
bind_status = await create_or_update_bind(
session=session,
chat_platform=platform,
chat_account=account,
game_platform=GAME_TYPE,
game_account=self.user.ID,
)
bot_avatar = await get_avatar(bot_info, 'Data URI', '../../static/logo/logo.svg')
user_info = await self.get_user_info()
if bind_status in (BindStatus.SUCCESS, BindStatus.UPDATE):
async with HostPage(
await render(
'binding',
Bind(
platform='TETR.IO',
status='unknown',
user=Bind.People(
avatar=f'https://tetr.io/user-content/avatars/{user_info.data.user.id}.jpg?rv={user_info.data.user.avatar_revision}'
if user_info.data.user.avatar_revision is not None
else f'{{"type":"identicon","hash":"{md5(user_info.data.user.id.encode()).hexdigest()}"}}', # noqa: S324
name=user_info.data.user.username.upper(),
),
bot=Bind.People(
avatar=bot_avatar,
name=bot_info.user_name,
),
command='io查我',
),
)
) as page_hash:
message = UniMessage.image(
raw=await screenshot(urlunparse(('http', get_self_netloc(), f'/host/{page_hash}.html', '', '', '')))
)
return message
@override
async def handle_query(self) -> UniMessage:
"""处理查询消息"""
self.command_type = 'query'
await self.get_user()
user_info, user_records = await gather(self.get_user_info(), self.get_user_records())
sprint = user_records.data.records.sprint
blitz = user_records.data.records.blitz
if isinstance(sprint.record, MultiRecord) or isinstance(blitz.record, MultiRecord):
raise WhatTheFuckError('单人游戏记录是多人游戏记录')
try:
return UniMessage.image(raw=await self.make_query_image(self.user, user_info, sprint.record, blitz.record))
except TypeError:
...
# fallback
league = user_info.data.user.league
user_name = user_info.data.user.username.upper()
ret_message = ''
if isinstance(league, NeverPlayedLeague):
ret_message += f'用户 {user_name} 没有排位统计数据'
else:
if isinstance(league, NeverRatedLeague):
ret_message += f'用户 {user_name} 暂未完成定级赛, 最近十场的数据:'
else:
if league.rank == 'z':
ret_message += f'用户 {user_name} 暂无段位, {round(league.rating,2)} TR'
else:
ret_message += (
f'{league.rank.upper()} 段用户 {user_name} {round(league.rating,2)} TR (#{league.standing})'
)
ret_message += f', 段位分 {round(league.glicko,2)}±{round(league.rd,2)}, 最近十场的数据:'
lpm = league.pps * 24
ret_message += f"\nL'PM: {round(lpm, 2)} ( {league.pps} pps )"
ret_message += f'\nAPM: {league.apm} ( x{round(league.apm/lpm,2)} )'
if league.vs is not None:
adpm = league.vs * 0.6
ret_message += f'\nADPM: {round(adpm,2)} ( x{round(adpm/lpm,2)} ) ( {league.vs}vs )'
if sprint.record is not None:
ret_message += f'\n40L: {round(sprint.record.endcontext.final_time/1000,2)}s'
ret_message += f' ( #{sprint.rank} )' if sprint.rank is not None else ''
if blitz.record is not None:
ret_message += f'\nBlitz: {blitz.record.endcontext.score}'
ret_message += f' ( #{blitz.rank} )' if blitz.rank is not None else ''
return UniMessage(ret_message)
@staticmethod
async def query_historical_data(user: User, user_info: InfoSuccess) -> list[TETRIOInfo.TetraLeagueHistory.Data]:
today = datetime.now(ZoneInfo('Asia/Shanghai')).replace(hour=0, minute=0, second=0, microsecond=0)
forward = timedelta(days=9)
start_time = (today - forward).astimezone(UTC)
async with get_session() as session:
historical_data = (
await session.scalars(
select(HistoricalData)
.where(HistoricalData.trigger_time >= start_time)
.where(HistoricalData.game_platform == GAME_TYPE)
.where(HistoricalData.user_unique_identifier == user.unique_identifier)
)
).all()
if historical_data:
extra = (
await session.scalars(
select(HistoricalData)
.where(HistoricalData.game_platform == GAME_TYPE)
.where(HistoricalData.user_unique_identifier == user.unique_identifier)
.order_by(HistoricalData.id.desc())
.where(HistoricalData.id < min([i.id for i in historical_data]))
.limit(1)
)
).one_or_none()
if extra is not None:
historical_data = list(historical_data)
historical_data.append(extra)
histories = [
TETRIOInfo.TetraLeagueHistory.Data(
record_at=i.processed_data.user_info.cache.cached_at.astimezone(ZoneInfo('Asia/Shanghai')),
tr=i.processed_data.user_info.data.user.league.rating,
)
for i in historical_data
if isinstance(i.processed_data, ProcessedData)
and i.processed_data.user_info is not None
and isinstance(i.processed_data.user_info.data.user.league, RatedLeague)
]
# 按照时间排序
histories = sorted(histories, key=lambda x: x.record_at)
for index, value in enumerate(histories):
# 在历史记录里找有没有今天0点后的数据
if value.record_at > today:
histories = histories[:index] + [
get_specified_point(histories[index - 1], histories[index], today.replace(microsecond=1000))
]
break
else:
histories.append(
get_specified_point(
histories[-1],
TETRIOInfo.TetraLeagueHistory.Data(
record_at=user_info.cache.cached_at, tr=user_info.data.user.league.rating
),
today.replace(microsecond=1000),
)
)
if histories[0].record_at < (today - forward):
histories[0] = get_specified_point(
histories[0],
histories[1],
today - forward,
)
else:
histories.insert(0, TETRIOInfo.TetraLeagueHistory.Data(record_at=today - forward, tr=histories[0].tr))
return histories
@staticmethod
async def make_query_image(
user: User, user_info: InfoSuccess, sprint: SoloRecord | None, blitz: SoloRecord | None
) -> bytes:
league = user_info.data.user.league
if not isinstance(league, RatedLeague) or league.vs is None:
raise TypeError
user_name = user_info.data.user.username.upper()
histories = await Processor.query_historical_data(user, user_info)
value_max, value_min = get_value_bounds([i.tr for i in histories])
split_value, offset = get_split(value_max, value_min)
if sprint is not None:
duration = timedelta(milliseconds=sprint.endcontext.final_time).total_seconds()
sprint_value = f'{duration:.1f}s' if duration < 60 else f'{duration // 60:.0f}m {duration % 60:.1f}s' # noqa: PLR2004
else:
sprint_value = 'N/A'
blitz_value = f'{blitz.endcontext.score:,}' if blitz is not None else 'N/A'
async with HostPage(
await render(
'tetrio/info',
TETRIOInfo(
user=TETRIOInfo.User(
avatar=f'https://tetr.io/user-content/avatars/{user_info.data.user.id}.jpg?rv={user_info.data.user.avatar_revision}'
if user_info.data.user.avatar_revision is not None
else f'{{"type":"identicon","hash":"{md5(user_info.data.user.id.encode()).hexdigest()}"}}', # noqa: S324
name=user_name,
bio=user_info.data.user.bio,
),
ranking=TETRIOInfo.Ranking(
rating=round(league.glicko, 2),
rd=round(league.rd, 2),
),
tetra_league=TETRIOInfo.TetraLeague(
rank=league.rank,
tr=round(league.rating, 2),
global_rank=league.standing,
pps=league.pps,
lpm=round(lpm := (league.pps * 24), 2),
apm=league.apm,
apl=round(league.apm / lpm, 2),
vs=league.vs,
adpm=round(adpm := (league.vs * 0.6), 2),
adpl=round(adpm / lpm, 2),
),
tetra_league_history=TETRIOInfo.TetraLeagueHistory(
data=histories,
split_interval=split_value,
min_tr=value_min,
max_tr=value_max,
offset=offset,
),
radar=TETRIOInfo.Radar(
app=(app := (league.apm / (60 * league.pps))),
dsps=(dsps := ((league.vs / 100) - (league.apm / 60))),
dspp=(dspp := (dsps / league.pps)),
ci=150 * dspp - 125 * app + 50 * (league.vs / league.apm) - 25,
ge=2 * ((app * dsps) / league.pps),
),
sprint=sprint_value,
blitz=blitz_value,
),
)
) as page_hash:
return await screenshot(urlunparse(('http', get_self_netloc(), f'/host/{page_hash}.html', '', '', '')))
async def get_user(self) -> None:
"""
用于获取 UserName 和 UserID 的函数
"""
if self.user.name is None:
self.user.name = (await self.get_user_info()).data.user.username
if self.user.ID is None:
self.user.ID = (await self.get_user_info()).data.user.id
async def get_user_info(self) -> InfoSuccess:
"""获取用户数据"""
if self.processed_data.user_info is None:
self.raw_response.user_info = await Cache.get(
splice_url([BASE_URL, 'users/', f'{self.user.ID or self.user.name}'])
)
user_info: UserInfo = type_validate_json(UserInfo, self.raw_response.user_info) # type: ignore[arg-type]
if isinstance(user_info, FailedModel):
raise RequestError(f'用户信息请求错误:\n{user_info.error}')
self.processed_data.user_info = user_info
return self.processed_data.user_info
async def get_user_records(self) -> RecordsSuccess:
"""获取Solo数据"""
if self.processed_data.user_records is None:
self.raw_response.user_records = await Cache.get(
splice_url([BASE_URL, 'users/', f'{self.user.ID or self.user.name}/', 'records'])
)
user_records: UserRecords = type_validate_json(UserRecords, self.raw_response.user_records) # type: ignore[arg-type]
if isinstance(user_records, FailedModel):
raise RequestError(f'用户Solo数据请求错误:\n{user_records.error}')
self.processed_data.user_records = user_records
return self.processed_data.user_records
@scheduler.scheduled_job('cron', hour='0,6,12,18', minute=0)
@retry(exception_type=RequestError, delay=timedelta(minutes=15))
async def get_io_rank_data() -> None:
league_all: LeagueAll = type_validate_json(
LeagueAll, # type: ignore[arg-type]
(data := await Cache.get(splice_url([BASE_URL, 'users/lists/league/all']))),
)
if isinstance(league_all, FailedModel):
raise RequestError(f'排行榜数据请求错误:\n{league_all.error}')
def pps(user: LeagueAllUser) -> float:
return user.league.pps
def apm(user: LeagueAllUser) -> float:
return user.league.apm
def vs(user: LeagueAllUser) -> float:
return user.league.vs
def _min(users: list[LeagueAllUser], field: Callable[[LeagueAllUser], float]) -> LeagueAllUser:
return min(users, key=field)
def _max(users: list[LeagueAllUser], field: Callable[[LeagueAllUser], float]) -> LeagueAllUser:
return max(users, key=field)
def build_extremes_data(
users: list[LeagueAllUser],
field: Callable[[LeagueAllUser], float],
sort: Callable[[list[LeagueAllUser], Callable[[LeagueAllUser], float]], LeagueAllUser],
) -> tuple[dict[str, str], float]:
user = sort(users, field)
return User(ID=user.id, name=user.username).dict(), field(user)
data_hash: str | None = await run_sync((await run_sync(sha512)(data)).hexdigest)()
async with open(get_data_file('nonebot_plugin_tetris_stats', f'{data_hash}.json.zst'), mode='wb') as file:
await file.write(await run_sync(ZstdCompressor(level=12, threads=-1).compress)(data))
users = [i for i in league_all.data.users if isinstance(i, LeagueAllUser)]
rank_to_users: defaultdict[Rank, list[LeagueAllUser]] = defaultdict(list)
for i in users:
rank_to_users[i.league.rank].append(i)
rank_info: list[IORank] = []
for rank, percentile in RANK_PERCENTILE.items():
offset = floor((percentile / 100) * len(users)) - 1
tr_line = users[offset].league.rating
rank_users = rank_to_users[rank]
rank_info.append(
IORank(
rank=rank,
tr_line=tr_line,
player_count=len(rank_users),
low_pps=(build_extremes_data(rank_users, pps, _min)),
low_apm=(build_extremes_data(rank_users, apm, _min)),
low_vs=(build_extremes_data(rank_users, vs, _min)),
avg_pps=mean({i.league.pps for i in rank_users}),
avg_apm=mean({i.league.apm for i in rank_users}),
avg_vs=mean({i.league.vs for i in rank_users}),
high_pps=(build_extremes_data(rank_users, pps, _max)),
high_apm=(build_extremes_data(rank_users, apm, _max)),
high_vs=(build_extremes_data(rank_users, vs, _max)),
update_time=league_all.cache.cached_at,
file_hash=data_hash,
)
)
async with get_session() as session:
session.add_all(rank_info)
await session.commit()
@driver.on_startup
async def _() -> None:
async with get_session() as session:
latest_time = await session.scalar(select(IORank.update_time).order_by(IORank.id.desc()).limit(1))
if latest_time is None or datetime.now(tz=UTC) - latest_time.replace(tzinfo=UTC) > timedelta(hours=6):
await get_io_rank_data()

View File

@@ -0,0 +1,20 @@
from datetime import datetime
from typing import Literal
from pydantic import BaseModel
class Cache(BaseModel):
status: str
cached_at: datetime
cached_until: datetime
class SuccessModel(BaseModel):
success: Literal[True]
cache: Cache
class FailedModel(BaseModel):
success: Literal[False]
error: str

View File

@@ -0,0 +1,59 @@
from pydantic import BaseModel, Field
from ..typing import Rank
from .base import FailedModel
from .base import SuccessModel as BaseSuccessModel
class _User(BaseModel):
id: str = Field(..., alias='_id')
username: str
role: str
xp: float
supporter: bool
verified: bool
country: str | None = None
class SuccessModel(BaseSuccessModel):
class Data(BaseModel):
class ValidUser(_User):
class League(BaseModel):
gamesplayed: int
gameswon: int
rating: float
glicko: float
rd: float
rank: Rank
bestrank: Rank
apm: float
pps: float
vs: float
decaying: bool
league: League
class InvalidUser(_User):
class League(BaseModel):
gamesplayed: int
gameswon: int
rating: float
glicko: float | None = None
rd: float | None = None
rank: Rank
bestrank: Rank
apm: float | None = None
pps: float | None = None
vs: float | None = None
decaying: bool
league: League
users: list[ValidUser | InvalidUser]
data: Data
LeagueAll = SuccessModel | FailedModel
ValidUser = SuccessModel.Data.ValidUser
InvalidUser = SuccessModel.Data.InvalidUser

View File

@@ -0,0 +1,21 @@
from typing import Literal
from ... import ProcessedData as ProcessedDataMeta
from ... import RawResponse as RawResponseMeta
from ..constant import GAME_TYPE
from .user_info import SuccessModel as InfoSuccess
from .user_records import SuccessModel as RecordsSuccess
class RawResponse(RawResponseMeta):
platform: Literal['IO'] = GAME_TYPE
user_info: bytes | None = None
user_records: bytes | None = None
class ProcessedData(ProcessedDataMeta):
platform: Literal['IO'] = GAME_TYPE
user_info: InfoSuccess | None = None
user_records: RecordsSuccess | None = None

View File

@@ -0,0 +1,17 @@
from typing import Literal
from ...schemas import BaseUser
from ..constant import GAME_TYPE
class User(BaseUser):
platform: Literal['IO'] = GAME_TYPE
ID: str | None = None
name: str | None = None
@property
def unique_identifier(self) -> str:
if self.ID is None:
raise ValueError('不完整的User!')
return self.ID

View File

@@ -0,0 +1,126 @@
from datetime import datetime
from typing import Literal
from pydantic import BaseModel, Field
from ..typing import Rank
from .base import FailedModel
from .base import SuccessModel as BaseSuccessModel
class SuccessModel(BaseSuccessModel):
class Data(BaseModel):
class User(BaseModel):
class Badge(BaseModel):
id: str
label: str
group: str | None = None
ts: datetime | Literal[False] | None = None
class NeverPlayedLeague(BaseModel):
gamesplayed: Literal[0]
gameswon: Literal[0]
rating: Literal[-1]
rank: Literal['z']
standing: Literal[-1]
standing_local: Literal[-1]
next_rank: None
prev_rank: None
next_at: Literal[-1]
prev_at: Literal[-1]
percentile: Literal[-1]
percentile_rank: Literal['z']
apm: None = Field(None)
pps: None = Field(None)
vs: None = Field(None)
decaying: bool
class NeverRatedLeague(BaseModel):
gamesplayed: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9]
gameswon: int
rating: Literal[-1]
rank: Literal['z']
standing: Literal[-1]
standing_local: Literal[-1]
next_rank: None
prev_rank: None
next_at: Literal[-1]
prev_at: Literal[-1]
percentile: Literal[-1]
percentile_rank: Literal['z']
apm: float
pps: float
vs: float
decaying: bool
class RatedLeague(BaseModel):
gamesplayed: int
gameswon: int
rating: float
rank: Rank
bestrank: Rank
standing: int
standing_local: int
next_rank: Rank | None = None
prev_rank: Rank | None = None
next_at: int
prev_at: int
percentile: float
percentile_rank: str
glicko: float
rd: float
apm: float
pps: float
vs: float | None = None
decaying: bool
class Connections(BaseModel):
class Discord(BaseModel):
id: str
username: str
discord: Discord | None = None
class Distinguishment(BaseModel):
type: str
id: str = Field(..., alias='_id')
username: str
role: Literal['anon', 'user', 'bot', 'halfmod', 'mod', 'admin', 'sysop', 'banned']
ts: datetime | None = None
botmaster: str | None = None
badges: list[Badge]
xp: float
gamesplayed: int
gameswon: int
gametime: float
country: str | None = None
badstanding: bool | None = None
supporter: bool | None = None # osk说是必有, 但实际上不是 fk osk
supporter_tier: int
verified: bool
league: NeverPlayedLeague | NeverRatedLeague | RatedLeague
avatar_revision: int | None = None
"""This user's avatar ID. Get their avatar at
https://tetr.io/user-content/avatars/{ USERID }.jpg?rv={ AVATAR_REVISION }"""
banner_revision: int | None = None
"""This user's banner ID. Get their banner at
https://tetr.io/user-content/banners/{ USERID }.jpg?rv={ BANNER_REVISION }
Ignore this field if the user is not a supporter."""
bio: str | None = None
connections: Connections
friend_count: int | None = None
distinguishment: Distinguishment | None = None
user: User
data: Data
NeverPlayedLeague = SuccessModel.Data.User.NeverPlayedLeague
NeverRatedLeague = SuccessModel.Data.User.NeverRatedLeague
RatedLeague = SuccessModel.Data.User.RatedLeague
UserInfo = SuccessModel | FailedModel

View File

@@ -0,0 +1,118 @@
from datetime import datetime
from pydantic import BaseModel, Field
from .base import FailedModel
from .base import SuccessModel as BaseSuccessModel
class EndContext(BaseModel):
class Time(BaseModel):
start: int
zero: bool
locked: bool
prev: int
frameoffset: int | None = None
class Clears(BaseModel):
singles: int
doubles: int
triples: int
quads: int
pentas: int | None = None
realtspins: int
minitspins: int
minitspinsingles: int
tspinsingles: int
minitspindoubles: int
tspindoubles: int
tspintriples: int
tspinquads: int
allclear: int
class Garbage(BaseModel):
sent: int
received: int
attack: int | None = None
cleared: int
class Finesse(BaseModel):
combo: int
faults: int
perfectpieces: int
seed: int
lines: int
level_lines: int
level_lines_needed: int
inputs: int
holds: int | None = None
time: Time
score: int
zenlevel: int | None = None
zenprogress: int | None = None
level: int
combo: int
currentcombopower: int | None = None # WTF
topcombo: int
btb: int
topbtb: int
currentbtbchainpower: int | None = None # WTF * 2
tspins: int
piecesplaced: int
clears: Clears
garbage: Garbage
kills: int
finesse: Finesse
final_time: float = Field(..., alias='finalTime')
gametype: str
class _User(BaseModel):
id: str = Field(..., alias='_id')
username: str
class _Record(BaseModel):
id: str = Field(..., alias='_id')
stream: str
replayid: str
user: _User
ts: datetime
ismulti: bool | None = None
class BaseModeRecord(BaseModel):
class SoloRecord(_Record):
endcontext: EndContext
class MultiRecord(_Record):
endcontext: list[EndContext]
record: SoloRecord | MultiRecord | None = None
rank: int | None = None
class SuccessModel(BaseSuccessModel):
class Data(BaseModel):
class Records(BaseModel):
class Sprint(BaseModeRecord): ...
class Blitz(BaseModeRecord): ...
sprint: Sprint = Field(..., alias='40l')
blitz: Blitz
class Zen(BaseModel):
level: int
score: int
records: Records
zen: Zen
data: Data
SoloRecord = BaseModeRecord.SoloRecord
MultiRecord = BaseModeRecord.MultiRecord
UserRecords = SuccessModel | FailedModel

View File

@@ -0,0 +1,22 @@
from typing import Literal
Rank = Literal[
'x',
'u',
'ss',
's+',
's',
's-',
'a+',
'a',
'a-',
'b+',
'b',
'b-',
'c+',
'c',
'c-',
'd+',
'd',
'z', # 未定级
]

View File

@@ -0,0 +1,31 @@
from abc import ABC, abstractmethod
from pydantic import BaseModel
from ..utils.typing import GameType
class Base(BaseModel):
platform: GameType
class BaseUser(ABC, Base):
"""游戏用户"""
def __eq__(self, __value: object) -> bool:
if isinstance(__value, BaseUser):
return self.unique_identifier == __value.unique_identifier
return False
@property
@abstractmethod
def unique_identifier(self) -> str:
raise NotImplementedError
class BaseRawResponse(Base):
"""原始请求数据"""
class BaseProcessedData(Base):
"""处理/验证后的数据"""

View File

@@ -0,0 +1,134 @@
from arclet.alconna import Alconna, AllParam, Arg, ArgFlag, Args, CommandMeta, Option
from nonebot.adapters import Bot, Event
from nonebot.matcher import Matcher
from nonebot_plugin_alconna import At, on_alconna
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import BotUserInfo, EventUserInfo, UserInfo # type: ignore[import-untyped]
from ...db import query_bind_info
from ...utils.exception import HandleNotFinishedError, NeedCatchError
from ...utils.platform import get_platform
from ...utils.typing import Me
from .. import add_default_handlers
from ..constant import BIND_COMMAND, QUERY_COMMAND
from .constant import GAME_TYPE
from .processor import Processor, User, identify_user_info
alc = on_alconna(
Alconna(
'top',
Option(
BIND_COMMAND[0],
Args(
Arg(
'account',
identify_user_info,
notice='TOP 用户名',
flags=[ArgFlag.HIDDEN],
)
),
alias=BIND_COMMAND[1:],
compact=True,
dest='bind',
help_text='绑定 TOP 账号',
),
Option(
QUERY_COMMAND[0],
Args(
Arg(
'target',
At | Me,
notice='@想要查询的人 | 自己',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
Arg(
'account',
identify_user_info | Me | At,
notice='TOP 用户名',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
),
alias=QUERY_COMMAND[1:],
compact=True,
dest='query',
help_text='查询 TOP 游戏信息',
),
Arg('other', AllParam, flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL]),
meta=CommandMeta(
description='查询 TetrisOnline波兰服 的信息',
example='top绑定scdhh\ntop查我',
compact=True,
fuzzy_match=True,
),
),
skip_for_unmatch=False,
auto_send_output=True,
aliases={'TOP'},
)
@alc.assign('bind')
async def _( # noqa: PLR0913
bot: Bot,
event: Event,
matcher: Matcher,
account: User,
bot_info: UserInfo = BotUserInfo(), # noqa: B008
user_info: UserInfo = EventUserInfo(), # noqa: B008
):
proc = Processor(
event_id=id(event),
user=account,
command_args=[],
)
try:
await (
await proc.handle_bind(
platform=get_platform(bot), account=event.get_user_id(), bot_info=bot_info, user_info=user_info
)
).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
async with get_session() as session:
bind = await query_bind_info(
session=session,
chat_platform=get_platform(bot),
chat_account=(target.target if isinstance(target, At) else event.get_user_id()),
game_platform=GAME_TYPE,
)
if bind is None:
await matcher.finish('未查询到绑定信息')
message = '* 由于无法验证绑定信息, 不能保证查询到的用户为本人\n'
proc = Processor(
event_id=id(event),
user=User(name=bind.game_account),
command_args=[],
)
try:
await (UniMessage(message) + await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(event: Event, matcher: Matcher, account: User):
proc = Processor(
event_id=id(event),
user=account,
command_args=[],
)
try:
await (await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
add_default_handlers(alc)

View File

@@ -0,0 +1,4 @@
from typing import Literal
GAME_TYPE: Literal['TOP'] = 'TOP'
BASE_URL = 'http://tetrisonline.pl/top/'

View File

@@ -0,0 +1,165 @@
from contextlib import suppress
from dataclasses import dataclass
from io import StringIO
from re import match
from typing import Literal
from urllib.parse import urlencode, urlunparse
from lxml import etree
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import UserInfo # type: ignore[import-untyped]
from pandas import read_html
from typing_extensions import override
from ...db import BindStatus, create_or_update_bind
from ...utils.avatar import get_avatar
from ...utils.exception import MessageFormatError, RequestError
from ...utils.host import HostPage, get_self_netloc
from ...utils.render import Bind, render
from ...utils.request import Request, splice_url
from ...utils.screenshot import screenshot
from .. import Processor as ProcessorMeta
from ..schemas import BaseUser
from .constant import BASE_URL, GAME_TYPE
from .schemas.response import ProcessedData, RawResponse
class User(BaseUser):
platform: Literal['TOP'] = GAME_TYPE
name: str
@property
@override
def unique_identifier(self) -> str:
return self.name
@dataclass
class Data:
lpm: float
apm: float
@dataclass
class GameData:
day: Data | None
total: Data | None
def identify_user_info(info: str) -> User | MessageFormatError:
if match(r'^[a-zA-Z0-9_]{1,16}$', info):
return User(name=info)
return MessageFormatError('用户名不合法')
class Processor(ProcessorMeta):
user: User
raw_response: RawResponse
processed_data: ProcessedData
@override
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
super().__init__(event_id, user, command_args)
self.raw_response = RawResponse()
self.processed_data = ProcessedData()
@property
@override
def game_platform(self) -> Literal['TOP']:
return GAME_TYPE
@override
async def handle_bind(self, platform: str, account: str, bot_info: UserInfo, user_info: UserInfo) -> UniMessage:
"""处理绑定消息"""
self.command_type = 'bind'
await self.check_user()
async with get_session() as session:
bind_status = await create_or_update_bind(
session=session,
chat_platform=platform,
chat_account=account,
game_platform=GAME_TYPE,
game_account=self.user.name,
)
if bind_status in (BindStatus.SUCCESS, BindStatus.UPDATE):
async with HostPage(
await render(
'binding',
Bind(
platform=self.game_platform,
status='unknown',
user=Bind.People(
avatar=await get_avatar(user_info, 'Data URI', None),
name=(await self.get_user_name()).upper(),
),
bot=Bind.People(
avatar=await get_avatar(bot_info, 'Data URI', '../../static/logo/logo.svg'),
name=bot_info.user_name,
),
command='top查我',
),
)
) as page_hash:
message = UniMessage.image(
raw=await screenshot(urlunparse(('http', get_self_netloc(), f'/host/{page_hash}.html', '', '', '')))
)
return message
@override
async def handle_query(self) -> UniMessage:
"""处理查询消息"""
self.command_type = 'query'
await self.check_user()
game_data = await self.get_game_data()
message = ''
if game_data.day is not None:
message += f'用户 {self.user.name} 24小时内统计数据为: '
message += f"\nL'PM: {round(game_data.day.lpm,2)} ( {round(game_data.day.lpm/24,2)} pps )"
message += f'\nAPM: {round(game_data.day.apm,2)} ( x{round(game_data.day.apm/game_data.day.lpm,2)} )'
else:
message += f'用户 {self.user.name} 暂无24小时内统计数据'
if game_data.total is not None:
message += '\n历史统计数据为: '
message += f"\nL'PM: {round(game_data.total.lpm,2)} ( {round(game_data.total.lpm/24,2)} pps )"
message += f'\nAPM: {round(game_data.total.apm,2)} ( x{round(game_data.total.apm/game_data.total.lpm,2)} )'
else:
message += '\n暂无历史统计数据'
return UniMessage(message)
async def get_user_profile(self) -> str:
"""获取用户信息"""
if self.processed_data.user_profile is None:
url = splice_url([BASE_URL, 'profile.php', f'?{urlencode({"user":self.user.name})}'])
self.raw_response.user_profile = await Request.request(url, is_json=False)
self.processed_data.user_profile = self.raw_response.user_profile.decode()
return self.processed_data.user_profile
async def check_user(self) -> None:
if 'user not found!' in await self.get_user_profile():
raise RequestError('用户不存在!')
async def get_user_name(self) -> str:
"""获取用户名"""
data = etree.HTML(await self.get_user_profile()).xpath('//div[@class="mycontent"]/h1/text()')
return data[0].replace("'s profile", '')
async def get_game_data(self) -> GameData:
"""获取游戏统计数据"""
html = etree.HTML(await self.get_user_profile())
day = None
with suppress(ValueError):
day = Data(
lpm=float(str(html.xpath('//div[@class="mycontent"]/text()[3]')[0]).replace('lpm:', '').strip()),
apm=float(str(html.xpath('//div[@class="mycontent"]/text()[4]')[0]).replace('apm:', '').strip()),
)
table = StringIO(
etree.tostring(
html.xpath('//div[@class="mycontent"]/table[@class="mytable"]')[0],
encoding='utf-8',
).decode()
)
dataframe = read_html(table, encoding='utf-8', header=0)[0]
total = Data(lpm=dataframe['lpm'].mean(), apm=dataframe['apm'].mean()) if len(dataframe) != 0 else None
return GameData(day=day, total=total)

View File

@@ -0,0 +1,16 @@
from typing import Literal
from ...schemas import BaseProcessedData, BaseRawResponse
from ..constant import GAME_TYPE
class RawResponse(BaseRawResponse):
platform: Literal['TOP'] = GAME_TYPE
user_profile: bytes | None = None
class ProcessedData(BaseProcessedData):
platform: Literal['TOP'] = GAME_TYPE
user_profile: str | None = None

View File

@@ -0,0 +1,197 @@
from typing import NoReturn
from arclet.alconna import Alconna, AllParam, Arg, ArgFlag, Args, CommandMeta, Option
from nonebot.adapters import Bot, Event
from nonebot.matcher import Matcher
from nonebot_plugin_alconna import At, on_alconna
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import BotUserInfo, EventUserInfo, UserInfo # type: ignore[import-untyped]
from ...db import query_bind_info
from ...utils.exception import HandleNotFinishedError, NeedCatchError, RequestError
from ...utils.platform import get_platform
from ...utils.typing import Me
from .. import add_default_handlers
from ..constant import BIND_COMMAND, QUERY_COMMAND
from .constant import GAME_TYPE
from .processor import Processor, User, identify_user_info
alc = on_alconna(
Alconna(
'茶服',
Option(
BIND_COMMAND[0],
Args(
Arg(
'account',
identify_user_info,
notice='茶服 用户名 / TeaID',
flags=[ArgFlag.HIDDEN],
)
),
alias=BIND_COMMAND[1:],
compact=True,
dest='bind',
help_text='绑定 茶服 账号',
),
Option(
QUERY_COMMAND[0],
Args(
Arg(
'target',
At | Me,
notice='@想要查询的人 | 自己',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
Arg(
'account',
identify_user_info,
notice='茶服 用户名 / TeaID',
flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL],
),
# 如果放在一个 Union Args 里, 验证顺序不能保证, 可能出错
),
alias=QUERY_COMMAND[1:],
compact=True,
dest='query',
help_text='查询 茶服 游戏信息',
),
Arg('other', AllParam, flags=[ArgFlag.HIDDEN, ArgFlag.OPTIONAL]),
meta=CommandMeta(
description='查询 TetrisOnline茶服 的信息',
example='茶服查我',
compact=True,
fuzzy_match=True,
),
),
skip_for_unmatch=False,
auto_send_output=True,
aliases={'tos', 'TOS'},
)
async def finish_special_query(matcher: Matcher, proc: Processor) -> NoReturn:
try:
await (await proc.handle_query()).finish()
except NeedCatchError as e:
if isinstance(e, RequestError) and '未找到此用户' in e.message:
matcher.skip()
await matcher.send(str(e))
raise HandleNotFinishedError from e
try:
from nonebot.adapters.onebot.v11 import GROUP as OB11GROUP
from nonebot.adapters.onebot.v11 import Bot as OB11Bot
from nonebot.adapters.onebot.v11 import MessageEvent as OB11MessageEvent
@alc.assign('query')
async def _(bot: OB11Bot, event: OB11MessageEvent, matcher: Matcher, target: At | Me):
if event.is_tome() and await OB11GROUP(bot, event):
await matcher.finish('不能查询bot的信息')
proc = Processor(
event_id=id(event),
user=User(teaid=f'onebot-{target.target}' if isinstance(target, At) else f'onebot-{event.get_user_id()}'),
command_args=[],
)
await finish_special_query(matcher, proc)
except ImportError:
pass
try:
from nonebot.adapters.kaiheila.event import MessageEvent as KookMessageEvent
@alc.assign('query')
async def _(event: KookMessageEvent, matcher: Matcher, target: At | Me):
proc = Processor(
event_id=id(event),
user=User(teaid=f'kook-{target.target}' if isinstance(target, At) else f'kook-{event.get_user_id()}'),
command_args=[],
)
await finish_special_query(matcher, proc)
except ImportError:
pass
try:
from nonebot.adapters.discord import MessageEvent as DiscordMessageEvent
@alc.assign('query')
async def _(event: DiscordMessageEvent, matcher: Matcher, target: At | Me):
proc = Processor(
event_id=id(event),
user=User(teaid=f'discord-{target.target}' if isinstance(target, At) else f'discord-{event.get_user_id()}'),
command_args=[],
)
await finish_special_query(matcher, proc)
except ImportError:
pass
@alc.assign('bind')
async def _( # noqa: PLR0913
bot: Bot,
event: Event,
matcher: Matcher,
account: User,
bot_info: UserInfo = BotUserInfo(), # noqa: B008
user_info: UserInfo = EventUserInfo(), # noqa: B008
):
proc = Processor(
event_id=id(event),
user=account,
command_args=[],
)
try:
await (
await proc.handle_bind(
platform=get_platform(bot), account=event.get_user_id(), bot_info=bot_info, nb_user_info=user_info
)
).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(bot: Bot, event: Event, matcher: Matcher, target: At | Me):
async with get_session() as session:
bind = await query_bind_info(
session=session,
chat_platform=get_platform(bot),
chat_account=(target.target if isinstance(target, At) else event.get_user_id()),
game_platform=GAME_TYPE,
)
if bind is None:
await matcher.finish('未查询到绑定信息')
message = '* 由于无法验证绑定信息, 不能保证查询到的用户为本人\n'
proc = Processor(
event_id=id(event),
user=User(teaid=bind.game_account),
command_args=[],
)
try:
await (UniMessage(message) + await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
@alc.assign('query')
async def _(event: Event, matcher: Matcher, account: User):
proc = Processor(
event_id=id(event),
user=account,
command_args=[],
)
try:
await (await proc.handle_query()).finish()
except NeedCatchError as e:
await matcher.send(str(e))
raise HandleNotFinishedError from e
add_default_handlers(alc)

View File

@@ -0,0 +1,10 @@
from typing import Literal
GAME_TYPE: Literal['TOS'] = 'TOS'
BASE_URL = {
'https://teatube.cn:8888/',
'http://cafuuchino1.studio26f.org:19970',
'http://cafuuchino2.studio26f.org:19970',
'http://cafuuchino3.studio26f.org:19970',
'http://cafuuchino4.studio26f.org:19970',
}

View File

@@ -0,0 +1,257 @@
from dataclasses import dataclass
from re import match
from typing import Literal
from urllib.parse import urlencode, urlunparse
from httpx import TimeoutException
from nonebot.compat import type_validate_json
from nonebot_plugin_alconna.uniseg import UniMessage
from nonebot_plugin_orm import get_session
from nonebot_plugin_userinfo import UserInfo as NBUserInfo # type: ignore[import-untyped]
from typing_extensions import override
from ...db import BindStatus, create_or_update_bind
from ...utils.avatar import get_avatar
from ...utils.exception import MessageFormatError, RequestError
from ...utils.host import HostPage, get_self_netloc
from ...utils.render import Bind, render
from ...utils.request import Request, splice_url
from ...utils.screenshot import screenshot
from .. import Processor as ProcessorMeta
from ..schemas import BaseUser
from .constant import BASE_URL, GAME_TYPE
from .schemas.response import ProcessedData, RawResponse
from .schemas.user_info import SuccessModel as InfoSuccess
from .schemas.user_info import UserInfo
from .schemas.user_profile import UserProfile
class User(BaseUser):
platform: Literal['TOS'] = GAME_TYPE
teaid: str | None = None
name: str | None = None
@property
@override
def unique_identifier(self) -> str:
if self.teaid is None:
raise ValueError('不完整的User!')
return self.teaid
@dataclass
class GameData:
num: int
pps: float
lpm: float
apm: float
adpm: float
apl: float
adpl: float
vs: float
def identify_user_info(info: str) -> User | MessageFormatError:
if (
match(
r'^(?!\.)(?!com[0-9]$)(?!con$)(?!lpt[0-9]$)(?!nul$)(?!prn$)[^\-][^\+][^\|\*\?\\\s\!:<>/$"]*[^\.\|\*\?\\\s\!:<>/$"]+$',
info,
)
and info.isdigit() is False
and 2 <= len(info) <= 18 # noqa: PLR2004
):
return User(name=info)
if info.startswith(('onebot-', 'qqguild-', 'kook-', 'discord-')) and info.split('-', maxsplit=1)[1].isdigit():
return User(teaid=info)
return MessageFormatError('用户名/QQ号不合法')
class Processor(ProcessorMeta):
user: User
raw_response: RawResponse
processed_data: ProcessedData
@override
def __init__(self, event_id: int, user: User, command_args: list[str]) -> None:
super().__init__(event_id, user, command_args)
self.raw_response = RawResponse(user_profile={})
self.processed_data = ProcessedData(user_profile={})
@property
@override
def game_platform(self) -> Literal['TOS']:
return GAME_TYPE
@override
async def handle_bind(
self, platform: str, account: str, bot_info: NBUserInfo, nb_user_info: NBUserInfo
) -> UniMessage:
"""处理绑定消息"""
self.command_type = 'bind'
await self.get_user()
async with get_session() as session:
bind_status = await create_or_update_bind(
session=session,
chat_platform=platform,
chat_account=account,
game_platform=GAME_TYPE,
game_account=self.user.unique_identifier,
)
user_info = await self.get_user_info()
if bind_status in (BindStatus.SUCCESS, BindStatus.UPDATE):
async with HostPage(
await render(
'binding',
Bind(
platform=self.game_platform,
status='unknown',
user=Bind.People(
avatar=await get_avatar(nb_user_info, 'Data URI', None), name=user_info.data.name
),
bot=Bind.People(
avatar=await get_avatar(bot_info, 'Data URI', '../../static/logo/logo.svg'),
name=bot_info.user_name,
),
command='茶服查我',
),
)
) as page_hash:
message = UniMessage.image(
raw=await screenshot(urlunparse(('http', get_self_netloc(), f'/host/{page_hash}.html', '', '', '')))
)
return message
@override
async def handle_query(self) -> UniMessage:
"""处理查询消息"""
self.command_type = 'query'
await self.get_user()
user_info = (await self.get_user_info()).data
message = f'用户 {user_info.name} ({user_info.teaid}) '
if user_info.ranked_games == '0':
message += '暂无段位统计数据'
else:
message += f', 段位分 {round(float(user_info.rating_now),2)}±{round(float(user_info.rd_now),2)} ({round(float(user_info.vol_now),2)}) '
game_data = await self.get_game_data()
if game_data is None:
message += ', 暂无游戏数据'
else:
message += f', 最近 {game_data.num} 局数据'
message += f"\nL'PM: {game_data.lpm} ( {game_data.pps} pps )"
message += f'\nAPM: {game_data.apm} ( x{game_data.apl} )'
message += f'\nADPM: {game_data.adpm} ( x{game_data.adpl} ) ( {game_data.vs}vs )'
message += f'\n40L: {float(user_info.pb_sprint)/1000:.2f}s' if user_info.pb_sprint != '2147483647' else ''
message += f'\nMarathon: {user_info.pb_marathon}' if user_info.pb_marathon != '0' else ''
message += f'\nChallenge: {user_info.pb_challenge}' if user_info.pb_challenge != '0' else ''
return UniMessage(message)
async def get_user(self) -> None:
"""
用于获取 UserName 和 UserID 的函数
"""
if self.user.name is None:
self.user.name = (await self.get_user_info()).data.name
if self.user.teaid is None:
self.user.teaid = (await self.get_user_info()).data.teaid
async def get_user_info(self) -> InfoSuccess:
"""获取用户信息"""
if self.processed_data.user_info is None:
if self.user.teaid is not None:
url = [
splice_url(
[
i,
'getTeaIdInfo',
f'?{urlencode({"teaId":self.user.teaid})}',
]
)
for i in BASE_URL
]
else:
url = [
splice_url(
[
i,
'getUsernameInfo',
f'?{urlencode({"username":self.user.name})}',
]
)
for i in BASE_URL
]
self.raw_response.user_info = await Request.failover_request(
url, failover_code=[502], failover_exc=(TimeoutException,)
)
user_info: UserInfo = type_validate_json(UserInfo, self.raw_response.user_info) # type: ignore[arg-type]
if not isinstance(user_info, InfoSuccess):
raise RequestError(f'用户信息请求错误:\n{user_info.error}')
self.processed_data.user_info = user_info
return self.processed_data.user_info
async def get_user_profile(self, other_parameter: dict[str, str | bytes] | None = None) -> UserProfile:
"""获取用户数据"""
if other_parameter is None:
other_parameter = {}
params = urlencode(dict(sorted(other_parameter.items())))
if self.processed_data.user_profile.get(params) is None:
self.raw_response.user_profile[params] = await Request.failover_request(
[
splice_url(
[
i,
'getProfile',
f'?{urlencode({"id":self.user.teaid or self.user.name,**other_parameter})}',
]
)
for i in BASE_URL
],
failover_code=[502],
failover_exc=(TimeoutException,),
)
self.processed_data.user_profile[params] = type_validate_json(
UserProfile, self.raw_response.user_profile[params]
)
return self.processed_data.user_profile[params]
async def get_game_data(self) -> GameData | None:
"""获取游戏数据"""
user_profile = await self.get_user_profile()
if user_profile.data == []:
return None
weighted_total_lpm = weighted_total_apm = weighted_total_adpm = 0.0
total_time = 0.0
num = 0
for i in user_profile.data:
# 排除单人局和时间为0的游戏
# 茶: 不计算没挖掘的局, 即使apm和lpm也如此
if i.num_players == 1 or i.time == 0 or i.dig is None:
continue
# 加权计算
time = i.time / 1000
lpm = 24 * (i.pieces / time)
apm = (i.attack / time) * 60
adpm = ((i.attack + i.dig) / time) * 60
weighted_total_lpm += lpm * time
weighted_total_apm += apm * time
weighted_total_adpm += adpm * time
total_time += time
num += 1
if num == 50: # noqa: PLR2004 # TODO: 将查询局数作为可选命令参数
break
if num == 0:
return None
# TODO: 如果有效局数不满50, 没有无dig信息的局, 且userData['data']内有50个局, 则继续往前获取信息
lpm = weighted_total_lpm / total_time
apm = weighted_total_apm / total_time
adpm = weighted_total_adpm / total_time
return GameData(
num=num,
pps=round(lpm / 24, 2),
lpm=round(lpm, 2),
apm=round(apm, 2),
adpm=round(adpm, 2),
apl=round((apm / lpm), 2),
adpl=round((adpm / lpm), 2),
vs=round((adpm / 60 * 100), 2),
)

View File

@@ -0,0 +1,20 @@
from typing import Literal
from ...schemas import BaseProcessedData, BaseRawResponse
from ..constant import GAME_TYPE
from .user_info import SuccessModel as InfoSuccess
from .user_profile import UserProfile
class RawResponse(BaseRawResponse):
platform: Literal['TOS'] = GAME_TYPE
user_profile: dict[str, bytes]
user_info: bytes | None = None
class ProcessedData(BaseProcessedData):
platform: Literal['TOS'] = GAME_TYPE
user_profile: dict[str, UserProfile]
user_info: InfoSuccess | None = None

View File

@@ -0,0 +1,86 @@
from datetime import datetime
from typing import Literal
from pydantic import BaseModel, Field
class SuccessModel(BaseModel):
class Data(BaseModel):
class PeriodMatch(BaseModel):
name: str
teaid: str = Field(..., alias='teaId')
rating: str
rd: str
start_time: datetime = Field(..., alias='startTime')
end_time: datetime = Field(..., alias='endTime')
win: str
lose: str
score: str
class UserDataTotalItem(BaseModel):
time_map: str = Field(..., alias='timeMap')
pieces_map: str = Field(..., alias='piecesMap')
clear_lines_map: str = Field(..., alias='clearLinesMap')
attacks_map: str = Field(..., alias='attacksMap')
dig_map: str = Field(..., alias='digMap')
send_map: str = Field(..., alias='sendMap')
rise_map: str = Field(..., alias='riseMap')
offset_map: str = Field(..., alias='offsetMap')
receive_map: str = Field(..., alias='receiveMap')
games_map: str = Field(..., alias='gamesMap')
tetris_map: str = Field(..., alias='tetrisMap')
combo_map: str = Field(..., alias='comboMap')
tspin_map: str = Field(..., alias='tspinMap')
b2b_map: str = Field(..., alias='b2bMap')
perfect_clear_map: str = Field(..., alias='perfectClearMap')
time_no_map: str = Field(..., alias='timeNoMap')
pieces_no_map: str = Field(..., alias='piecesNoMap')
clear_lines_no_map: str = Field(..., alias='clearLinesNoMap')
attacks_no_map: str = Field(..., alias='attacksNoMap')
dig_no_map: str = Field(..., alias='digNoMap')
send_no_map: str = Field(..., alias='sendNoMap')
rise_no_map: str = Field(..., alias='riseNoMap')
offset_no_map: str = Field(..., alias='offsetNoMap')
receive_no_map: str = Field(..., alias='receiveNoMap')
games_no_map: str = Field(..., alias='gamesNoMap')
tetris_no_map: str = Field(..., alias='tetrisNoMap')
combo_no_map: str = Field(..., alias='comboNoMap')
tspin_no_map: str = Field(..., alias='tspinNoMap')
b2b_no_map: str = Field(..., alias='b2bNoMap')
perfect_clear_no_map: str = Field(..., alias='perfectClearNoMap')
teaid: str = Field(..., alias='teaId')
name: str
total_exp: str = Field(..., alias='totalExp')
ranking: str
ranked_games: str = Field(..., alias='rankedGames')
rating_now: str = Field(..., alias='ratingNow')
rd_now: str = Field(..., alias='rdNow')
vol_now: str = Field(..., alias='volNow')
rating_last: str = Field(..., alias='ratingLast')
rd_last: str = Field(..., alias='rdLast')
vol_last: str = Field(..., alias='volLast')
period_matches: list[PeriodMatch] = Field(..., alias='periodMatches')
user_data_total: list[UserDataTotalItem] = Field(..., alias='userDataTotal')
ranking_items: str = Field(..., alias='rankingItems')
ranking_game_items: str = Field(..., alias='rankingGameItems')
training_level: str = Field(..., alias='trainingLevel')
training_wins: str = Field(..., alias='trainingWins')
pb_sprint: str = Field(..., alias='PBSprint')
pb_marathon: str = Field(..., alias='PBMarathon')
pb_challenge: str = Field(..., alias='PBChallenge')
register_date: datetime = Field(..., alias='registerDate')
last_login_date: datetime = Field(..., alias='lastLoginDate')
code: int
success: Literal[True]
data: Data
class FailedModel(BaseModel):
code: int
success: Literal[False]
error: str
UserInfo = SuccessModel | FailedModel

View File

@@ -0,0 +1,33 @@
from datetime import datetime
from typing import Literal
from pydantic import BaseModel
class UserProfile(BaseModel):
class Data(BaseModel):
idmultiplayergameresult: int
iduser: str
teaid: str
time: int
clear_lines: int
attack: int
send: int
offset: int
receive: int
rise: int
dig: int
pieces: int
max_combo: int
pc_count: int
place: int
num_players: int
fumen_code: Literal['0', '1'] # wtf
rule_set: str
garbage: str
idmultiplayergame: int
datetime: datetime
code: int
success: bool
data: list[Data]

View File

@@ -0,0 +1,52 @@
from base64 import b64encode
from io import BytesIO
from typing import Literal, overload
from nonebot_plugin_userinfo import UserInfo # type: ignore[import-untyped]
from PIL import Image
@overload
async def get_avatar(user: UserInfo, scheme: Literal['Data URI'], default: str | None) -> str:
"""获取用户头像的指定格式
Args:
user (UserInfo): 要获取的用户
scheme (Literal[&#39;Data URI&#39;]): 格式
default (str | None): 获取不到时的默认值
Raises:
TypeError: Can't get avatar: 当获取不到头像并且没有设置默认值时抛出
TypeError: Can't get avatar format: 当获取到的头像无法识别格式时抛出
Returns:
str: Data URI 格式的头像
"""
@overload
async def get_avatar(user: UserInfo, scheme: Literal['bytes'], default: str | None) -> bytes:
"""获取用户头像的指定格式
Args:
user (UserInfo): 要获取的用户
scheme (Literal[&#39;bytes&#39;]): 格式
default (str | None): 获取不到时的默认值
Returns:
bytes: bytes 格式的头像
"""
async def get_avatar(user: UserInfo, scheme: Literal['Data URI', 'bytes'], default: str | None) -> str | bytes:
if user.user_avatar is None:
if default is None:
raise TypeError("Can't get avatar")
return default
bot_avatar = await user.user_avatar.get_image()
if scheme == 'Data URI':
avatar_format = Image.open(BytesIO(bot_avatar)).format
if avatar_format is None:
raise TypeError("Can't get avatar format")
return f'data:{Image.MIME[avatar_format]};base64,{b64encode(bot_avatar).decode()}'
return bot_avatar

View File

@@ -0,0 +1,87 @@
import sys
from os import environ
from platform import system
from re import sub
from nonebot import get_driver
from nonebot.log import logger
from playwright.__main__ import main
from playwright.async_api import Browser, async_playwright
driver = get_driver()
global_config = driver.config
@driver.on_startup
async def _():
await BrowserManager._init_playwright()
@driver.on_shutdown
async def _():
await BrowserManager._close_browser()
class BrowserManager:
"""浏览器管理类"""
_browser: Browser | None = None
@classmethod
async def _init_playwright(cls) -> None:
if system() == 'Windows' and getattr(global_config, 'fastapi_reload', False):
raise ImportError('加载失败, Windows 必须设置 FASTAPI_RELOAD=false 才能正常运行 playwright')
logger.info('开始 安装/更新 playwright 浏览器')
environ['PLAYWRIGHT_DOWNLOAD_HOST'] = 'https://npmmirror.com/mirrors/playwright/'
if cls._call_playwright(['', 'install', 'firefox']):
logger.success('安装/更新 playwright 浏览器成功')
else:
logger.warning('playwright 浏览器 安装/更新 失败, 尝试使用原始仓库下载')
del environ['PLAYWRIGHT_DOWNLOAD_HOST']
if cls._call_playwright(['', 'install', 'firefox']):
logger.success('安装/更新 playwright 浏览器成功')
else:
logger.error('安装/更新 playwright 浏览器失败')
try:
await cls._start_browser()
except BaseException as e: # 不知道会有什么异常, 交给用户解决
raise ImportError(
'playwright 启动失败, 请尝试在命令行运行 playwright install-deps firefox, 如果仍然启动失败, 请参考上面的报错👆'
) from e
else:
logger.success('playwright 启动成功')
@classmethod
def _call_playwright(cls, argv: list[str]) -> bool:
"""等价于调用 playwright 的命令行程序"""
argv_backup = sys.argv.copy()
sys.argv[0] = sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.argv = argv
try:
main()
except SystemExit as e:
return e.code == 0
except BaseException: # noqa: BLE001
return False
finally:
sys.argv = argv_backup
return True
@classmethod
async def _start_browser(cls) -> Browser:
"""启动浏览器实例"""
playwright = await async_playwright().start()
cls._browser = await playwright.firefox.launch()
return cls._browser
@classmethod
async def get_browser(cls) -> Browser:
"""获取浏览器实例"""
return cls._browser or await cls._start_browser()
@classmethod
async def _close_browser(cls) -> None:
"""关闭浏览器实例"""
if isinstance(cls._browser, Browser):
await cls._browser.close()

View File

@@ -0,0 +1,39 @@
class TetrisStatsError(Exception):
"""所有 TetrisStats 发生的异常基类"""
def __init__(self, message: str = ''):
self.message = message
def __str__(self) -> str:
return self.message
def __repr__(self) -> str:
return self.message
class NeedCatchError(TetrisStatsError):
"""需要被捕获的异常基类"""
class RequestError(NeedCatchError):
"""请求错误"""
def __init__(self, message: str = '', *, status_code: int | None = None):
super().__init__(message)
self.status_code = status_code
class MessageFormatError(NeedCatchError):
"""用户发送的消息格式不正确"""
class DoNotCatchError(TetrisStatsError):
"""不应该被捕获的异常基类"""
class WhatTheFuckError(DoNotCatchError):
"""用于表示不应该出现的情况 ("""
class HandleNotFinishedError(DoNotCatchError):
"""任务没有正常完成处理的错误"""

View File

@@ -0,0 +1,70 @@
from hashlib import sha256
from ipaddress import IPv4Address, IPv6Address
from typing import ClassVar
from fastapi import FastAPI, status
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from nonebot import get_app, get_driver
from nonebot.log import logger
from nonebot_plugin_localstore import get_cache_dir # type: ignore[import-untyped]
from pydantic import IPvAnyAddress
from .templates import templates_dir
app = get_app()
driver = get_driver()
global_config = driver.config
cache_dir = get_cache_dir('nonebot_plugin_tetris_stats')
if not isinstance(app, FastAPI):
raise RuntimeError('本插件需要 FastAPI 驱动器才能运行') # noqa: TRY004
NOT_FOUND = HTMLResponse('404 Not Found', status_code=status.HTTP_404_NOT_FOUND)
class HostPage:
pages: ClassVar[dict[str, str]] = {}
def __init__(self, page: str) -> None:
self.page_hash = sha256(page.encode()).hexdigest()
self.pages[self.page_hash] = page
async def __aenter__(self) -> str:
return self.page_hash
async def __aexit__(self, exc_type, exc, tb) -> None: # noqa: ANN001
self.pages.pop(self.page_hash, None)
@driver.on_startup
def _():
app.mount(
'/host/assets',
StaticFiles(directory=templates_dir / 'assets'),
name='assets',
)
logger.success('assets mounted')
@app.get('/host/{page_hash}.html', status_code=status.HTTP_200_OK)
async def _(page_hash: str) -> HTMLResponse:
if page_hash in HostPage.pages:
return HTMLResponse(HostPage.pages[page_hash])
return NOT_FOUND
def get_self_netloc() -> str:
host: IPv4Address | IPv6Address | IPvAnyAddress = global_config.host
if isinstance(host, IPv4Address):
if host == IPv4Address('0.0.0.0'): # noqa: S104
host = IPv4Address('127.0.0.1')
netloc = f'{host}:{global_config.port}'
else:
if host == IPv6Address('::'):
host = IPv6Address('::1')
netloc = f'[{host}]:{global_config.port}'
return netloc

View File

@@ -0,0 +1,322 @@
from typing import overload
from .typing import Number
class TetrisMetricsBaseWithPPS:
def __init__(self, pps: Number, precision: int) -> None:
self._pps = pps
self.precision = precision
@property
def _lpm(self) -> Number:
return self._pps * 24
@property
def lpm(self) -> Number:
return round(self._lpm, self.precision)
@property
def pps(self) -> Number:
return round(self._pps, self.precision)
class TetrisMetricsBaseWithLPM:
def __init__(self, lpm: Number, precision: int) -> None:
self._lpm = lpm
self.precision = precision
@property
def lpm(self) -> Number:
return round(self._lpm, self.precision)
@property
def _pps(self) -> Number:
return self._lpm / 24
@property
def pps(self) -> Number:
return round(self._pps, self.precision)
class TetrisMetricsBaseWithVS:
def __init__(self, vs: Number, precision: int) -> None:
self._vs = vs
self.precision = precision
@property
def vs(self) -> Number:
return round(self._vs, self.precision)
@property
def _adpm(self) -> Number:
return self._vs * 0.6
@property
def adpm(self) -> Number:
return round(self._adpm, self.precision)
class TetrisMetricsBaseWithADPM:
def __init__(self, adpm: Number, precision: int) -> None:
self._adpm = adpm
self.precision = precision
@property
def _vs(self) -> Number:
return self._adpm / 0.6
@property
def vs(self) -> Number:
return round(self._vs, self.precision)
@property
def adpm(self) -> Number:
return round(self._adpm, self.precision)
class TetrisMetricsBasicWithPPS(TetrisMetricsBaseWithPPS):
def __init__(self, pps: Number, apm: Number, precision: int) -> None:
super().__init__(pps=pps, precision=precision)
self._apm = apm
@property
def apm(self) -> Number:
return round(self._apm, self.precision)
@property
def apl(self) -> Number:
return round(self._apm / self._lpm, self.precision)
class TetrisMetricsBasicWithLPM(TetrisMetricsBaseWithLPM):
def __init__(self, lpm: Number, apm: Number, precision: int):
super().__init__(lpm=lpm, precision=precision)
self._apm = apm
@property
def apm(self) -> Number:
return round(self._apm, self.precision)
@property
def apl(self) -> Number:
return round(self._apm / self._lpm, self.precision)
class TetrisMetricsProWithPPSVS(TetrisMetricsBasicWithPPS, TetrisMetricsBaseWithVS):
def __init__(self, pps: Number, apm: Number, vs: Number, precision: int) -> None:
super().__init__(pps=pps, apm=apm, precision=precision)
super(TetrisMetricsBaseWithPPS, self).__init__(vs=vs, precision=precision)
@property
def adpl(self) -> Number:
return round(self._adpm / self._lpm, self.precision)
class TetrisMetricsProWithPPSADPM(TetrisMetricsBasicWithPPS, TetrisMetricsBaseWithADPM):
def __init__(self, pps: Number, apm: Number, adpm: Number, precision: int) -> None:
super().__init__(pps=pps, apm=apm, precision=precision)
super(TetrisMetricsBaseWithPPS, self).__init__(adpm=adpm, precision=precision)
@property
def adpl(self) -> Number:
return round(self._adpm / self._lpm, self.precision)
class TetrisMetricsProWithLPMVS(TetrisMetricsBasicWithLPM, TetrisMetricsBaseWithVS):
def __init__(self, lpm: Number, apm: Number, vs: Number, precision: int) -> None:
super().__init__(lpm=lpm, apm=apm, precision=precision)
super(TetrisMetricsBaseWithLPM, self).__init__(vs=vs, precision=precision)
@property
def adpl(self) -> Number:
return round(self._adpm / self._lpm, self.precision)
class TetrisMetricsProWithLPMADPM(TetrisMetricsBasicWithLPM, TetrisMetricsBaseWithADPM):
def __init__(self, lpm: Number, apm: Number, adpm: Number, precision: int) -> None:
super().__init__(lpm=lpm, apm=apm, precision=precision)
super(TetrisMetricsBaseWithLPM, self).__init__(adpm=adpm, precision=precision)
@property
def adpl(self) -> Number:
return round(self._adpm / self._lpm, self.precision)
@overload
def get_metrics(
*,
pps: Number,
lpm: None = None,
apm: None = None,
vs: None = None,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsBaseWithPPS:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: Number,
apm: None = None,
vs: None = None,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsBaseWithLPM:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: None = None,
apm: None = None,
vs: Number,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsBaseWithVS:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: None = None,
apm: None = None,
vs: None = None,
adpm: Number,
precision: int = 2,
) -> TetrisMetricsBaseWithADPM:
...
@overload
def get_metrics(
*,
pps: Number,
lpm: None = None,
apm: Number,
vs: None = None,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsBasicWithPPS:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: Number,
apm: Number,
vs: None = None,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsBasicWithLPM:
...
@overload
def get_metrics(
*,
pps: Number,
lpm: None = None,
apm: Number,
vs: Number,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsProWithPPSVS:
...
@overload
def get_metrics(
*,
pps: Number,
lpm: None = None,
apm: Number,
vs: None = None,
adpm: Number,
precision: int = 2,
) -> TetrisMetricsProWithPPSADPM:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: Number,
apm: Number,
vs: Number,
adpm: None = None,
precision: int = 2,
) -> TetrisMetricsProWithLPMVS:
...
@overload
def get_metrics(
*,
pps: None = None,
lpm: Number,
apm: Number,
vs: None = None,
adpm: Number,
precision: int = 2,
) -> TetrisMetricsProWithLPMADPM:
...
def get_metrics( # noqa: PLR0911, PLR0912, PLR0913
*,
pps: Number | None = None,
lpm: Number | None = None,
apm: Number | None = None,
vs: Number | None = None,
adpm: Number | None = None,
precision: int = 2,
) -> (
TetrisMetricsBaseWithPPS
| TetrisMetricsBaseWithLPM
| TetrisMetricsBaseWithVS
| TetrisMetricsBaseWithADPM
| TetrisMetricsBasicWithPPS
| TetrisMetricsBasicWithLPM
| TetrisMetricsProWithPPSVS
| TetrisMetricsProWithLPMVS
| TetrisMetricsProWithPPSADPM
| TetrisMetricsProWithLPMADPM
):
if apm is None:
if pps is not None:
return TetrisMetricsBaseWithPPS(pps, precision=precision)
if lpm is not None:
return TetrisMetricsBaseWithLPM(lpm, precision=precision)
if vs is not None:
return TetrisMetricsBaseWithVS(vs, precision=precision)
if adpm is not None:
return TetrisMetricsBaseWithADPM(adpm, precision=precision)
elif vs is None and adpm is None:
if pps is not None:
return TetrisMetricsBasicWithPPS(pps, apm, precision=precision)
if lpm is not None:
return TetrisMetricsBasicWithLPM(lpm, apm, precision=precision)
else:
if vs is not None:
if pps is not None:
return TetrisMetricsProWithPPSVS(pps, apm, vs, precision=precision)
if lpm is not None:
return TetrisMetricsProWithLPMVS(lpm, apm, vs, precision=precision)
if adpm is not None:
if pps is not None:
return TetrisMetricsProWithPPSADPM(pps, apm, adpm, precision=precision)
if lpm is not None:
return TetrisMetricsProWithLPMADPM(lpm, apm, adpm, precision=precision)
raise TypeError

View File

@@ -0,0 +1,19 @@
from nonebot.adapters import Bot
def get_platform(bot: Bot) -> str:
try:
from nonebot.adapters.onebot.v12 import Bot as OB12Bot
if isinstance(bot, OB12Bot):
return bot.platform
except ImportError:
pass
try:
from nonebot.adapters.satori import Bot as SaBot
if isinstance(bot, SaBot):
return bot.platform
except ImportError:
pass
return bot.type

View File

@@ -0,0 +1,94 @@
from datetime import datetime, timezone
from typing import ClassVar
from nonebot import get_driver, get_plugin
from nonebot.adapters import Bot, Event
from nonebot.matcher import Matcher
from nonebot.message import run_postprocessor, run_preprocessor
from nonebot_plugin_orm import get_session
from ..db.models import HistoricalData
UTC = timezone.utc
driver = get_driver()
class Recorder:
matchers: ClassVar[set[type[Matcher]]] = set()
historical_data: ClassVar[dict[int, tuple[HistoricalData, bool]]] = {}
error_event: ClassVar[set[int]] = set()
@classmethod
def create_historical_data(cls, event_id: int, historical_data: HistoricalData) -> None:
cls.historical_data[event_id] = (historical_data, False)
@classmethod
def update_historical_data(cls, event_id: int, historical_data: HistoricalData) -> None:
if event_id not in cls.historical_data:
raise KeyError
cls.historical_data[event_id] = (historical_data, True)
@classmethod
def get_historical_data(cls, event_id: int) -> HistoricalData:
return cls.historical_data[event_id][0]
@classmethod
async def save_historical_data(cls, event_id: int) -> None:
historical_data, completed = cls.del_historical_data(event_id)
if completed:
async with get_session() as session:
session.add(historical_data)
await session.commit()
@classmethod
def del_historical_data(cls, event_id: int) -> tuple[HistoricalData, bool]:
return cls.historical_data.pop(event_id)
@classmethod
def add_error_event(cls, event_id: int) -> None:
cls.error_event.add(event_id)
@classmethod
def del_error_event(cls, event_id: int) -> None:
cls.error_event.remove(event_id)
@classmethod
def is_error_event(cls, event_id: int) -> bool:
return event_id in cls.error_event
@driver.on_startup
def _():
plugin = get_plugin('nonebot_plugin_tetris_stats')
if plugin is not None:
Recorder.matchers = plugin.matcher
else:
raise RuntimeError('获取不到自身插件对象')
@run_preprocessor
def _(bot: Bot, event: Event, matcher: Matcher):
if isinstance(matcher, tuple(Recorder.matchers)):
Recorder.create_historical_data(
event_id=id(event),
historical_data=HistoricalData(
trigger_time=datetime.now(tz=UTC),
bot_platform=bot.type,
bot_account=bot.self_id,
source_type=event.get_type(),
source_account=event.get_session_id(),
message=event.get_message(),
),
)
@run_postprocessor
async def _(event: Event, matcher: Matcher, exception: Exception | None):
if isinstance(matcher, tuple(Recorder.matchers)):
event_id = id(event)
if exception is not None:
Recorder.add_error_event(event_id)
Recorder.del_historical_data(event_id)
else:
await Recorder.save_historical_data(event_id)

View File

@@ -0,0 +1,104 @@
from datetime import datetime
from typing import Annotated, ClassVar, Literal, overload
from jinja2 import Environment, FileSystemLoader
from nonebot.compat import PYDANTIC_V2
from pydantic import BaseModel
from ..game_data_processor.io_data_processor.typing import Rank
from .templates import templates_dir
from .typing import Number
if PYDANTIC_V2:
from pydantic import PlainSerializer
env = Environment(
loader=FileSystemLoader(templates_dir), autoescape=True, trim_blocks=True, lstrip_blocks=True, enable_async=True
)
def format_datetime_to_timestamp(dt: datetime) -> int:
return int(dt.timestamp() * 1000)
class Bind(BaseModel):
class People(BaseModel):
avatar: str
name: str
platform: Literal['TETR.IO', 'TOP', 'TOS']
status: Literal['error', 'success', 'unknown', 'unlink', 'unverified']
user: People
bot: People
command: str
class TETRIOInfo(BaseModel):
class User(BaseModel):
avatar: str
name: str
bio: str | None
class Ranking(BaseModel):
rating: Number
rd: Number
class TetraLeague(BaseModel):
rank: Rank
tr: Number
global_rank: Number
pps: Number
lpm: Number
apm: Number
apl: Number
vs: Number
adpm: Number
adpl: Number
class TetraLeagueHistory(BaseModel):
class Data(BaseModel):
if PYDANTIC_V2:
record_at: Annotated[datetime, PlainSerializer(format_datetime_to_timestamp, return_type=int)]
else:
record_at: datetime # type: ignore[no-redef]
tr: Number
data: list[Data]
split_interval: Number
min_tr: Number
max_tr: Number
offset: Number
class Radar(BaseModel):
app: Number
dsps: Number
dspp: Number
ci: Number
ge: Number
user: User
ranking: Ranking
tetra_league: TetraLeague
tetra_league_history: TetraLeagueHistory
radar: Radar
sprint: str
blitz: str
if not PYDANTIC_V2:
class Config:
json_encoders: ClassVar[dict] = {datetime: format_datetime_to_timestamp}
@overload
async def render(render_type: Literal['binding'], data: Bind) -> str: ...
@overload
async def render(render_type: Literal['tetrio/info'], data: TETRIOInfo) -> str: ...
async def render(render_type: Literal['binding', 'tetrio/info'], data: Bind | TETRIOInfo) -> str:
if PYDANTIC_V2:
return await env.get_template('index.html').render_async(path=render_type, data=data.model_dump_json())
return await env.get_template('index.html').render_async(path=render_type, data=data.json())

View File

@@ -0,0 +1,165 @@
from collections.abc import Sequence
from http import HTTPStatus
from urllib.parse import urljoin, urlparse
from aiofiles import open
from httpx import AsyncClient, HTTPError
from nonebot import get_driver, get_plugin_config
from nonebot.log import logger
from playwright.async_api import Response
from ujson import JSONDecodeError, dumps, loads
from ..config.config import CACHE_PATH, Config
from .browser import BrowserManager
from .exception import RequestError
driver = get_driver()
config = get_plugin_config(Config)
@driver.on_startup
async def _():
await Request._init_cache()
await Request._read_cache()
@driver.on_shutdown
async def _():
await Request._write_cache()
def splice_url(url_list: list[str]) -> str:
url = ''
if len(url_list):
url = url_list.pop(0)
for i in url_list:
url = urljoin(url, i)
return url
class Request:
"""网络请求相关类"""
_CACHE_FILE = CACHE_PATH / 'cloudflare_cache.json'
_headers: dict | None = None
_cookies: dict | None = None
@classmethod
async def _anti_cloudflare(cls, url: str) -> bytes:
"""用firefox硬穿五秒盾"""
browser = await BrowserManager.get_browser()
async with await browser.new_context() as context, await context.new_page() as page:
response = await page.goto(url)
attempts = 0
while attempts < 60: # noqa: PLR2004
attempts += 1
text = await page.locator('body').text_content()
if text is None:
await page.wait_for_timeout(1000)
continue
if await page.title() == 'Please Wait... | Cloudflare':
logger.warning('疑似触发了 Cloudflare 的验证码')
break
try:
loads(text)
except JSONDecodeError:
await page.wait_for_timeout(1000)
else:
if not isinstance(response, Response):
raise RequestError('api请求失败')
cls._headers = await response.request.all_headers()
try:
cls._cookies = {
name: value
for i in await context.cookies()
if (name := i.get('name')) is not None and (value := i.get('value')) is not None
}
except KeyError:
cls._cookies = None
return await response.body()
raise RequestError('绕过五秒盾失败')
@classmethod
async def _init_cache(cls) -> None:
"""初始化缓存文件"""
if not cls._CACHE_FILE.exists():
async with open(file=cls._CACHE_FILE, mode='w', encoding='UTF-8') as file:
await file.write(dumps({'headers': cls._headers, 'cookies': cls._cookies}))
@classmethod
async def _read_cache(cls) -> None:
"""读取缓存文件"""
try:
async with open(file=cls._CACHE_FILE, mode='r', encoding='UTF-8') as file:
json = loads(await file.read())
except FileNotFoundError:
await cls._init_cache()
except (PermissionError, JSONDecodeError):
cls._CACHE_FILE.unlink()
await cls._init_cache()
else:
cls._headers = json['headers']
cls._cookies = json['cookies']
@classmethod
async def _write_cache(cls) -> None:
"""写入缓存文件"""
try:
async with open(file=cls._CACHE_FILE, mode='r+', encoding='UTF-8') as file:
await file.write(dumps({'headers': cls._headers, 'cookies': cls._cookies}))
except FileNotFoundError:
await cls._init_cache()
except (PermissionError, JSONDecodeError):
cls._CACHE_FILE.unlink()
await cls._init_cache()
@classmethod
async def request(cls, url: str, *, is_json: bool = True) -> bytes:
"""请求api"""
try:
async with AsyncClient(cookies=cls._cookies, timeout=config.tetris_req_timeout) as session:
response = await session.get(url, headers=cls._headers)
if response.status_code != HTTPStatus.OK:
raise RequestError(
f'请求错误 code: {response.status_code} {HTTPStatus(response.status_code).phrase}\n{response.text}',
status_code=response.status_code,
)
if is_json:
loads(response.content)
return response.content
except HTTPError as e:
raise RequestError(f'请求错误 \n{e!r}') from e
except JSONDecodeError:
if urlparse(url).netloc.lower().endswith('tetr.io'):
return await cls._anti_cloudflare(url)
raise
@classmethod
async def failover_request(
cls,
urls: Sequence[str],
*,
failover_code: Sequence[int],
failover_exc: tuple[type[BaseException], ...],
is_json: bool = True,
) -> bytes:
error_list: list[RequestError] = []
for i in urls:
logger.debug(f'尝试请求 {i}')
try:
return await cls.request(i, is_json=is_json)
except RequestError as e:
if e.status_code in failover_code: # 如果状态码在 failover_code 中, 则继续尝试下一个URL
error_list.append(e)
continue
# 如果状态码不在故障转移列表中, 则查找异常栈, 如果异常栈内有 failover_exc 内的异常类型, 则继续尝试下一个URL
tb = e.__traceback__
while tb is not None:
if isinstance(tb.tb_frame.f_locals.get('exc_value'), failover_exc):
error_list.append(e)
break
tb = tb.tb_next
else:
raise
continue
raise RequestError(f'所有地址皆不可用\n{error_list!r}')

View File

@@ -0,0 +1,37 @@
from asyncio import sleep
from collections.abc import Awaitable, Callable
from datetime import timedelta
from functools import wraps
from typing import TypeVar, cast
from nonebot.log import logger
T = TypeVar('T')
def retry(
max_attempts: int = 3,
exception_type: type[BaseException] | tuple[type[BaseException], ...] = Exception,
delay: timedelta | None = None,
) -> Callable[[Callable[..., Awaitable[T]]], Callable[..., Awaitable[T]]]:
def decorator(func: Callable[..., Awaitable[T]]) -> Callable[..., Awaitable[T]]:
@wraps(func)
async def wrapper(*args, **kwargs) -> T: # noqa: ANN002, ANN003
attempts = 0
while attempts < max_attempts + 1:
try:
return await func(*args, **kwargs)
except exception_type as e: # noqa: PERF203
logger.exception(e)
attempts += 1
if attempts <= max_attempts:
if delay is not None:
await sleep(delay.total_seconds())
logger.debug(f'Retrying: {func.__name__} ({attempts}/{max_attempts})')
continue
raise
raise RuntimeError('Unexpectedly reached the end of the retry loop')
return cast(Callable[..., Awaitable[T]], wrapper)
return decorator

View File

@@ -0,0 +1,11 @@
from .browser import BrowserManager
async def screenshot(url: str) -> bytes:
browser = await BrowserManager.get_browser()
async with (
await browser.new_page(no_viewport=True, viewport={'width': 0, 'height': 0}) as page,
):
await page.goto(url)
await page.wait_for_load_state('networkidle')
return await page.screenshot(full_page=True, type='png')

View File

@@ -0,0 +1,60 @@
from asyncio.subprocess import PIPE, create_subprocess_exec
from shutil import rmtree
from nonebot import get_driver
from nonebot.log import logger
from nonebot_plugin_localstore import get_data_dir # type: ignore[import-untyped]
driver = get_driver()
templates_dir = get_data_dir('nonebot_plugin_tetris_stats') / 'templates'
@driver.on_startup
async def init_templates() -> None:
try:
await create_subprocess_exec('git', '--version', stdout=PIPE)
except FileNotFoundError as e:
raise RuntimeError(
'未找到 git, 请确保 git 已安装并在环境变量中\n安装步骤请参阅: https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git'
) from e
if not templates_dir.exists():
logger.info('模板仓库不存在, 正在尝试初始化...')
proc = await create_subprocess_exec(
'git',
'clone',
'-b',
'gh-pages',
'https://github.com/A-Minos/tetris-stats-templates',
templates_dir,
'--depth=1',
stdout=PIPE,
stderr=PIPE,
)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
for i in stderr.decode().splitlines():
logger.error(i)
raise RuntimeError('初始化模板仓库失败')
logger.success('模板仓库初始化成功')
return
proc = await create_subprocess_exec(
'git', 'rev-parse', '--is-inside-work-tree', stdout=PIPE, stderr=PIPE, cwd=templates_dir
)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
for i in stderr.decode().splitlines():
logger.error(i)
logger.warning('模板仓库状态异常, 尝试重新初始化')
rmtree(templates_dir)
await init_templates()
return
logger.info('正在更新模板仓库...')
proc = await create_subprocess_exec('git', 'pull', stdout=PIPE, stderr=PIPE, cwd=templates_dir)
stdout, stderr = await proc.communicate()
logger.info(stdout.decode().strip())
if proc.returncode != 0:
for i in stderr.decode().splitlines():
logger.error(i)
raise RuntimeError('更新模板仓库失败')
logger.success('模板仓库更新成功')

View File

@@ -0,0 +1,61 @@
from collections.abc import Awaitable, Callable
from typing import Any, Literal
Number = float | int
GameType = Literal['IO', 'TOP', 'TOS']
CommandType = Literal['bind', 'query']
AsyncCallable = Callable[..., Awaitable[Any]]
Me = Literal[
'',
'自己',
'我等',
'卑人',
'',
'老身',
'',
'老娘',
'本姑娘',
'本大爷',
'鄙人',
'寡人',
'小生',
'贫僧',
'本人',
'',
'',
'',
'',
'',
'me',
'洒家',
'在下',
'',
'人家',
'本小姐',
'老夫',
'老子',
'',
'本尊',
'',
'拙者',
'',
'',
'自分',
'吾輩',
'我輩',
'',
'己等',
'俺等',
'此方',
'',
'',
'劳资',
'本宝宝',
'',
'本喵',
'watashi',
'i',
'myself',
'self',
'oneself',
]

View File

@@ -0,0 +1,3 @@
from importlib.metadata import version
__version__ = version('nonebot_plugin_tetris_stats')

3465
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +1,110 @@
[tool.poetry]
name = "nonebot-plugin-tetris-stats"
version = "0.1.0"
description = "一个基于nonebot2的用于查询TETRIS相关游戏玩家数据的插件"
authors = ["scdhh <wallfjjd@gmail.com>"]
readme = "README.md"
homepage = "https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats"
repository = "https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats"
license = "MIT"
name = 'nonebot-plugin-tetris-stats'
version = '1.1.1'
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
authors = ['scdhh <wallfjjd@gmail.com>']
readme = 'README.md'
homepage = 'https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats'
repository = 'https://github.com/shoucandanghehe/nonebot-plugin-tetris-stats'
license = 'AGPL-3.0'
[tool.poetry.dependencies]
python = "^3.10"
nb-cli = "^0.6.7"
nonebot-adapter-onebot = "^2.0.0-beta.1"
aiohttp = "^3.8.1"
asyncio = "^3.4.3"
python = '^3.10'
nonebot2 = { extras = ["fastapi"], version = "^2.3.0" }
lxml = '^5.1.0'
pandas = '>=1.4.3,<3.0.0'
playwright = '^1.41.2'
ujson = '^5.9.0'
aiofiles = "^23.2.1"
nonebot-plugin-orm = ">=0.1.1,<0.8.0"
nonebot-plugin-localstore = "^0.6.0"
httpx = "^0.27.0"
nonebot-plugin-alconna = ">=0.40"
nonebot-plugin-apscheduler = "^0.4.0"
aiocache = "^0.12.2"
zstandard = "^0.22.0"
jinja2 = "^3.1.3"
nonebot-plugin-userinfo = "^0.2.4"
pillow = "^10.3.0"
rich = "^13.7.1"
[tool.poetry.dev-dependencies]
mypy = "^0.950"
[tool.poetry.group.dev.dependencies]
mypy = '>=1.9'
types-ujson = '^5.9.0'
pandas-stubs = '>=1.5.2,<3.0.0'
ruff = '>=0.3.0'
types-aiofiles = "^23.2.0.20240106"
types-lxml = "^2024.2.9"
nonebot-plugin-orm = { extras = ["default"], version = ">=0.3,<0.8" }
nonebot-adapter-onebot = "^2.4.1"
nonebot-adapter-satori = "^0.11.4"
nonebot-adapter-kaiheila = "^0.3.4"
nonebot-adapter-discord = "^0.1.3"
types-pillow = "^10.2.0.20240423"
[tool.poetry.group.debug.dependencies]
objprint = '^0.2.2'
viztracer = "^0.16.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ['poetry-core>=1.0.0']
build-backend = 'poetry.core.masonry.api'
[tool.ruff]
line-length = 120
target-version = "py310"
[tool.ruff.lint]
select = [
'F', # pyflakes
'E', # pycodestyle errors
'W', # pycodestyle warnings
'I', # isort
'N', # PEP8-naming
'UP', # pyupgrade
'YTT', # flake8-2020
'ANN', # flake8-annotations
'ASYNC', # flake8-async
'S', # flake8-bandit
'BLE', # flake8-blind-except
'FBT', # flake8-boolean-trap
'B', # flake8-bugbear
'A', # flake8-builtins
'C4', # flake8-comprehensions
'DTZ', # flake8-datetimez
'FA', # flake8-future-annotations
'ISC', # flake8-implicit-str-concat
'PIE', # flake8-pie
'T20', # flake8-print
'Q', # flake8-quotes
'RSE', # flake8-raise
'RET', # flake8-return
'SIM', # flake8-simplify
'PTH', # flake8-use-pathlib
'PD', # pandas-vet
'PL', # pylint
'TRY', # tryceratops
'FLY', # flynt
'PERF', # Perflint
'RUF', # Ruff-specific rules
]
ignore = [
'E501', # 过长的行由 ruff format 处理, 剩余的都是字符串
'ANN101', # 由 type checker 自动推断
'ANN102', # 由 type checker 自动推断
'ANN202', # 向 NoneBot 注册的函数
'TRY003',
]
flake8-quotes = { inline-quotes = 'single', multiline-quotes = 'double' }
[tool.ruff.lint.flake8-annotations]
mypy-init-return = true
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["id"]
[tool.ruff.format]
quote-style = 'single'
[tool.nonebot]
plugins = ['nonebot_plugin_tetris_stats']