Skip to content

Commit 58da370

Browse files
committed
Merge remote-tracking branch 'origin/master' into pr/Raven95676/8189
# Conflicts: # dashboard/src/assets/mdi-subset/materialdesignicons-subset.css # dashboard/src/assets/mdi-subset/materialdesignicons-webfont-subset.woff # dashboard/src/assets/mdi-subset/materialdesignicons-webfont-subset.woff2
2 parents 918edf3 + 2d78626 commit 58da370

103 files changed

Lines changed: 3157 additions & 304 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: checkout
1414
uses: actions/checkout@v6
1515
- name: Setup pnpm
16-
uses: pnpm/action-setup@v6.0.7
16+
uses: pnpm/action-setup@v6.0.8
1717
with:
1818
version: 10.28.2
1919
- name: Setup Node.js

.github/workflows/dashboard_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v6
1616

1717
- name: Setup pnpm
18-
uses: pnpm/action-setup@v6.0.7
18+
uses: pnpm/action-setup@v6.0.8
1919
with:
2020
version: 10.28.2
2121

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
echo "tag=$tag" >> "$GITHUB_OUTPUT"
5252
5353
- name: Setup pnpm
54-
uses: pnpm/action-setup@v6.0.7
54+
uses: pnpm/action-setup@v6.0.8
5555
with:
5656
version: 10.28.2
5757

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,10 @@ ruff check .
5252

5353
1. Title format: use conventional commit messages
5454
2. Use English to write PR title and descriptions.
55+
56+
## Release versions
57+
58+
1. Replace current version name to specific version name.
59+
2. Write changelog in `changelogs/`, you can refer to the full commit messages between the latest tag to the latest commit.
60+
3. Make and push a commit into master branch with message format like: `chore: bump version to 4.25.0`
61+
4. Create a tag and push the tag. For example: `git tag v4.25.0 && git push origin v4.25.0`

astrbot/builtin_stars/astrbot/main.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import copy
22
import traceback
3+
from collections.abc import Iterable
34
from sys import maxsize
45

56
import astrbot.api.message_components as Comp
@@ -19,6 +20,13 @@
1920
from .long_term_memory import LongTermMemory
2021

2122

23+
def _iter_message_components(event: AstrMessageEvent):
24+
messages = getattr(getattr(event, "message_obj", None), "message", None)
25+
if not isinstance(messages, Iterable) or isinstance(messages, (str, bytes)):
26+
return ()
27+
return tuple(messages)
28+
29+
2230
class Main(star.Star):
2331
def __init__(self, context: star.Context) -> None:
2432
self.context = context
@@ -134,8 +142,9 @@ def ltm_enabled(self, event: AstrMessageEvent):
134142
@filter.platform_adapter_type(filter.PlatformAdapterType.ALL)
135143
async def on_message(self, event: AstrMessageEvent):
136144
"""群聊记忆增强"""
145+
message_components = _iter_message_components(event)
137146
has_image_or_plain = False
138-
for comp in event.message_obj.message:
147+
for comp in message_components:
139148
if isinstance(comp, Plain) or isinstance(comp, Image):
140149
has_image_or_plain = True
141150
break
@@ -167,7 +176,7 @@ async def on_message(self, event: AstrMessageEvent):
167176

168177
if not session_curr_cid:
169178
logger.error(
170-
"当前未处于对话状态,无法主动回复,请确保 平台设置->会话隔离(unique_session) 未开启,并使用 /switch 序号 切换或者 /new 创建一个会话。",
179+
"当前未处于对话状态,无法主动回复,请确保 平台设置->会话隔离(unique_session) 未开启,并使用 /new 创建一个会话。",
171180
)
172181
return
173182

@@ -177,6 +186,13 @@ async def on_message(self, event: AstrMessageEvent):
177186
)
178187

179188
prompt = event.message_str
189+
image_urls = []
190+
for comp in message_components:
191+
if isinstance(comp, Image):
192+
try:
193+
image_urls.append(await comp.convert_to_file_path())
194+
except Exception:
195+
logger.exception("主动回复处理图片失败")
180196

