-
-
Notifications
You must be signed in to change notification settings - Fork 730
hotfix 分支 #1698
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
base: master
Are you sure you want to change the base?
hotfix 分支 #1698
Conversation
文件级别更改
提示和命令与 Sourcery 互动
自定义您的体验访问您的 dashboard 以:
获取帮助
Original review guide in EnglishReviewer's GuideThis PR restructures the CLI package by centralizing command registration in the root module, modularizing Flow Diagram: Updated CLI Command Structuregraph TD
A[astrbot cli] --> help_cmd("help [command_name]")
A --> init_cmd("init")
A --> run_cmd("run [--reload] [--port]")
A --> conf_group("conf")
A --> plug_group("plug")
conf_group --> conf_set("set <key> <value>")
conf_group --> conf_get("get [key]")
plug_group --> plug_new("new <name>")
plug_group --> plug_list("list [--all]")
plug_group --> plug_install("install <name> [--proxy]")
plug_group --> plug_update("update [name] [--proxy]")
plug_group --> plug_remove("remove <name>")
plug_group --> plug_search("search <query>")
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
嘿 @LIghtJUNction - 我已经审查了你的更改,并发现了一些需要解决的问题。
阻塞问题:
- 导入不存在的 CONFIG_VALIDATORS 将导致命令中断 (link)
一般评论:
astrbot.cli.plug.list
中的list
命令隐藏了内置的list
名称——考虑重命名它(例如list_plugins
)以避免混淆。- 在
conf/get.py
中,你从 utils 导入CONFIG_VALIDATORS
,但它只在conf/set.py
中定义——将该映射提取到一个共享模块中,以便 get 和 set 都可以一致地引用它。 - PR 在同一模块中混合了绝对导入和相对导入——选择一种样式(对于包内导入,首选相对导入)并始终如一地应用它,以提高可读性。
以下是我在审查期间查看的内容
- 🔴 一般问题:1 个阻塞问题,1 个其他问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟡 复杂性:发现 1 个问题
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @LIghtJUNction - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- Importing non-existent CONFIG_VALIDATORS will break command (link)
General comments:
- The
list
command inastrbot.cli.plug.list
shadows the built-inlist
name—consider renaming it (e.g.list_plugins
) to avoid confusion. - In
conf/get.py
you importCONFIG_VALIDATORS
from utils but it’s only defined inconf/set.py
—extract that mapping into a shared module so both get and set can reference it consistently. - The PR mixes absolute and relative imports within the same modules—pick one style (prefer relative for intra‐package imports) and apply it consistently to improve readability.
Here's what I looked at during the review
- 🔴 General issues: 1 blocking issue, 1 other issue
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
astrbot/cli/conf/set.py
Outdated
validate_callback_api_base, | ||
) | ||
# 可通过CLI设置的配置项,配置键到验证器函数的映射 | ||
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { |
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.
issue (complexity): 考虑将 CONFIG_VALIDATORS 移动到模块级别,并简化 set_config 函数,以提高效率和清晰度。
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
# 将 CONFIG_VALIDATORS 移动到模块级别,这样它就不会在每次调用时重建 | |
# config/commands/set.py | |
from typing import Callable, Any | |
import click | |
from .utils import load_config, save_config | |
from ..utils import ( | |
validate_timezone, | |
validate_log_level, | |
validate_dashboard_port, | |
validate_dashboard_username, | |
validate_dashboard_password, | |
validate_callback_api_base, | |
) | |
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
"timezone": validate_timezone, | |
"log_level": validate_log_level, | |
"dashboard.port": validate_dashboard_port, | |
"dashboard.username": validate_dashboard_username, | |
"dashboard.password": validate_dashboard_password, | |
"callback_api_base": validate_callback_api_base, | |
} | |
@click.command("set") | |
@click.argument("key") | |
@click.argument("value") | |
def set_config(key: str, value: str): | |
if key not in CONFIG_VALIDATORS: | |
raise click.ClickException(f"不支持的配置项: {key}") | |
# 1) 尽早且单独验证 | |
try: | |
validated = CONFIG_VALIDATORS[key](value) | |
except Exception as e: | |
raise click.UsageError(f"验证失败: {e}") | |
# 2) 加载和更新配置,使用简单的扁平/点状逻辑 | |
config = load_config() | |
parts = key.split(".", 1) | |
if len(parts) == 2: | |
section, field = parts | |
old = config.get(section, {}).get(field) | |
config.setdefault(section, {})[field] = validated | |
else: | |
old = config.get(key) | |
config[key] = validated | |
# 3) 保存并报告 | |
save_config(config) | |
click.echo(f"配置已更新: {key}") | |
if key == "dashboard.password": | |
click.echo(" 原值: ********") | |
click.echo(" 新值: ********") | |
else: | |
click.echo(f" 原值: {old}") | |
click.echo(f" 新值: {validated}") |
Original comment in English
issue (complexity): Consider moving CONFIG_VALIDATORS to the module level and simplifying the set_config function for better efficiency and clarity.
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
# Move CONFIG_VALIDATORS to module‐level so it's not rebuilt on every call | |
# config/commands/set.py | |
from typing import Callable, Any | |
import click | |
from .utils import load_config, save_config | |
from ..utils import ( | |
validate_timezone, | |
validate_log_level, | |
validate_dashboard_port, | |
validate_dashboard_username, | |
validate_dashboard_password, | |
validate_callback_api_base, | |
) | |
CONFIG_VALIDATORS: dict[str, Callable[[str], Any]] = { | |
"timezone": validate_timezone, | |
"log_level": validate_log_level, | |
"dashboard.port": validate_dashboard_port, | |
"dashboard.username": validate_dashboard_username, | |
"dashboard.password": validate_dashboard_password, | |
"callback_api_base": validate_callback_api_base, | |
} | |
@click.command("set") | |
@click.argument("key") | |
@click.argument("value") | |
def set_config(key: str, value: str): | |
if key not in CONFIG_VALIDATORS: | |
raise click.ClickException(f"不支持的配置项: {key}") | |
# 1) Validate early and separately | |
try: | |
validated = CONFIG_VALIDATORS[key](value) | |
except Exception as e: | |
raise click.UsageError(f"验证失败: {e}") | |
# 2) Load and update config with simple flat/dotted logic | |
config = load_config() | |
parts = key.split(".", 1) | |
if len(parts) == 2: | |
section, field = parts | |
old = config.get(section, {}).get(field) | |
config.setdefault(section, {})[field] = validated | |
else: | |
old = config.get(key) | |
config[key] = validated | |
# 3) Save and report | |
save_config(config) | |
click.echo(f"配置已更新: {key}") | |
if key == "dashboard.password": | |
click.echo(" 原值: ********") | |
click.echo(" 新值: ********") | |
else: | |
click.echo(f" 原值: {old}") | |
click.echo(f" 新值: {validated}") |
astrbot/cli/conf/get.py
Outdated
try: | ||
value = get_nested_item(config, key) | ||
if key == "dashboard.password": | ||
value = "********" | ||
click.echo(f"{key}: {value}") | ||
except KeyError: | ||
raise click.ClickException(f"未知的配置项: {key}") | ||
except Exception as e: | ||
raise click.UsageError(f"获取配置失败: {str(e)}") |
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.
issue (code-quality): 从先前的错误显式引发 [×2] (raise-from-previous-error
)
Original comment in English
issue (code-quality): Explicitly raise from a previous error [×2] (raise-from-previous-error
)
astrbot/cli/conf/set.py
Outdated
|
||
config = load_config() | ||
|
||
try: |
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.
issue (code-quality): 从先前的错误显式引发 [×2] (raise-from-previous-error
)
Original comment in English
issue (code-quality): Explicitly raise from a previous error [×2] (raise-from-previous-error
)
astrbot/cli/plug/remove.py
Outdated
shutil.rmtree(plugin_path) | ||
click.echo(f"插件 {name} 已卸载") | ||
except Exception as e: | ||
raise click.ClickException(f"卸载插件 {name} 失败: {e}") |
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 (code-quality): 显式地从先前的错误中引发 (raise-from-previous-error
)
raise click.ClickException(f"卸载插件 {name} 失败: {e}") | |
raise click.ClickException(f"卸载插件 {name} 失败: {e}") from e |
Original comment in English
suggestion (code-quality): Explicitly raise from a previous error (raise-from-previous-error
)
raise click.ClickException(f"卸载插件 {name} 失败: {e}") | |
raise click.ClickException(f"卸载插件 {name} 失败: {e}") from e |
astrbot/cli/plug/update.py
Outdated
plugin = next( | ||
( | ||
p | ||
for p in plugins | ||
if p["name"] == name and p["status"] == PluginStatus.NEED_UPDATE | ||
), | ||
None, | ||
) | ||
|
||
if not plugin: | ||
raise click.ClickException(f"插件 {name} 不需要更新或无法更新") |
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.
issue (code-quality): 我们发现了这些问题:
- 使用命名表达式简化赋值和条件 (
use-named-expression
) - 在控制流跳转后将代码提升到 else 中 (
reintroduce-else
) - 交换 if/else 分支 (
swap-if-else-branches
)
Original comment in English
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Lift code into else after jump in control flow (
reintroduce-else
) - Swap if/else branches (
swap-if-else-branches
)
astrbot/cli/utils/valutils.py
Outdated
if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: | ||
raise click.ClickException( | ||
"日志级别必须是 DEBUG/INFO/WARNING/ERROR/CRITICAL 之一" | ||
) |
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.
issue (code-quality): 我们发现了这些问题:
- 在控制流跳转后将代码提升到 else 中 (
reintroduce-else
) - 交换 if/else 分支 (
swap-if-else-branches
) - 在检查字面量集合的成员资格时使用集合 (
collection-into-set
)
Original comment in English
issue (code-quality): We've found these issues:
- Lift code into else after jump in control flow (
reintroduce-else
) - Swap if/else branches (
swap-if-else-branches
) - Use set when checking membership of a collection of literals (
collection-into-set
)
astrbot/cli/utils/valutils.py
Outdated
except ValueError: | ||
raise click.ClickException("端口必须是数字") |
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 (code-quality): 显式地从先前的错误中引发 (raise-from-previous-error
)
except ValueError: | |
raise click.ClickException("端口必须是数字") | |
except ValueError as e: | |
raise click.ClickException("端口必须是数字") from e |
Original comment in English
suggestion (code-quality): Explicitly raise from a previous error (raise-from-previous-error
)
except ValueError: | |
raise click.ClickException("端口必须是数字") | |
except ValueError as e: | |
raise click.ClickException("端口必须是数字") from e |
修改完毕 |
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.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/<folder>
astrbot/cli/conf/__main__.py
Outdated
@click.group(invoke_without_command=True) | ||
@click.option("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai") | ||
@click.option("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO") | ||
@click.option("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080") | ||
@click.option("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin") | ||
@click.option("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin") | ||
@click.option("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000") | ||
@click.pass_context | ||
def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str): | ||
"""配置管理子命令组""" | ||
if ctx.invoked_subcommand is None: | ||
# 检查是否有参数被设置为非默认值 |
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.
不建议占用过多选项
astrbot/cli/conf/set.py
Outdated
@click.option("--force", "-f", is_flag=True, help="强制设置,跳过验证器") | ||
@click.option("--create", "-c", is_flag=True, help="如果键不存在则创建") | ||
def set_config(key: str, value: str, type: str, force: bool, create: bool): |
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.
不建议提供强制设置的选项,当前无需提供--create flag
astrbot/cli/utils/valutils.py
Outdated
def validate_log_level(value: str) -> str: | ||
"""验证日志级别""" | ||
value = value.upper() | ||
if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: |
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.
这里建议用集合
astrbot/cli/init.py
Outdated
import toml | ||
|
||
with open(dot_astrbot,"w") as f: | ||
toml.dump(metadata,f) | ||
|
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.
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
我不想使用cwd主要是方便随处启动。避免到处初始化
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:26 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
个人感觉让用户在这里指定路径不如让用户cd过去( |
但是设置好环境变量就不用管了啊
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:40 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
我不想使用cwd主要是方便随处启动。避免到处初始化
________________________________
From: LIght JUNction ***@***.***>
Sent: Monday, June 9, 2025 3:26 AM
To: AstrBotDevs/AstrBot ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
收到
________________________________
From: 鸦羽 ***@***.***>
Sent: Monday, June 9, 2025 3:24 AM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强! (PR #1698)
@Raven95676 requested changes on this pull request.
1.不建议占用~/.astrbot
2.init不建议提供指定root目录的选项,仅允许初始化当前目录为root目录即可,比较符合直觉
3.部分插件及部分逻辑依赖data.plugins这一导入路径,所有插件命令建议统一指向<ASTRBOT_ROOT>/data/
________________________________
In astrbot/cli/conf/__main__.py<#1698 (comment)>:
***@***.***(invoke_without_command=True)
***@***.***("--timezone","-tz", default="Asia/Shanghai", help="设置时区,默认 Asia/Shanghai")
***@***.***("--log-level", "-l", default="INFO", help="设置日志级别,默认 INFO")
***@***.***("--dashboard-port", "-dp", default=8080, help="设置仪表盘端口,默认 8080")
***@***.***("--dashboard-username", "-du", default="admin", help="设置仪表盘用户名,默认 admin")
***@***.***("--dashboard-password", "-dpw", default="admin", help="设置仪表盘密码,默认 admin")
***@***.***("--callback-api-base", "-cab", default="http://localhost:5000", help="设置回调 API 基础 URL,默认 http://localhost:5000")
***@***.***_context
+def conf(ctx, timezone: str, log_level: str, dashboard_port: int, dashboard_username: str, dashboard_password: str, callback_api_base: str):
+ """配置管理子命令组"""
+ if ctx.invoked_subcommand is None:
+ # 检查是否有参数被设置为非默认值
不建议占用过多选项
________________________________
In astrbot/cli/conf/set.py<#1698 (comment)>:
***@***.***("--force", "-f", is_flag=True, help="强制设置,跳过验证器")
***@***.***("--create", "-c", is_flag=True, help="如果键不存在则创建")
+def set_config(key: str, value: str, type: str, force: bool, create: bool):
不建议提供强制设置的选项,当前无需提供--create flag
________________________________
In astrbot/cli/utils/valutils.py<#1698 (comment)>:
@@ -0,0 +1,53 @@
+import hashlib
+import zoneinfo
+import click
+
+def validate_log_level(value: str) -> str:
+ """验证日志级别"""
+ value = value.upper()
+ if value not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]:
这里建议用集合
________________________________
In astrbot/cli/init.py<#1698 (comment)>:
+ import toml
+
+ with open(dot_astrbot,"w") as f:
+ toml.dump(metadata,f)
+
感觉没必要为了这个新增一个toml依赖,用yaml/json就可以
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2IOTAFRUBBNQSXT6XFD3CT467AVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSMBYHAYTOOJTHA>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
pyproject.toml
Outdated
|
||
[tool.uv.workspace] | ||
members = [ | ||
"astrbot_plugin_test", |
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.
这个是?
target-version = "py310" | ||
|
||
[tool.uv.sources] | ||
silk-python = { git = "https://github.com/synodriver/pysilk.git" } |
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.
为什么不用pypi呢
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.
为什么不用pypi呢
我联系作者了,作者表示他会更新。
这里是因为作者没上传源代码到pypi
这样可以避免因为一个依赖安装不上导致整个astrbot安装不上
这个是直接从git源代码获取依赖,而不是从pypi
________________________________
From: Soulter ***@***.***>
Sent: Friday, June 20, 2025 2:42 PM
To: AstrBotDevs/AstrBot ***@***.***>
Cc: LIghtJUNction ***@***.***>; Mention ***@***.***>
Subject: Re: [AstrBotDevs/AstrBot] 让CLI组织结构更整洁+来点颜色+子命令组功能增强!+ ruff check全修复(详见提交说明)+ 适配最新的豆包模型新增的reasoning_content字段 (PR #1698)
@Soulter commented on this pull request.
________________________________
In pyproject.toml<#1698 (comment)>:
target-version = "py310"
+
+[tool.uv.sources]
+silk-python = { git = "https://github.com/synodriver/pysilk.git" }
+
+[tool.uv.workspace]
+members = [
+ "astrbot_plugin_test",
这个是?
―
Reply to this email directly, view it on GitHub<#1698 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AZQH2INT5OLXNAMILTGQYEL3EQMUFAVCNFSM6AAAAAB6J67AAGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDSNBWGQZDCNRTGI>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
requirements.txt
Outdated
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.
我不建议 requirements freeze 依赖项的版本号
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.
我觉得没什么问题了。看起来主要的改动集中在:
- ruff check 修复
- cli 优化
我建议将 requirements 中的依赖版本控制与 pyproject 中的一致,使用宽松依赖,否则插件安装很受影响,此外,其余的更改我认为应该没什么问题了
requirements已经上传更新了,移除了hash |
请问把astrbot包移动到src目录下是必须的嘛 |
我是全程使用uv的,如果不移动到src , uv tool install -e .就可能会出bug |
这个bug我研究了一会,windows可以触发,由于linux对全局环境管理比较严格。linux上没复现 |
触发我试过包括但不限于: |
同步一下,解决冲突 |
新增rich库依赖 |
解决了 #XYZ
Motivation
Modifications
规范性改动
并修复了一个导入错误,因为函数被弃用
Check
requirements.txt
和pyproject.toml
文件相应位置。好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
模块化并改进 AstrBot CLI,将命令重组为不同的模块,引入配置和插件管理组,修复导入问题,并增强验证和文档。
新特性:
Bug 修复:
增强:
文档:
Original summary in English
Summary by Sourcery
Modularize and refine the AstrBot CLI by reorganizing commands into distinct modules, introducing configuration and plugin management groups, fixing import issues, and enhancing validation and documentation.
New Features:
Bug Fixes:
Enhancements:
Documentation: