-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ 签到/金币排行限制最大数量 #1616
✨ 签到/金币排行限制最大数量 #1616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ | |
from nonebot_plugin_apscheduler import scheduler | ||
from nonebot_plugin_alconna import ( | ||
Args, | ||
Query, | ||
Option, | ||
Alconna, | ||
Arparma, | ||
AlconnaQuery, | ||
on_alconna, | ||
store_true, | ||
) | ||
|
@@ -90,7 +92,7 @@ | |
Option("--my", action=store_true, help_text="我的签到"), | ||
Option( | ||
"-l|--list", | ||
Args["num", int, 10], | ||
Args["num", int], | ||
help_text="好感度排行", | ||
), | ||
Option("-g|--global", action=store_true, help_text="全局排行"), | ||
|
@@ -140,7 +142,11 @@ async def _(session: EventSession, arparma: Arparma, nickname: str = UserName()) | |
|
||
|
||
@_sign_matcher.assign("list") | ||
async def _(session: EventSession, arparma: Arparma, num: int): | ||
async def _( | ||
session: EventSession, arparma: Arparma, num: Query[int] = AlconnaQuery("num", 10) | ||
): | ||
if num.result > 50: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: 考虑为最大排名限制定义一个常量 为了提高可维护性和一致性,考虑在模块级别定义一个常量,如 MAX_RANK_LIMIT = 50,并在此处和其他类似检查中使用它。
Original comment in Englishsuggestion: Consider defining a constant for the maximum rank limit To improve maintainability and consistency, consider defining a constant like MAX_RANK_LIMIT = 50 at the module level and using it here and in other similar checks.
|
||
await MessageUtils.build_message("排行榜人数不能超过50哦...").finish() | ||
gid = session.id3 or session.id2 | ||
if not arparma.find("global") and not gid: | ||
await MessageUtils.build_message( | ||
|
@@ -149,7 +155,7 @@ async def _(session: EventSession, arparma: Arparma, num: int): | |
if session.id1: | ||
if arparma.find("global"): | ||
gid = None | ||
if image := await SignManage.rank(session.id1, num, gid): | ||
if image := await SignManage.rank(session.id1, num.result, gid): | ||
logger.info("查看签到排行", arparma.header_result, session=session) | ||
await MessageUtils.build_message(image).finish() | ||
return MessageUtils.build_message("用户id为空...").send() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: 考虑将私信检查通用化
此私信检查对其他命令也可能有用。考虑创建一个装饰器或实用函数来处理此检查,可以在不同的命令处理程序中重用。
Original comment in English
suggestion: Consider generalizing the private message check
This check for private messages could be useful for other commands as well. Consider creating a decorator or utility function to handle this check, which could be reused across different command handlers.