181197
if not conv:
182198
logger.error("未找到对话,无法主动回复")
@@ -185,6 +201,7 @@ async def on_message(self, event: AstrMessageEvent):
185201
yield event.request_llm(
186202
prompt=prompt,
187203
session_id=event.session_id,
204+
image_urls=image_urls,
188205
conversation=conv,
189206
)
190207
except BaseException as e:

astrbot/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.24.5"
1+
__version__ = "4.25.1"

astrbot/cli/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66

77
from . import __version__
8-
from .commands import conf, init, plug, run
8+
from .commands import conf, init, password, plug, run
99

1010
logo_tmpl = r"""
1111
___ _______.___________..______ .______ ______ .___________.
@@ -54,6 +54,7 @@ def help(command_name: str | None) -> None:
5454
cli.add_command(help)
5555
cli.add_command(plug)
5656
cli.add_command(conf)
57+
cli.add_command(password)
5758

5859
if __name__ == "__main__":
5960
cli()

astrbot/cli/commands/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .cmd_conf import conf
22
from .cmd_init import init
3+
from .cmd_password import password
34
from .cmd_plug import plug
45
from .cmd_run import run
56

6-
__all__ = ["conf", "init", "plug", "run"]
7+
__all__ = ["conf", "init", "password", "plug", "run"]

astrbot/cli/commands/cmd_conf.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,22 @@ def _get_nested_item(obj: dict[str, Any], path: str) -> Any:
137137
return obj
138138

139139

140+
def _set_dashboard_password(config: dict[str, Any], raw_password: str) -> None:
141+
"""Set dashboard password hashes and clear password migration flags."""
142+
_set_nested_item(
143+
config,
144+
"dashboard.pbkdf2_password",
145+
hash_dashboard_password(raw_password),
146+
)
147+
_set_nested_item(
148+
config,
149+
"dashboard.password",
150+
hash_legacy_dashboard_password(raw_password),
151+
)
152+
_set_nested_item(config, "dashboard.password_storage_upgraded", True)
153+
_set_nested_item(config, "dashboard.password_change_required", False)
154+
155+
140156
@click.group(name="conf")
141157
def conf() -> None:
142158
"""Configuration management commands
@@ -171,16 +187,7 @@ def set_config(key: str, value: str) -> None:
171187
old_value = _get_nested_item(config, key)
172188
validated_value = CONFIG_VALIDATORS[key](value)
173189
if key == "dashboard.password":
174-
_set_nested_item(
175-
config,
176-
"dashboard.pbkdf2_password",
177-
hash_dashboard_password(validated_value),
178-
)
179-
_set_nested_item(
180-
config,
181-
"dashboard.password",
182-
hash_legacy_dashboard_password(validated_value),
183-
)
190+
_set_dashboard_password(config, validated_value)
184191
else:
185192
_set_nested_item(config, key, validated_value)
186193
_save_config(config)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import click
2+
3+
from .cmd_conf import (
4+
_load_config,
5+
_save_config,
6+
_set_dashboard_password,
7+
_set_nested_item,
8+
_validate_dashboard_password,
9+
_validate_dashboard_username,
10+
)
11+
12+
13+
@click.command(name="password")
14+
@click.option(
15+
"--username",
16+
help="Optional dashboard username to set together with the new password.",
17+
)
18+
def password(username: str | None) -> None:
19+
"""Change the AstrBot dashboard password."""
20+
config = _load_config()
21+
22+
new_password = click.prompt(
23+
"New dashboard password",
24+
hide_input=True,
25+
confirmation_prompt=True,
26+
)
27+
validated_password = _validate_dashboard_password(new_password)
28+
29+
if username is not None:
30+
validated_username = _validate_dashboard_username(username.strip())
31+
_set_nested_item(config, "dashboard.username", validated_username)
32+
33+
_set_dashboard_password(config, validated_password)
34+
_save_config(config)
35+
36+
click.echo("Dashboard password updated.")
37+
if username is not None:
38+
click.echo(f"Dashboard username updated: {validated_username}")

0 commit comments

Comments
 (0)