From a16914f53433599e214fafdff8fd1f86072fdc26 Mon Sep 17 00:00:00 2001 From: XiaoDeng3386 <1744793737@qq.com> Date: Thu, 14 Aug 2025 13:45:42 +0000 Subject: [PATCH 01/12] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=B8=82=E5=9C=BA?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 5 +- migrations/versions/9f6eedd5686c_.py | 52 ++++++++ pyproject.toml | 4 +- src/lang/zh_hans/market.yaml | 16 +++ src/plugins/nonebot_plugin_market/__init__.py | 19 +++ src/plugins/nonebot_plugin_market/__main__.py | 120 ++++++++++++++++++ src/plugins/nonebot_plugin_market/help.yaml | 3 + src/plugins/nonebot_plugin_market/models.py | 19 +++ src/pyproject.toml | 3 +- 9 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 migrations/versions/9f6eedd5686c_.py create mode 100644 src/lang/zh_hans/market.yaml create mode 100644 src/plugins/nonebot_plugin_market/__init__.py create mode 100644 src/plugins/nonebot_plugin_market/__main__.py create mode 100644 src/plugins/nonebot_plugin_market/help.yaml create mode 100644 src/plugins/nonebot_plugin_market/models.py diff --git a/.vscode/settings.json b/.vscode/settings.json index fa339e39c..33730e785 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,8 @@ "plaintext": false, "markdown": false, "scminput": false - } + }, + "python-envs.defaultEnvManager": "ms-python.python:poetry", + "python-envs.defaultPackageManager": "ms-python.python:poetry", + "python-envs.pythonProjects": [] } \ No newline at end of file diff --git a/migrations/versions/9f6eedd5686c_.py b/migrations/versions/9f6eedd5686c_.py new file mode 100644 index 000000000..fb905b23f --- /dev/null +++ b/migrations/versions/9f6eedd5686c_.py @@ -0,0 +1,52 @@ +"""empty message + +迁移 ID: 9f6eedd5686c +父迁移: f79433854a65 +创建时间: 2025-08-14 13:39:38.284103 + +""" +from __future__ import annotations + +from collections.abc import Sequence + +from alembic import op +import sqlalchemy as sa + + +revision: str = '9f6eedd5686c' +down_revision: str | Sequence[str] | None = 'f79433854a65' +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! ### + op.create_table('nonebot_plugin_market_marketitem', + sa.Column('item_id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('item_namespace', sa.String(length=64), nullable=False), + sa.Column('remain_count', sa.Integer(), nullable=False), + sa.Column('price', sa.Float(), nullable=False), + sa.Column('user_id', sa.String(length=128), nullable=False), + sa.Column('item_data', sa.LargeBinary(), nullable=False), + sa.PrimaryKeyConstraint('item_id', name=op.f('pk_nonebot_plugin_market_marketitem')), + info={'bind_key': 'nonebot_plugin_market'} + ) + op.create_table('nonebot_plugin_market_selllog', + sa.Column('item_namespace', sa.String(length=64), nullable=False), + sa.Column('sold_count', sa.Integer(), nullable=False), + sa.Column('price_sum', sa.Float(), nullable=False), + sa.PrimaryKeyConstraint('item_namespace', name=op.f('pk_nonebot_plugin_market_selllog')), + info={'bind_key': 'nonebot_plugin_market'} + ) + # ### end Alembic commands ### + + +def downgrade(name: str = "") -> None: + if name: + return + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('nonebot_plugin_market_selllog') + op.drop_table('nonebot_plugin_market_marketitem') + # ### end Alembic commands ### diff --git a/pyproject.toml b/pyproject.toml index 8d81391d4..3bf379622 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ plugins = [ "nonebot_plugin_waiter", "nonebot_plugin_bilichat", "nonebot_plugin_picmcstat", - "nonebot_plugin_fakepic", # Custom plugins "nonebot_plugin_access", @@ -82,7 +81,8 @@ plugins = [ "nonebot_plugin_cave_image_prompt", "nonebot_plugin_hkrpg_calendar", "nonebot_plugin_ba_calendar", - "nonebot_plugin_everyday_wife" + "nonebot_plugin_everyday_wife", + "nonebot_plugin_market" ] plugin_dirs = [] builtin_plugins = [] diff --git a/src/lang/zh_hans/market.yaml b/src/lang/zh_hans/market.yaml new file mode 100644 index 000000000..9e59963f6 --- /dev/null +++ b/src/lang/zh_hans/market.yaml @@ -0,0 +1,16 @@ +help: + description: + details: + usage1: + usage2: + usage3: +main: + info: +sell: + index_error: + item_not_enough: + wrong_count: + not_soldable: + done: +buy: + finish: \ No newline at end of file diff --git a/src/plugins/nonebot_plugin_market/__init__.py b/src/plugins/nonebot_plugin_market/__init__.py new file mode 100644 index 000000000..68d8e81ff --- /dev/null +++ b/src/plugins/nonebot_plugin_market/__init__.py @@ -0,0 +1,19 @@ +from nonebot import require +from nonebot.plugin import PluginMetadata + + +__plugin_meta__ = PluginMetadata( + name="nonebot-plugin-market", + description="", + usage="", + config=None, +) + +require("nonebot_plugin_orm") +require("nonebot_plugin_alconna") +require("nonebot_plugin_larklang") +require("nonebot_plugin_larkutils") +require("nonebot_plugin_bag") +require("nonebot_plugin_items") + +from . import __main__ diff --git a/src/plugins/nonebot_plugin_market/__main__.py b/src/plugins/nonebot_plugin_market/__main__.py new file mode 100644 index 000000000..a5ababe9e --- /dev/null +++ b/src/plugins/nonebot_plugin_market/__main__.py @@ -0,0 +1,120 @@ +import json +from nonebot_plugin_alconna import Alconna, on_alconna, Args, Subcommand +from nonebot_plugin_items.base.stack import ItemStack +from nonebot_plugin_items.utils.get import get_item +from nonebot_plugin_items.utils.string import get_location_by_id +from nonebot_plugin_larkuser.utils.user import get_user +from nonebot_plugin_larkutils import get_user_id +from nonebot_plugin_larklang import LangHelper +from nonebot_plugin_bag.utils.bag import get_bag_item, give_item +from nonebot_plugin_orm import get_session, AsyncSession +from .models import MarketItem, SellLog +from sqlalchemy import select + + +lang = LangHelper() +matcher = on_alconna(Alconna( + "market", + Subcommand("sell", Args["bag_index", int], Args["count", int, 0], Args["price_diff", str, ""]), + Subcommand("buy", Args["name", str], Args["count", int, 1]) +)) + + +async def get_average_price(item_data: ItemStack, session: AsyncSession) -> float: + result = await session.get(SellLog, {"item_namespace": str(item_data.item.getLocation())}) + if result is not None: + return round(result.price_sum / result.sold_count, 2) + if (p := item_data.getNbt("price")) is not None: + return p + raise TypeError + + + + +@matcher.assign("$main") +async def _(user_id: str = get_user_id()) -> None: + async with get_session() as session: + count = len((await session.scalars(select(MarketItem).where(MarketItem.remain_count > 0))).all()) + await lang.finish("main.info", user_id, count) + +@matcher.assign("sell") +async def _(bag_index: int, count: int, price_diff: str, user_id: str = get_user_id()) -> None: + try: + item = await get_bag_item(user_id, bag_index) + except IndexError: + await lang.finish("sell.index_error", user_id) + if count > 0 and item.stack.count < count: + await lang.finish("sell.item_not_enough", user_id, item.stack.count) + elif count < 0: + await lang.finish("sell.wrong_count", user_id) + elif count == 0: + count = item.stack.count + async with get_session() as session: + try: + avg_price = await get_average_price(item.stack, session) + except TypeError: + await lang.finish("sell.not_soldable", user_id) + if price_diff.startswith("+"): + price = round(avg_price * (1 + 0.01 * min(5, len(price_diff))), 2) + elif price_diff.startswith("-"): + price = round(avg_price * (1 - 0.01 * min(5, len(price_diff))), 2) + else: + price = avg_price + session.add(MarketItem( + user_id=user_id, + remain_count=count, + item_data=json.dumps(item.stack.data).encode("utf-8"), + price=price, + item_namespace=str(item.stack.item.getLocation()) + )) + await session.commit() + item.stack.count -= count + await lang.finish("sell.done", user_id, item.stack.getName(), count, price) + + + +async def get_market_item(user_id: str, data: MarketItem) -> ItemStack: + location = get_location_by_id(data.item_namespace) + return await get_item(location, user_id, data.remain_count, json.loads(data.item_data)) + +async def get_market_items_by_name(user_id: str, session: AsyncSession, name: str) -> list[MarketItem]: + items = [] + for item_data in await session.scalars(select(MarketItem).where(MarketItem.remain_count > 0)): + item = await get_market_item(user_id, item_data) + if name in await item.getName(): + items.append(item_data) + return items + +async def give_market_item(count: int, item_data: MarketItem, user_id: str) -> None: + item = await get_market_item(user_id, item_data) + item.count = count + await give_item(user_id, item) + +@matcher.assign("buy") +async def _(name: str, count: int, user_id: str = get_user_id()) -> None: + bought_count = 0 + used_vimcoin = 0 + user = await get_user(user_id) + async with get_session() as session: + items = await get_market_items_by_name(user_id, session, name) + for item in items: + if item.remain_count >= (c := count - bought_count) and await user.has_vimcoin(p := item.price * c): + bought_count = count + await user.use_vimcoin(p, True) + await (await get_user(item.user_id)).add_vimcoin(p * 0.99) + await give_market_item(c, item, user_id) + item.remain_count -= c + used_vimcoin += p + break + elif user.has_vimcoin(p := item.price * item.remain_count): + bought_count += item.remain_count + await user.use_vimcoin(p, True) + await (await get_user(item.user_id)).add_vimcoin(p * 0.99) + await give_market_item(item.remain_count, item, user_id) + await session.delete(item) + used_vimcoin += p + await session.commit() + await lang.finish("buy.finish", user_id, p, bought_count, name) + + + diff --git a/src/plugins/nonebot_plugin_market/help.yaml b/src/plugins/nonebot_plugin_market/help.yaml new file mode 100644 index 000000000..8dea3dead --- /dev/null +++ b/src/plugins/nonebot_plugin_market/help.yaml @@ -0,0 +1,3 @@ +plugin: market +commands: + market: help;3;game \ No newline at end of file diff --git a/src/plugins/nonebot_plugin_market/models.py b/src/plugins/nonebot_plugin_market/models.py new file mode 100644 index 000000000..38d8232c4 --- /dev/null +++ b/src/plugins/nonebot_plugin_market/models.py @@ -0,0 +1,19 @@ +from datetime import datetime +from typing import Optional +from nonebot_plugin_orm import Model +from sqlalchemy import String +from sqlalchemy.orm import Mapped, mapped_column + + +class MarketItem(Model): + item_id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) + item_namespace: Mapped[str] = mapped_column(String(64)) + remain_count: Mapped[int] + price: Mapped[float] + user_id: Mapped[str] = mapped_column(String(128)) + item_data: Mapped[bytes] + +class SellLog(Model): + item_namespace: Mapped[str] = mapped_column(String(64), primary_key=True) + sold_count: Mapped[int] + price_sum: Mapped[float] diff --git a/src/pyproject.toml b/src/pyproject.toml index f5731062d..745c2a851 100644 --- a/src/pyproject.toml +++ b/src/pyproject.toml @@ -97,7 +97,8 @@ packages = [ { include = "nonebot_plugin_cave_image_prompt", from = "./plugins" }, { include = "nonebot_plugin_hkrpg_calendar", from = "./plugins" }, { include = "nonebot_plugin_ba_calendar", from = "./plugins" }, - { include = "nonebot_plugin_everyday_wife", from = "./plugins" } + { include = "nonebot_plugin_everyday_wife", from = "./plugins" }, + { include = "nonebot_plugin_market", from = "./plugins" } ] From 509140c296f8841675870790499d1031eaacb154 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:46:42 +0000 Subject: [PATCH 02/12] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/versions/9f6eedd5686c_.py | 41 ++++++++++--------- src/plugins/nonebot_plugin_market/__main__.py | 38 +++++++++-------- src/plugins/nonebot_plugin_market/models.py | 1 + 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/migrations/versions/9f6eedd5686c_.py b/migrations/versions/9f6eedd5686c_.py index fb905b23f..4351c3bfb 100644 --- a/migrations/versions/9f6eedd5686c_.py +++ b/migrations/versions/9f6eedd5686c_.py @@ -5,6 +5,7 @@ 创建时间: 2025-08-14 13:39:38.284103 """ + from __future__ import annotations from collections.abc import Sequence @@ -13,8 +14,8 @@ import sqlalchemy as sa -revision: str = '9f6eedd5686c' -down_revision: str | Sequence[str] | None = 'f79433854a65' +revision: str = "9f6eedd5686c" +down_revision: str | Sequence[str] | None = "f79433854a65" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None @@ -23,22 +24,24 @@ def upgrade(name: str = "") -> None: if name: return # ### commands auto generated by Alembic - please adjust! ### - op.create_table('nonebot_plugin_market_marketitem', - sa.Column('item_id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('item_namespace', sa.String(length=64), nullable=False), - sa.Column('remain_count', sa.Integer(), nullable=False), - sa.Column('price', sa.Float(), nullable=False), - sa.Column('user_id', sa.String(length=128), nullable=False), - sa.Column('item_data', sa.LargeBinary(), nullable=False), - sa.PrimaryKeyConstraint('item_id', name=op.f('pk_nonebot_plugin_market_marketitem')), - info={'bind_key': 'nonebot_plugin_market'} + op.create_table( + "nonebot_plugin_market_marketitem", + sa.Column("item_id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column("item_namespace", sa.String(length=64), nullable=False), + sa.Column("remain_count", sa.Integer(), nullable=False), + sa.Column("price", sa.Float(), nullable=False), + sa.Column("user_id", sa.String(length=128), nullable=False), + sa.Column("item_data", sa.LargeBinary(), nullable=False), + sa.PrimaryKeyConstraint("item_id", name=op.f("pk_nonebot_plugin_market_marketitem")), + info={"bind_key": "nonebot_plugin_market"}, ) - op.create_table('nonebot_plugin_market_selllog', - sa.Column('item_namespace', sa.String(length=64), nullable=False), - sa.Column('sold_count', sa.Integer(), nullable=False), - sa.Column('price_sum', sa.Float(), nullable=False), - sa.PrimaryKeyConstraint('item_namespace', name=op.f('pk_nonebot_plugin_market_selllog')), - info={'bind_key': 'nonebot_plugin_market'} + op.create_table( + "nonebot_plugin_market_selllog", + sa.Column("item_namespace", sa.String(length=64), nullable=False), + sa.Column("sold_count", sa.Integer(), nullable=False), + sa.Column("price_sum", sa.Float(), nullable=False), + sa.PrimaryKeyConstraint("item_namespace", name=op.f("pk_nonebot_plugin_market_selllog")), + info={"bind_key": "nonebot_plugin_market"}, ) # ### end Alembic commands ### @@ -47,6 +50,6 @@ def downgrade(name: str = "") -> None: if name: return # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('nonebot_plugin_market_selllog') - op.drop_table('nonebot_plugin_market_marketitem') + op.drop_table("nonebot_plugin_market_selllog") + op.drop_table("nonebot_plugin_market_marketitem") # ### end Alembic commands ### diff --git a/src/plugins/nonebot_plugin_market/__main__.py b/src/plugins/nonebot_plugin_market/__main__.py index a5ababe9e..1e049fb23 100644 --- a/src/plugins/nonebot_plugin_market/__main__.py +++ b/src/plugins/nonebot_plugin_market/__main__.py @@ -13,11 +13,13 @@ lang = LangHelper() -matcher = on_alconna(Alconna( - "market", - Subcommand("sell", Args["bag_index", int], Args["count", int, 0], Args["price_diff", str, ""]), - Subcommand("buy", Args["name", str], Args["count", int, 1]) -)) +matcher = on_alconna( + Alconna( + "market", + Subcommand("sell", Args["bag_index", int], Args["count", int, 0], Args["price_diff", str, ""]), + Subcommand("buy", Args["name", str], Args["count", int, 1]), + ) +) async def get_average_price(item_data: ItemStack, session: AsyncSession) -> float: @@ -27,8 +29,6 @@ async def get_average_price(item_data: ItemStack, session: AsyncSession) -> floa if (p := item_data.getNbt("price")) is not None: return p raise TypeError - - @matcher.assign("$main") @@ -37,6 +37,7 @@ async def _(user_id: str = get_user_id()) -> None: count = len((await session.scalars(select(MarketItem).where(MarketItem.remain_count > 0))).all()) await lang.finish("main.info", user_id, count) + @matcher.assign("sell") async def _(bag_index: int, count: int, price_diff: str, user_id: str = get_user_id()) -> None: try: @@ -60,23 +61,25 @@ async def _(bag_index: int, count: int, price_diff: str, user_id: str = get_user price = round(avg_price * (1 - 0.01 * min(5, len(price_diff))), 2) else: price = avg_price - session.add(MarketItem( - user_id=user_id, - remain_count=count, - item_data=json.dumps(item.stack.data).encode("utf-8"), - price=price, - item_namespace=str(item.stack.item.getLocation()) - )) + session.add( + MarketItem( + user_id=user_id, + remain_count=count, + item_data=json.dumps(item.stack.data).encode("utf-8"), + price=price, + item_namespace=str(item.stack.item.getLocation()), + ) + ) await session.commit() item.stack.count -= count await lang.finish("sell.done", user_id, item.stack.getName(), count, price) - async def get_market_item(user_id: str, data: MarketItem) -> ItemStack: location = get_location_by_id(data.item_namespace) return await get_item(location, user_id, data.remain_count, json.loads(data.item_data)) + async def get_market_items_by_name(user_id: str, session: AsyncSession, name: str) -> list[MarketItem]: items = [] for item_data in await session.scalars(select(MarketItem).where(MarketItem.remain_count > 0)): @@ -85,11 +88,13 @@ async def get_market_items_by_name(user_id: str, session: AsyncSession, name: st items.append(item_data) return items + async def give_market_item(count: int, item_data: MarketItem, user_id: str) -> None: item = await get_market_item(user_id, item_data) item.count = count await give_item(user_id, item) + @matcher.assign("buy") async def _(name: str, count: int, user_id: str = get_user_id()) -> None: bought_count = 0 @@ -115,6 +120,3 @@ async def _(name: str, count: int, user_id: str = get_user_id()) -> None: used_vimcoin += p await session.commit() await lang.finish("buy.finish", user_id, p, bought_count, name) - - - diff --git a/src/plugins/nonebot_plugin_market/models.py b/src/plugins/nonebot_plugin_market/models.py index 38d8232c4..e53db8477 100644 --- a/src/plugins/nonebot_plugin_market/models.py +++ b/src/plugins/nonebot_plugin_market/models.py @@ -13,6 +13,7 @@ class MarketItem(Model): user_id: Mapped[str] = mapped_column(String(128)) item_data: Mapped[bytes] + class SellLog(Model): item_namespace: Mapped[str] = mapped_column(String(64), primary_key=True) sold_count: Mapped[int] From de46fd3497f817e0b3422486beb0ff4442081c49 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:48:16 +0000 Subject: [PATCH 03/12] Auto update from GitHub Actions --- COMMANDS.md | 262 +++++----------------------------------------------- poetry.lock | 96 ++++++------------- 2 files changed, 51 insertions(+), 307 deletions(-) diff --git a/COMMANDS.md b/COMMANDS.md index e13c2ea02..dc14cf71e 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -1,182 +1,6 @@ # Moonlark 指令列表 > 由 Moonlark & nonebot-plugin-larkhelp 生成 -## `2048`: 2048 小游戏 - -数字合成游戏 —— 2048 - -### 用法 -- `/2048` -## `bingo`: 宾果游戏生成 - -输入大小与内容,一键生成宾果游戏图片 - -### 用法 -- `/bingo [列数] [行数] (开始创建宾果游戏)` -## `boothill`: 波提欧 - -对句子进行一些???的处理,仅支持简体中文。 - -「他宝了个腿的。」 ——巡海游侠,波提欧 - - -### 用法 -- `/boothill <句子>` -## `character`: 成员列表 - -(该功能仍在测试中)查看当前拥有的角色。 - -### 用法 -- `/character (查看角色列表)` -- `/character (查看角色详情)` -## `chatterbox`: 群话痨排行 - -统计群聊中的话痨,该功能不支持 QQ 节点且需要在群聊中手动启用。 - -### 用法 -- `/ct (群话痨排行)` -- `/ct -e|-d (功能开关)` -- `/ct me|<@用户> (查询指定用户的话痨排行)` -## `defuse-tnt`: 拆除 TNT - -运气游戏——通过猜测排列出正确的拆除炸弹的密码。 - -### 用法 -- `/defuse-tnt` -## `ftt`: 寻径指津 - -寻径指津玩法 - -### 用法 -- `/ftt (从随机地图开始)` -- `/ftt (从指定种子生成地图)` -## `jrrp`: 今日人品 - -查询今天的人品值,今天也是幸运的一天~ - -### 用法 -- `/jrrp (获取今天的人品值)` -- `/jrrp r (今日幸运星[--rank])` -- `/jrrp rr (今日倒霉蛋[--rank-r])` -## `minigame`: 小游戏积分排名 - -查看 Moonlark 中游玩玩法的用户的排名 - -### 用法 -- `/minigame-rank` -## `quick-math`: 快速数学 - -以计算为核心的玩法。找到问题的答案,并在排行榜中获取更高的积分。(指令别名:qm) - -### 用法 -- `/quick-math [--level <开始的等级>] (开始挑战)` -- `/quick-math rank [--total] (积分排行榜)` -- `/quick-math points (查看总分详情)` -- `/quick-math zen <等级> (禅模式)` -## `sandbox`: 战斗沙箱 - -(该功能仍在测试中)启动战斗沙箱,进行模拟战斗。 - -### 用法 -- `/sandbox [标靶等级] [标靶数量]` -## `setu`: 随机图片 - -随机 Pixiv 插画 - -### 用法 -- `/setu (随机图片)` -- `/setu rank (查看使用排行)` -## `sudoku`: 数独解谜游戏 - -数独解谜游戏,提供不同难度级别的数独谜题。游戏可以错误检查功能,帮助用户学习数独技巧。 - -### 用法 -- `/sudoku new (生成指定空格数的数独)` -- `/sudoku change (修改数独指定行列数字)` -- `/sudoku erase (去除数独指定行列数字)` -- `/sudoku hint (提供第一个空格的提示)` -- `/sudoku reset (重置数独为初始状态)` -- `/sudoku answer (展示答案)` -- `/sudoku undo (撤销操作)` -- `/sudoku redo (撤销操作)` -## `team`: 设置战斗队伍 - -(该功能仍在测试中)设置战斗有关模块使用的队伍,配合 character 指令使用。 - -### 用法 -- `/team (查看当前队伍)` -- `/team set <位置> (成员入队)` -## `tol`: 关灯挑战 - -尝试关掉所有的灯_一盏灯被开启或关闭时它上、下、左、右边的灯的状态也会发生改变。 - -### 用法 -- `/tol` -## `wordle`: WORDLE - -猜单词的游戏,支持多人游玩。 - -游玩提示:为了避免干扰使用,不成功的匹配不会被提示,也不能在一个会话中同时开启多个 WORDLE 游戏。 - - -### 用法 -- `/wordle [长度=5]` -## `access`: 权限管理 - -Moonlark 权限控制 (仅 SUPERUSER 可用) - -### 用法 -- `/access {ban|pardon} <主体ID> (封禁/解封用户)` -- `/access {block|unblock} <权限> <主体ID> (添加/移除权限)` -## `bag`: 背包 - -查看,处理,使用背包中的物品 - -### 用法 -- `/bag (查看背包)` -- `/bag overflow list (查看 overflow 区物品列表)` -- `/bag overflow show (查看 overflow 区物品)` -- `/bag overflow get [count] (获取 overflow 区物品)` -- `/bag show (查看物品)` -- `/bag drop [count] (丢弃物品)` -- `/bag tidy (整理背包)` -- `/bag move (移动物品)` -- `/bag use [-c|--count ] [argv...] (使用物品)` -## `lang`: 本地化 - -Moonlark 本地化设置 - -### 用法 -- `/lang (查看语言列表)` -- `/lang view <语言> (查看语言信息)` -- `/lang set <语言> (设置语言)` -- `/lang reload (重载语言[SU])` -## `panel`: 用户面板 - -查看用户数据面板 - -### 用法 -- `/panel (查看面板)` -- `/panel i (查看邀请指令)` -## `status`: 系统状态 - -[lgc-NB2Dev/nonebot-plugin-picstatus] 获取 Moonlark 运行状态 - -### 用法 -- `/status` -## `theme`: 主题 - -设定部分指令的图片渲染主题 - -### 用法 -- `/theme (查看主题列表)` -- `/theme (更换主题)` -## `whoami`: 我是谁 - -查看用户帐号基本信息 - -### 用法 -- `/whoami (查看帐号信息)` ## `bac`: 蔚蓝档案活动日历 查询蔚蓝档案现在和将来的卡池、活动信息,支持国服(默认)、国际服(参数:in)、日服(参数:jp)。 @@ -196,13 +20,6 @@ Moonlark 本地化设置 ### 用法 - `/github <链接/仓库>` -## `help`: 命令帮助 - -获取命令用法 - -### 用法 -- `/help (获取命令列表)` -- `/help <命令名> (查看命令帮助)` ## `holiday`: 剩余假期 查看剩余的假期 @@ -263,15 +80,6 @@ Linux 手册 (ManPage) 查询 ### 用法 - `/raw <文本...>` -## `summary`: 历史消息总结 - -使用 AI 总结群聊中的历史消息。读取长度默认为 200 条消息,最大为 270,该功能不支持 QQ 节点且需要在群聊中手动启用。 - -### 用法 -- `/summary [读取长度] (总结历史消息)` -- `/summary -s broadcast (广播风格总结)` -- `/summary -s topic (话题梳理)` -- `/summary -e|-d (功能开关)` ## `t`: 翻译器 翻译文本(默认英到中) @@ -284,69 +92,41 @@ Linux 手册 (ManPage) 查询 ### 用法 - `/time-progress` -## `vote`: 投票 - -Moonlark 投票 - -### 用法 -- `/vote [-a|--all] (获取投票列表)` -- `/vote create [-g|--global] [-l|--last <持续(小时)>] [标题] (创建投票)` -- `/vote <投票ID> <选项编号> (参与投票)` -- `/vote <投票ID> (查看投票详情)` -- `/vote close <投票ID> (结束投票)` -## `wakatime`: WakaTime +## `boothill`: 波提欧 -在 Moonlark 上查看 WakaTime 时长并参与排行 +对句子进行一些???的处理,仅支持简体中文。 -### 用法 -- `/wakatime (查看我的 WakaTime 信息)` -- `/wakatime login (绑定 WakaTime 账户)` -- `/wakatime rank (查看 WakaTime 排行榜)` -## `cave`: 回声洞 +「他宝了个腿的。」 ——巡海游侠,波提欧 -(与漂流瓶类似)投稿或查看其他用户投稿的回声洞,所有内容依照 CC-BY-NC-SA 4.0 许可协议授权 ### 用法 -- `/cave (随机条目)` -- `/cave-a <内容...> (投稿条目)` -- `/cave-r [-c] (删除条目或评论)` -- `/cave-s (恢复 7 天内删除的条目)` -- `/cave-g (查看自己投稿的条目)` -- `/cave-c [-u|--user|--set <时间(分钟)>] (查看或修改冷却状态)` -- `/cave-s (统计投稿者)` -## `chat`: 主动水群 +- `/boothill <句子>` +## `setu`: 随机图片 -基于 LLM 的主动水群功能,可以尝试用于活跃群气氛。(启用后将会收集、处理、并储存启用群聊的聊天记录和群员的昵称,仅支持非 QQ 官方节点) +随机 Pixiv 插画 ### 用法 -- `/chat switch (修改功能启用状态)` -- `/chat on (启用功能)` -- `/chat off (禁用功能)` -- `/chat mute (临时禁用水群功能)` -- `/chat unmute (取消临时禁用)` -- `/chat reset-memory (重置储存的记忆)` -## `email`: 邮件 +- `/setu (随机图片)` +- `/setu rank (查看使用排行)` +## `lang`: 本地化 -进入 Moonlark 邮箱 +Moonlark 本地化设置 ### 用法 -- `/email (查看未读邮件)` -- `/email claim all (领取全部物品)` -- `/email claim (领取指定邮件)` -- `/email unread all (将所有邮件标为未读)` -- `/email unread (将邮件标为未读)` -## `schedule`: 每日任务 +- `/lang (查看语言列表)` +- `/lang view <语言> (查看语言信息)` +- `/lang set <语言> (设置语言)` +- `/lang reload (重载语言[SU])` +## `status`: 系统状态 -查看每日任务或领取每日任务奖励,每日刷新,部分功能仅在签到后可用。 +[lgc-NB2Dev/nonebot-plugin-picstatus] 获取 Moonlark 运行状态 ### 用法 -- `/schdeule (查看每日任务列表)` -- `/schdeule collect (领取可领取的奖励)` -## `waifu`: 今日群老婆 +- `/status` +## `theme`: 主题 -匹配你的每日群老婆!(仅支持群聊使用) +设定部分指令的图片渲染主题 ### 用法 -- `/waifu (今日群老婆)` -- `/waifu divorce (离婚)` -- `/waifu force-marry <@群员> (强娶)` +- `/theme (查看主题列表)` +- `/theme (更换主题)` diff --git a/poetry.lock b/poetry.lock index b5e1fb05e..71807fc57 100644 --- a/poetry.lock +++ b/poetry.lock @@ -303,18 +303,6 @@ files = [ [package.dependencies] chardet = ">=3.0.2" -[[package]] -name = "cachetools" -version = "5.5.2" -description = "Extensible memoizing collections and decorators" -optional = false -python-versions = ">=3.7" -groups = ["main"] -files = [ - {file = "cachetools-5.5.2-py3-none-any.whl", hash = "sha256:d26a22bcc62eb95c3beabd9f1ee5e820d3d2704fe2967cbe350e20c8ffcd3f0a"}, - {file = "cachetools-5.5.2.tar.gz", hash = "sha256:1a661caa9175d26759571b2e19580f9d6393969e5dfca11fdb1f947a23e640d4"}, -] - [[package]] name = "cashews" version = "7.4.1" @@ -926,21 +914,6 @@ idna = ["idna (>=3.7)"] trio = ["trio (>=0.23)"] wmi = ["wmi (>=1.5.1)"] -[[package]] -name = "emoji" -version = "2.14.1" -description = "Emoji for Python" -optional = false -python-versions = ">=3.7" -groups = ["main"] -files = [ - {file = "emoji-2.14.1-py3-none-any.whl", hash = "sha256:35a8a486c1460addb1499e3bf7929d3889b2e2841a57401903699fef595e942b"}, - {file = "emoji-2.14.1.tar.gz", hash = "sha256:f8c50043d79a2c1410ebfae833ae1868d5941a67a6cd4d18377e2eb0bd79346b"}, -] - -[package.extras] -dev = ["coverage", "pytest (>=7.4.4)"] - [[package]] name = "exceptiongroup" version = "1.3.0" @@ -2044,14 +2017,14 @@ traitlets = "*" [[package]] name = "mcstatus" -version = "12.0.3" +version = "12.0.5" description = "A library to query Minecraft Servers for their status and capabilities." optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "mcstatus-12.0.3-py3-none-any.whl", hash = "sha256:823f2ec2120cedb8adb1625868fccb4353fb92de02fcc592c044deed02921968"}, - {file = "mcstatus-12.0.3.tar.gz", hash = "sha256:67a204033aa09065490766e6ff98342617f57e4b4d4bf59483187aa2b3c6578a"}, + {file = "mcstatus-12.0.5-py3-none-any.whl", hash = "sha256:24b99acdb06687eac3851b797c8af4a23f0b1bed81ecd33897b12922e456d116"}, + {file = "mcstatus-12.0.5.tar.gz", hash = "sha256:db7721ef6be1de67509251fff27db86abba48f9794145587adb3f66de57faef5"}, ] [package.dependencies] @@ -2644,29 +2617,29 @@ resolved_reference = "b9f843fe913e5a1c8f858a43402993f286604969" [[package]] name = "nonebot-plugin-picstatus" -version = "2.1.3.post1" +version = "2.1.4" description = "A NoneBot2 plugin generates a picture which shows the status of current device" optional = false -python-versions = "<4.0,>=3.9" +python-versions = "<4.0,>=3.10" groups = ["main"] files = [ - {file = "nonebot_plugin_picstatus-2.1.3.post1-py3-none-any.whl", hash = "sha256:1385fa91b4ebbd7d733836fbe5b6eaeba43f8055ebf03997272d6ca2dbf3afdc"}, - {file = "nonebot_plugin_picstatus-2.1.3.post1.tar.gz", hash = "sha256:4fc4421550c30446cf0bf130569c571789bfef916a3652a4cd7fc6074d119528"}, + {file = "nonebot_plugin_picstatus-2.1.4-py3-none-any.whl", hash = "sha256:14c1b76b8ae283f86af47923d61e33c3492d5640250e084808e3d09bc6ba14f5"}, + {file = "nonebot_plugin_picstatus-2.1.4.tar.gz", hash = "sha256:1ca69f2fc6d129836517eb4eba9a233ccdaeb948eebb0a70a385f58bf15bc99a"}, ] [package.dependencies] -anyio = ">=4.6.2.post1" -cookit = {version = ">=0.8.2", extras = ["jinja", "loguru", "playwright", "pydantic"]} -httpx = ">=0.27.2" -jinja2 = ">=3.1.4" -nonebot-plugin-alconna = ">=0.54.0" +anyio = ">=4.10.0" +cookit = {version = ">=0.13.0", extras = ["jinja", "loguru", "playwright", "pydantic"]} +httpx = ">=0.28.1" +jinja2 = ">=3.1.6" +nonebot-plugin-alconna = ">=0.59.4" nonebot-plugin-apscheduler = ">=0.5.0" -nonebot-plugin-htmlrender = ">=0.4.0" -nonebot-plugin-userinfo = ">=0.2.6" -nonebot2 = ">=2.4.0" -psutil = ">=6.1.0" +nonebot-plugin-htmlrender = ">=0.6.6" +nonebot-plugin-uninfo = ">=0.9.0" +nonebot2 = ">=2.4.3" +psutil = ">=7.0.0" py-cpuinfo = ">=9.0.0" -yarl = ">=1.18.3" +yarl = ">=1.20.1" [[package]] name = "nonebot-plugin-sentry" @@ -2717,25 +2690,6 @@ files = [ importlib-metadata = ">=7.2.1" nonebot2 = ">=2.4.2" -[[package]] -name = "nonebot-plugin-userinfo" -version = "0.2.6" -description = "Nonebot2 用户信息获取插件" -optional = false -python-versions = "<4.0,>=3.9" -groups = ["main"] -files = [ - {file = "nonebot_plugin_userinfo-0.2.6-py3-none-any.whl", hash = "sha256:79d2481af08a5ec77cf171c685eecd14eaf1ce4d5a1ec1fd22fbb0b85e06c260"}, - {file = "nonebot_plugin_userinfo-0.2.6.tar.gz", hash = "sha256:0d1ce897e94a9d4c0b5300bc8f239a4676f9bb62c78a14e0f0527e5398ffc840"}, -] - -[package.dependencies] -cachetools = ">=5.0.0,<6.0.0" -emoji = ">=2.0.0,<3.0.0" -httpx = ">=0.20.0,<1.0.0" -nonebot2 = ">=2.3.0,<3.0.0" -strenum = ">=0.4.15,<0.5.0" - [[package]] name = "nonebot-plugin-waiter" version = "0.8.1" @@ -4560,7 +4514,9 @@ groups = ["main"] files = [ {file = "SQLAlchemy-2.0.43-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:21ba7a08a4253c5825d1db389d4299f64a100ef9800e4624c8bf70d8f136e6ed"}, {file = "SQLAlchemy-2.0.43-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:11b9503fa6f8721bef9b8567730f664c5a5153d25e247aadc69247c4bc605227"}, + {file = "SQLAlchemy-2.0.43-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07097c0a1886c150ef2adba2ff7437e84d40c0f7dcb44a2c2b9c905ccfc6361c"}, {file = "SQLAlchemy-2.0.43-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:cdeff998cb294896a34e5b2f00e383e7c5c4ef3b4bfa375d9104723f15186443"}, + {file = "SQLAlchemy-2.0.43-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:bcf0724a62a5670e5718957e05c56ec2d6850267ea859f8ad2481838f889b42c"}, {file = "SQLAlchemy-2.0.43-cp37-cp37m-win32.whl", hash = "sha256:c697575d0e2b0a5f0433f679bda22f63873821d991e95a90e9e52aae517b2e32"}, {file = "SQLAlchemy-2.0.43-cp37-cp37m-win_amd64.whl", hash = "sha256:d34c0f6dbefd2e816e8f341d0df7d4763d382e3f452423e752ffd1e213da2512"}, {file = "sqlalchemy-2.0.43-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:70322986c0c699dca241418fcf18e637a4369e0ec50540a2b907b184c8bca069"}, @@ -4595,12 +4551,20 @@ files = [ {file = "sqlalchemy-2.0.43-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9df7126fd9db49e3a5a3999442cc67e9ee8971f3cb9644250107d7296cb2a164"}, {file = "sqlalchemy-2.0.43-cp313-cp313-win32.whl", hash = "sha256:7f1ac7828857fcedb0361b48b9ac4821469f7694089d15550bbcf9ab22564a1d"}, {file = "sqlalchemy-2.0.43-cp313-cp313-win_amd64.whl", hash = "sha256:971ba928fcde01869361f504fcff3b7143b47d30de188b11c6357c0505824197"}, + {file = "sqlalchemy-2.0.43-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4e6aeb2e0932f32950cf56a8b4813cb15ff792fc0c9b3752eaf067cfe298496a"}, + {file = "sqlalchemy-2.0.43-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:61f964a05356f4bca4112e6334ed7c208174511bd56e6b8fc86dad4d024d4185"}, {file = "sqlalchemy-2.0.43-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:46293c39252f93ea0910aababa8752ad628bcce3a10d3f260648dd472256983f"}, + {file = "sqlalchemy-2.0.43-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:136063a68644eca9339d02e6693932116f6a8591ac013b0014479a1de664e40a"}, {file = "sqlalchemy-2.0.43-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:6e2bf13d9256398d037fef09fd8bf9b0bf77876e22647d10761d35593b9ac547"}, + {file = "sqlalchemy-2.0.43-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:44337823462291f17f994d64282a71c51d738fc9ef561bf265f1d0fd9116a782"}, {file = "sqlalchemy-2.0.43-cp38-cp38-win32.whl", hash = "sha256:13194276e69bb2af56198fef7909d48fd34820de01d9c92711a5fa45497cc7ed"}, {file = "sqlalchemy-2.0.43-cp38-cp38-win_amd64.whl", hash = "sha256:334f41fa28de9f9be4b78445e68530da3c5fa054c907176460c81494f4ae1f5e"}, + {file = "sqlalchemy-2.0.43-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ceb5c832cc30663aeaf5e39657712f4c4241ad1f638d487ef7216258f6d41fe7"}, + {file = "sqlalchemy-2.0.43-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:11f43c39b4b2ec755573952bbcc58d976779d482f6f832d7f33a8d869ae891bf"}, {file = "sqlalchemy-2.0.43-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:413391b2239db55be14fa4223034d7e13325a1812c8396ecd4f2c08696d5ccad"}, + {file = "sqlalchemy-2.0.43-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c379e37b08c6c527181a397212346be39319fb64323741d23e46abd97a400d34"}, {file = "sqlalchemy-2.0.43-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:03d73ab2a37d9e40dec4984d1813d7878e01dbdc742448d44a7341b7a9f408c7"}, + {file = "sqlalchemy-2.0.43-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:8cee08f15d9e238ede42e9bbc1d6e7158d0ca4f176e4eab21f88ac819ae3bd7b"}, {file = "sqlalchemy-2.0.43-cp39-cp39-win32.whl", hash = "sha256:b3edaec7e8b6dc5cd94523c6df4f294014df67097c8217a89929c99975811414"}, {file = "sqlalchemy-2.0.43-cp39-cp39-win_amd64.whl", hash = "sha256:227119ce0a89e762ecd882dc661e0aa677a690c914e358f0dd8932a2e8b2765b"}, {file = "sqlalchemy-2.0.43-py3-none-any.whl", hash = "sha256:1681c21dd2ccee222c2fe0bef671d1aef7c504087c9c4e800371cfcc8ac966fc"}, @@ -5091,14 +5055,14 @@ test = ["aiohttp (>=3.10.5)", "flake8 (>=5.0,<6.0)", "mypy (>=0.800)", "psutil", [[package]] name = "virtualenv" -version = "20.33.1" +version = "20.34.0" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.8" groups = ["dev"] files = [ - {file = "virtualenv-20.33.1-py3-none-any.whl", hash = "sha256:07c19bc66c11acab6a5958b815cbcee30891cd1c2ccf53785a28651a0d8d8a67"}, - {file = "virtualenv-20.33.1.tar.gz", hash = "sha256:1b44478d9e261b3fb8baa5e74a0ca3bc0e05f21aa36167bf9cbf850e542765b8"}, + {file = "virtualenv-20.34.0-py3-none-any.whl", hash = "sha256:341f5afa7eee943e4984a9207c025feedd768baff6753cd660c857ceb3e36026"}, + {file = "virtualenv-20.34.0.tar.gz", hash = "sha256:44815b2c9dee7ed86e387b842a84f20b93f7f417f95886ca1996a72a4138eb1a"}, ] [package.dependencies] From b07028258d9b66aca5a3745040c2873b5001951b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 07:04:42 +0000 Subject: [PATCH 04/12] Auto update from GitHub Actions --- COMMANDS.md | 270 ++++++++++++++++++++++++++++++++++++++++++++++++---- poetry.lock | 46 +++++++++ 2 files changed, 295 insertions(+), 21 deletions(-) diff --git a/COMMANDS.md b/COMMANDS.md index dc14cf71e..fecde0e7e 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -1,6 +1,190 @@ # Moonlark 指令列表 > 由 Moonlark & nonebot-plugin-larkhelp 生成 +## `2048`: 2048 小游戏 + +数字合成游戏 —— 2048 + +### 用法 +- `/2048` +## `bingo`: 宾果游戏生成 + +输入大小与内容,一键生成宾果游戏图片 + +### 用法 +- `/bingo [列数] [行数] (开始创建宾果游戏)` +## `boothill`: 波提欧 + +对句子进行一些???的处理,仅支持简体中文。 + +「他宝了个腿的。」 ——巡海游侠,波提欧 + + +### 用法 +- `/boothill <句子>` +## `character`: 成员列表 + +(该功能仍在测试中)查看当前拥有的角色。 + +### 用法 +- `/character (查看角色列表)` +- `/character (查看角色详情)` +## `chatterbox`: 群话痨排行 + +统计群聊中的话痨,该功能不支持 QQ 节点且需要在群聊中手动启用。 + +### 用法 +- `/ct (群话痨排行)` +- `/ct -e|-d (功能开关)` +- `/ct me|<@用户> (查询指定用户的话痨排行)` +## `defuse-tnt`: 拆除 TNT + +运气游戏——通过猜测排列出正确的拆除炸弹的密码。 + +### 用法 +- `/defuse-tnt` +## `ftt`: 寻径指津 + +寻径指津玩法 + +### 用法 +- `/ftt (从随机地图开始)` +- `/ftt (从指定种子生成地图)` +## `jrrp`: 今日人品 + +查询今天的人品值,今天也是幸运的一天~ + +### 用法 +- `/jrrp (获取今天的人品值)` +- `/jrrp r (今日幸运星[--rank])` +- `/jrrp rr (今日倒霉蛋[--rank-r])` +## `market`: None + +None + +### 用法 +- `/None` +- `/None` +- `/None` +## `minigame`: 小游戏积分排名 + +查看 Moonlark 中游玩玩法的用户的排名 + +### 用法 +- `/minigame-rank` +## `quick-math`: 快速数学 + +以计算为核心的玩法。找到问题的答案,并在排行榜中获取更高的积分。(指令别名:qm) + +### 用法 +- `/quick-math [--level <开始的等级>] (开始挑战)` +- `/quick-math rank [--total] (积分排行榜)` +- `/quick-math points (查看总分详情)` +- `/quick-math zen <等级> (禅模式)` +## `sandbox`: 战斗沙箱 + +(该功能仍在测试中)启动战斗沙箱,进行模拟战斗。 + +### 用法 +- `/sandbox [标靶等级] [标靶数量]` +## `setu`: 随机图片 + +随机 Pixiv 插画 + +### 用法 +- `/setu (随机图片)` +- `/setu rank (查看使用排行)` +## `sudoku`: 数独解谜游戏 + +数独解谜游戏,提供不同难度级别的数独谜题。游戏可以错误检查功能,帮助用户学习数独技巧。 + +### 用法 +- `/sudoku new (生成指定空格数的数独)` +- `/sudoku change (修改数独指定行列数字)` +- `/sudoku erase (去除数独指定行列数字)` +- `/sudoku hint (提供第一个空格的提示)` +- `/sudoku reset (重置数独为初始状态)` +- `/sudoku answer (展示答案)` +- `/sudoku undo (撤销操作)` +- `/sudoku redo (撤销操作)` +## `team`: 设置战斗队伍 + +(该功能仍在测试中)设置战斗有关模块使用的队伍,配合 character 指令使用。 + +### 用法 +- `/team (查看当前队伍)` +- `/team set <位置> (成员入队)` +## `tol`: 关灯挑战 + +尝试关掉所有的灯_一盏灯被开启或关闭时它上、下、左、右边的灯的状态也会发生改变。 + +### 用法 +- `/tol` +## `wordle`: WORDLE + +猜单词的游戏,支持多人游玩。 + +游玩提示:为了避免干扰使用,不成功的匹配不会被提示,也不能在一个会话中同时开启多个 WORDLE 游戏。 + + +### 用法 +- `/wordle [长度=5]` +## `access`: 权限管理 + +Moonlark 权限控制 (仅 SUPERUSER 可用) + +### 用法 +- `/access {ban|pardon} <主体ID> (封禁/解封用户)` +- `/access {block|unblock} <权限> <主体ID> (添加/移除权限)` +## `bag`: 背包 + +查看,处理,使用背包中的物品 + +### 用法 +- `/bag (查看背包)` +- `/bag overflow list (查看 overflow 区物品列表)` +- `/bag overflow show (查看 overflow 区物品)` +- `/bag overflow get [count] (获取 overflow 区物品)` +- `/bag show (查看物品)` +- `/bag drop [count] (丢弃物品)` +- `/bag tidy (整理背包)` +- `/bag move (移动物品)` +- `/bag use [-c|--count ] [argv...] (使用物品)` +## `lang`: 本地化 + +Moonlark 本地化设置 + +### 用法 +- `/lang (查看语言列表)` +- `/lang view <语言> (查看语言信息)` +- `/lang set <语言> (设置语言)` +- `/lang reload (重载语言[SU])` +## `panel`: 用户面板 + +查看用户数据面板 + +### 用法 +- `/panel (查看面板)` +- `/panel i (查看邀请指令)` +## `status`: 系统状态 + +[lgc-NB2Dev/nonebot-plugin-picstatus] 获取 Moonlark 运行状态 + +### 用法 +- `/status` +## `theme`: 主题 + +设定部分指令的图片渲染主题 + +### 用法 +- `/theme (查看主题列表)` +- `/theme (更换主题)` +## `whoami`: 我是谁 + +查看用户帐号基本信息 + +### 用法 +- `/whoami (查看帐号信息)` ## `bac`: 蔚蓝档案活动日历 查询蔚蓝档案现在和将来的卡池、活动信息,支持国服(默认)、国际服(参数:in)、日服(参数:jp)。 @@ -20,6 +204,13 @@ ### 用法 - `/github <链接/仓库>` +## `help`: 命令帮助 + +获取命令用法 + +### 用法 +- `/help (获取命令列表)` +- `/help <命令名> (查看命令帮助)` ## `holiday`: 剩余假期 查看剩余的假期 @@ -80,6 +271,15 @@ Linux 手册 (ManPage) 查询 ### 用法 - `/raw <文本...>` +## `summary`: 历史消息总结 + +使用 AI 总结群聊中的历史消息。读取长度默认为 200 条消息,最大为 270,该功能不支持 QQ 节点且需要在群聊中手动启用。 + +### 用法 +- `/summary [读取长度] (总结历史消息)` +- `/summary -s broadcast (广播风格总结)` +- `/summary -s topic (话题梳理)` +- `/summary -e|-d (功能开关)` ## `t`: 翻译器 翻译文本(默认英到中) @@ -92,41 +292,69 @@ Linux 手册 (ManPage) 查询 ### 用法 - `/time-progress` -## `boothill`: 波提欧 +## `vote`: 投票 -对句子进行一些???的处理,仅支持简体中文。 +Moonlark 投票 -「他宝了个腿的。」 ——巡海游侠,波提欧 +### 用法 +- `/vote [-a|--all] (获取投票列表)` +- `/vote create [-g|--global] [-l|--last <持续(小时)>] [标题] (创建投票)` +- `/vote <投票ID> <选项编号> (参与投票)` +- `/vote <投票ID> (查看投票详情)` +- `/vote close <投票ID> (结束投票)` +## `wakatime`: WakaTime +在 Moonlark 上查看 WakaTime 时长并参与排行 ### 用法 -- `/boothill <句子>` -## `setu`: 随机图片 +- `/wakatime (查看我的 WakaTime 信息)` +- `/wakatime login (绑定 WakaTime 账户)` +- `/wakatime rank (查看 WakaTime 排行榜)` +## `cave`: 回声洞 -随机 Pixiv 插画 +(与漂流瓶类似)投稿或查看其他用户投稿的回声洞,所有内容依照 CC-BY-NC-SA 4.0 许可协议授权 ### 用法 -- `/setu (随机图片)` -- `/setu rank (查看使用排行)` -## `lang`: 本地化 +- `/cave (随机条目)` +- `/cave-a <内容...> (投稿条目)` +- `/cave-r [-c] (删除条目或评论)` +- `/cave-s (恢复 7 天内删除的条目)` +- `/cave-g (查看自己投稿的条目)` +- `/cave-c [-u|--user|--set <时间(分钟)>] (查看或修改冷却状态)` +- `/cave-s (统计投稿者)` +## `chat`: 主动水群 -Moonlark 本地化设置 +基于 LLM 的主动水群功能,可以尝试用于活跃群气氛。(启用后将会收集、处理、并储存启用群聊的聊天记录和群员的昵称,仅支持非 QQ 官方节点) ### 用法 -- `/lang (查看语言列表)` -- `/lang view <语言> (查看语言信息)` -- `/lang set <语言> (设置语言)` -- `/lang reload (重载语言[SU])` -## `status`: 系统状态 +- `/chat switch (修改功能启用状态)` +- `/chat on (启用功能)` +- `/chat off (禁用功能)` +- `/chat mute (临时禁用水群功能)` +- `/chat unmute (取消临时禁用)` +- `/chat reset-memory (重置储存的记忆)` +## `email`: 邮件 -[lgc-NB2Dev/nonebot-plugin-picstatus] 获取 Moonlark 运行状态 +进入 Moonlark 邮箱 ### 用法 -- `/status` -## `theme`: 主题 +- `/email (查看未读邮件)` +- `/email claim all (领取全部物品)` +- `/email claim (领取指定邮件)` +- `/email unread all (将所有邮件标为未读)` +- `/email unread (将邮件标为未读)` +## `schedule`: 每日任务 -设定部分指令的图片渲染主题 +查看每日任务或领取每日任务奖励,每日刷新,部分功能仅在签到后可用。 ### 用法 -- `/theme (查看主题列表)` -- `/theme (更换主题)` +- `/schdeule (查看每日任务列表)` +- `/schdeule collect (领取可领取的奖励)` +## `waifu`: 今日群老婆 + +匹配你的每日群老婆!(仅支持群聊使用) + +### 用法 +- `/waifu (今日群老婆)` +- `/waifu divorce (离婚)` +- `/waifu force-marry <@群员> (强娶)` diff --git a/poetry.lock b/poetry.lock index d257c2456..787286565 100644 --- a/poetry.lock +++ b/poetry.lock @@ -303,6 +303,18 @@ files = [ [package.dependencies] chardet = ">=3.0.2" +[[package]] +name = "cachetools" +version = "5.5.2" +description = "Extensible memoizing collections and decorators" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "cachetools-5.5.2-py3-none-any.whl", hash = "sha256:d26a22bcc62eb95c3beabd9f1ee5e820d3d2704fe2967cbe350e20c8ffcd3f0a"}, + {file = "cachetools-5.5.2.tar.gz", hash = "sha256:1a661caa9175d26759571b2e19580f9d6393969e5dfca11fdb1f947a23e640d4"}, +] + [[package]] name = "cashews" version = "7.4.1" @@ -914,6 +926,21 @@ idna = ["idna (>=3.7)"] trio = ["trio (>=0.23)"] wmi = ["wmi (>=1.5.1)"] +[[package]] +name = "emoji" +version = "2.14.1" +description = "Emoji for Python" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "emoji-2.14.1-py3-none-any.whl", hash = "sha256:35a8a486c1460addb1499e3bf7929d3889b2e2841a57401903699fef595e942b"}, + {file = "emoji-2.14.1.tar.gz", hash = "sha256:f8c50043d79a2c1410ebfae833ae1868d5941a67a6cd4d18377e2eb0bd79346b"}, +] + +[package.extras] +dev = ["coverage", "pytest (>=7.4.4)"] + [[package]] name = "exceptiongroup" version = "1.3.0" @@ -2714,6 +2741,25 @@ files = [ importlib-metadata = ">=7.2.1" nonebot2 = ">=2.4.2" +[[package]] +name = "nonebot-plugin-userinfo" +version = "0.2.6" +description = "Nonebot2 用户信息获取插件" +optional = false +python-versions = "<4.0,>=3.9" +groups = ["main"] +files = [ + {file = "nonebot_plugin_userinfo-0.2.6-py3-none-any.whl", hash = "sha256:79d2481af08a5ec77cf171c685eecd14eaf1ce4d5a1ec1fd22fbb0b85e06c260"}, + {file = "nonebot_plugin_userinfo-0.2.6.tar.gz", hash = "sha256:0d1ce897e94a9d4c0b5300bc8f239a4676f9bb62c78a14e0f0527e5398ffc840"}, +] + +[package.dependencies] +cachetools = ">=5.0.0,<6.0.0" +emoji = ">=2.0.0,<3.0.0" +httpx = ">=0.20.0,<1.0.0" +nonebot2 = ">=2.3.0,<3.0.0" +strenum = ">=0.4.15,<0.5.0" + [[package]] name = "nonebot-plugin-waiter" version = "0.8.1" From 00fd8a176afda894b32ba6e67e1c385b5ee33d35 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 23 Aug 2025 16:25:53 +0000 Subject: [PATCH 05/12] Auto update from GitHub Actions --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 787286565..3637012d9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3006,14 +3006,14 @@ files = [ [[package]] name = "parso" -version = "0.8.4" +version = "0.8.5" description = "A Python Parser" optional = false python-versions = ">=3.6" groups = ["dev"] files = [ - {file = "parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18"}, - {file = "parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d"}, + {file = "parso-0.8.5-py2.py3-none-any.whl", hash = "sha256:646204b5ee239c396d040b90f9e272e9a8017c630092bf59980beb62fd033887"}, + {file = "parso-0.8.5.tar.gz", hash = "sha256:034d7354a9a018bdce352f48b2a8a450f05e9d6ee85db84764e9b6bd96dafe5a"}, ] [package.extras] From 4209a1ea744d85bac524c73972a3018d12717514 Mon Sep 17 00:00:00 2001 From: Canadew <110163919+chun-awa@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:45:28 +0800 Subject: [PATCH 06/12] fix: typo --- .vscode/settings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d8eff80a7..8de10c590 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,6 +9,6 @@ }, "python-envs.defaultEnvManager": "ms-python.python:poetry", "python-envs.defaultPackageManager": "ms-python.python:poetry", - "python-envs.pythonProjects": [] + "python-envs.pythonProjects": [], "Codegeex.RepoIndex": true -} \ No newline at end of file +} From f0e8dca21b892c8b42b1317db83c846aeb984f56 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 13:47:36 +0000 Subject: [PATCH 07/12] Auto update from GitHub Actions --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index e872324e4..35621b2a3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -5081,14 +5081,14 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "uvicorn" -version = "0.36.0" +version = "0.37.0" description = "The lightning-fast ASGI server." optional = false python-versions = ">=3.9" groups = ["main"] files = [ - {file = "uvicorn-0.36.0-py3-none-any.whl", hash = "sha256:6bb4ba67f16024883af8adf13aba3a9919e415358604ce46780d3f9bdc36d731"}, - {file = "uvicorn-0.36.0.tar.gz", hash = "sha256:527dc68d77819919d90a6b267be55f0e76704dca829d34aea9480be831a9b9d9"}, + {file = "uvicorn-0.37.0-py3-none-any.whl", hash = "sha256:913b2b88672343739927ce381ff9e2ad62541f9f8289664fa1d1d3803fa2ce6c"}, + {file = "uvicorn-0.37.0.tar.gz", hash = "sha256:4115c8add6d3fd536c8ee77f0e14a7fd2ebba939fed9b02583a97f80648f9e13"}, ] [package.dependencies] From d4d413842769d2f9cf4303ee0589be2cf62e85cc Mon Sep 17 00:00:00 2001 From: xxtg666 Date: Thu, 2 Oct 2025 10:49:44 +0000 Subject: [PATCH 08/12] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lang/zh_hans/market.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lang/zh_hans/market.yaml b/src/lang/zh_hans/market.yaml index 9e59963f6..b2ee60ae1 100644 --- a/src/lang/zh_hans/market.yaml +++ b/src/lang/zh_hans/market.yaml @@ -1,16 +1,16 @@ help: - description: - details: - usage1: - usage2: - usage3: + description: 全球市场 + details: 玩家间物品交易市场:可以将自己背包中的物品上架出售,也可以购买其他玩家出售的物品 + usage1: market + usage2: market sell [count] [price_diff] + usage3: market buy [count] main: - info: + info: 当前市场上有 {} 件商品正在出售 sell: - index_error: - item_not_enough: - wrong_count: - not_soldable: - done: + index_error: 背包中不存在此物品 + item_not_enough: 出售失败,选中的物品只有 {} 个,数量不足 + wrong_count: 出售数量不能为负数! + not_soldable: 该物品不支持在市场上出售 + done: 完成!已将 {} 个「{}」以单价 {} VimCoin 的价格上架至全球市场 buy: - finish: \ No newline at end of file + finish: 完成!购买了 {} 个「{}」,总共花费了 {} VimCoin \ No newline at end of file From 144586a2659b9b2ecf45d1f56ea1eea7a333549a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 10:53:33 +0000 Subject: [PATCH 09/12] Auto update from GitHub Actions --- COMMANDS.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/COMMANDS.md b/COMMANDS.md index 82ded6209..3bdbd2b4f 100644 --- a/COMMANDS.md +++ b/COMMANDS.md @@ -58,14 +58,14 @@ - `/jrrp (获取今天的人品值)` - `/jrrp r (今日幸运星[--rank])` - `/jrrp rr (今日倒霉蛋[--rank-r])` -## `market`: None +## `market`: 全球市场 -None +玩家间物品交易市场:可以将自己背包中的物品上架出售,也可以购买其他玩家出售的物品 ### 用法 -- `/None` -- `/None` -- `/None` +- `/market` +- `/market sell [count] [price_diff]` +- `/market buy [count]` ## `minigame`: 小游戏积分排名 查看 Moonlark 中游玩玩法的用户的排名 From 57f141fd138510ac40274bf46a895dcab0791773 Mon Sep 17 00:00:00 2001 From: This-is-XiaoDeng <1744793737@qq.com> Date: Sun, 10 May 2026 19:29:28 +0800 Subject: [PATCH 10/12] feat(market): add list command and improve help text - Add 'market list [page]' to browse items on sale (10 per page) - Add detailed price_diff usage explanation in help - Update help.yaml with structured usages and category - Update __init__.py with proper description and usage --- src/lang/zh_hans/market.yaml | 24 ++++++++++++---- src/plugins/nonebot_plugin_market/__init__.py | 4 +-- src/plugins/nonebot_plugin_market/__main__.py | 28 +++++++++++++++++++ src/plugins/nonebot_plugin_market/help.yaml | 11 +++++++- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/src/lang/zh_hans/market.yaml b/src/lang/zh_hans/market.yaml index b2ee60ae1..0819d0956 100644 --- a/src/lang/zh_hans/market.yaml +++ b/src/lang/zh_hans/market.yaml @@ -1,9 +1,19 @@ help: description: 全球市场 - details: 玩家间物品交易市场:可以将自己背包中的物品上架出售,也可以购买其他玩家出售的物品 - usage1: market - usage2: market sell [count] [price_diff] - usage3: market buy [count] + details: | + 玩家间物品交易市场:可以将自己背包中的物品上架出售,也可以购买其他玩家出售的物品。 + 所有交易收取 1% 手续费。 + usage1: market — 查看市场商品总数 + usage2: market list [page] — 浏览市场中出售的物品(每页 10 件) + usage3: market sell [count] [price_diff] — 上架物品 + usage4: market buy [count] — 购买物品 + usage5: | + price_diff 说明(基于该物品的平均成交价浮动): + 留空 = 按均价上架 + + = 高于均价 1%(每多一个 + 再加 1%,最多 +5%) + - = 低于均价 1%(每多一个 - 再减 1%,最多 -5%) + +++ = 高于均价 3% + -- = 低于均价 2% main: info: 当前市场上有 {} 件商品正在出售 sell: @@ -13,4 +23,8 @@ sell: not_soldable: 该物品不支持在市场上出售 done: 完成!已将 {} 个「{}」以单价 {} VimCoin 的价格上架至全球市场 buy: - finish: 完成!购买了 {} 个「{}」,总共花费了 {} VimCoin \ No newline at end of file + finish: 完成!购买了 {} 个「{}」,总共花费了 {} VimCoin +list: + empty: 市场上暂时没有商品在出售 + header: "📦 全球市场(第 {}/{} 页,共 {} 件)\n{}\n提示:使用 market list <页码> 翻页" + item_line: "{}. {} ×{} — {} VimCoin" diff --git a/src/plugins/nonebot_plugin_market/__init__.py b/src/plugins/nonebot_plugin_market/__init__.py index 68d8e81ff..eb3ae3538 100644 --- a/src/plugins/nonebot_plugin_market/__init__.py +++ b/src/plugins/nonebot_plugin_market/__init__.py @@ -4,8 +4,8 @@ __plugin_meta__ = PluginMetadata( name="nonebot-plugin-market", - description="", - usage="", + description="玩家间物品交易市场", + usage="market [list [page]] | market sell [count] [price_diff] | market buy [count]", config=None, ) diff --git a/src/plugins/nonebot_plugin_market/__main__.py b/src/plugins/nonebot_plugin_market/__main__.py index 1e049fb23..15cb531e8 100644 --- a/src/plugins/nonebot_plugin_market/__main__.py +++ b/src/plugins/nonebot_plugin_market/__main__.py @@ -18,6 +18,7 @@ "market", Subcommand("sell", Args["bag_index", int], Args["count", int, 0], Args["price_diff", str, ""]), Subcommand("buy", Args["name", str], Args["count", int, 1]), + Subcommand("list", Args["page", int, 1]), ) ) @@ -120,3 +121,30 @@ async def _(name: str, count: int, user_id: str = get_user_id()) -> None: used_vimcoin += p await session.commit() await lang.finish("buy.finish", user_id, p, bought_count, name) + + +ITEMS_PER_PAGE = 10 + + +@matcher.assign("list") +async def _(page: int, user_id: str = get_user_id()) -> None: + if page < 1: + page = 1 + async with get_session() as session: + query = select(MarketItem).where(MarketItem.remain_count > 0).order_by(MarketItem.item_id.desc()) + all_items = (await session.scalars(query)).all() + total = len(all_items) + if total == 0: + await lang.finish("list.empty", user_id) + total_pages = (total + ITEMS_PER_PAGE - 1) // ITEMS_PER_PAGE + if page > total_pages: + page = total_pages + start = (page - 1) * ITEMS_PER_PAGE + page_items = all_items[start : start + ITEMS_PER_PAGE] + lines = [] + for idx, market_item in enumerate(page_items, start=start + 1): + item = await get_market_item(user_id, market_item) + name = await item.getName() + lines.append(await lang.text("list.item_line", user_id, idx, name, market_item.remain_count, market_item.price)) + items_text = "\n".join(lines) + await lang.finish("list.header", user_id, page, total_pages, total, items_text) diff --git a/src/plugins/nonebot_plugin_market/help.yaml b/src/plugins/nonebot_plugin_market/help.yaml index 8dea3dead..d4f275cc7 100644 --- a/src/plugins/nonebot_plugin_market/help.yaml +++ b/src/plugins/nonebot_plugin_market/help.yaml @@ -1,3 +1,12 @@ plugin: market commands: - market: help;3;game \ No newline at end of file + market: + description: help.description + details: help.details + usages: + - help.usage1 + - help.usage2 + - help.usage3 + - help.usage4 + - help.usage5 + category: game From bb17daf9fcfc67db1a0a3fdab60e037de1d22e31 Mon Sep 17 00:00:00 2001 From: Delta Date: Mon, 11 May 2026 08:48:42 +0800 Subject: [PATCH 11/12] fix: rename handler functions to unique names, fix missing await and argument order - Rename handler functions from _ to handle_market_main/sell/buy/list - Fix missing await on user.has_vimcoin in buy handler elif branch - Fix sell.done argument order: count, name, price - Fix buy.finish argument order: bought_count, name, used_vimcoin --- src/plugins/nonebot_plugin_market/__main__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/nonebot_plugin_market/__main__.py b/src/plugins/nonebot_plugin_market/__main__.py index 15cb531e8..6c78304f7 100644 --- a/src/plugins/nonebot_plugin_market/__main__.py +++ b/src/plugins/nonebot_plugin_market/__main__.py @@ -33,14 +33,14 @@ async def get_average_price(item_data: ItemStack, session: AsyncSession) -> floa @matcher.assign("$main") -async def _(user_id: str = get_user_id()) -> None: +async def handle_market_main(user_id: str = get_user_id()) -> None: async with get_session() as session: count = len((await session.scalars(select(MarketItem).where(MarketItem.remain_count > 0))).all()) await lang.finish("main.info", user_id, count) @matcher.assign("sell") -async def _(bag_index: int, count: int, price_diff: str, user_id: str = get_user_id()) -> None: +async def handle_market_sell(bag_index: int, count: int, price_diff: str, user_id: str = get_user_id()) -> None: try: item = await get_bag_item(user_id, bag_index) except IndexError: @@ -73,7 +73,7 @@ async def _(bag_index: int, count: int, price_diff: str, user_id: str = get_user ) await session.commit() item.stack.count -= count - await lang.finish("sell.done", user_id, item.stack.getName(), count, price) + await lang.finish("sell.done", user_id, count, item.stack.getName(), price) async def get_market_item(user_id: str, data: MarketItem) -> ItemStack: @@ -97,7 +97,7 @@ async def give_market_item(count: int, item_data: MarketItem, user_id: str) -> N @matcher.assign("buy") -async def _(name: str, count: int, user_id: str = get_user_id()) -> None: +async def handle_market_buy(name: str, count: int, user_id: str = get_user_id()) -> None: bought_count = 0 used_vimcoin = 0 user = await get_user(user_id) @@ -112,7 +112,7 @@ async def _(name: str, count: int, user_id: str = get_user_id()) -> None: item.remain_count -= c used_vimcoin += p break - elif user.has_vimcoin(p := item.price * item.remain_count): + elif await user.has_vimcoin(p := item.price * item.remain_count): bought_count += item.remain_count await user.use_vimcoin(p, True) await (await get_user(item.user_id)).add_vimcoin(p * 0.99) @@ -120,14 +120,14 @@ async def _(name: str, count: int, user_id: str = get_user_id()) -> None: await session.delete(item) used_vimcoin += p await session.commit() - await lang.finish("buy.finish", user_id, p, bought_count, name) + await lang.finish("buy.finish", user_id, bought_count, name, used_vimcoin) ITEMS_PER_PAGE = 10 @matcher.assign("list") -async def _(page: int, user_id: str = get_user_id()) -> None: +async def handle_market_list(page: int, user_id: str = get_user_id()) -> None: if page < 1: page = 1 async with get_session() as session: From 9b9617438872ab0c49fe2f9acfb09e4cb26020ab Mon Sep 17 00:00:00 2001 From: This-is-XiaoDeng <1744793737@qq.com> Date: Mon, 11 May 2026 09:35:53 +0800 Subject: [PATCH 12/12] fix: remove unused imports, reorder count validation logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove unused datetime and Optional imports from models.py - Reorder sell handler count checks: negative → zero → exceeds stock (improves readability, same logical behavior) --- src/plugins/nonebot_plugin_market/__main__.py | 6 +++--- src/plugins/nonebot_plugin_market/models.py | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/nonebot_plugin_market/__main__.py b/src/plugins/nonebot_plugin_market/__main__.py index 6c78304f7..84db4289c 100644 --- a/src/plugins/nonebot_plugin_market/__main__.py +++ b/src/plugins/nonebot_plugin_market/__main__.py @@ -45,12 +45,12 @@ async def handle_market_sell(bag_index: int, count: int, price_diff: str, user_i item = await get_bag_item(user_id, bag_index) except IndexError: await lang.finish("sell.index_error", user_id) - if count > 0 and item.stack.count < count: - await lang.finish("sell.item_not_enough", user_id, item.stack.count) - elif count < 0: + if count < 0: await lang.finish("sell.wrong_count", user_id) elif count == 0: count = item.stack.count + elif count > item.stack.count: + await lang.finish("sell.item_not_enough", user_id, item.stack.count) async with get_session() as session: try: avg_price = await get_average_price(item.stack, session) diff --git a/src/plugins/nonebot_plugin_market/models.py b/src/plugins/nonebot_plugin_market/models.py index e53db8477..d585b2f31 100644 --- a/src/plugins/nonebot_plugin_market/models.py +++ b/src/plugins/nonebot_plugin_market/models.py @@ -1,5 +1,3 @@ -from datetime import datetime -from typing import Optional from nonebot_plugin_orm import Model from sqlalchemy import String from sqlalchemy.orm import Mapped, mapped_column