Compare commits

..

2 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
817ef94742 Implement Telegram topic isolation feature - share conversations across topics
Co-authored-by: Soulter <37870767+Soulter@users.noreply.github.com>
2025-08-16 16:30:18 +00:00
copilot-swe-agent[bot]
10e91fe375 Initial plan 2025-08-16 16:18:47 +00:00
12 changed files with 36 additions and 90 deletions

View File

@@ -6,7 +6,7 @@ import os
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
VERSION = "3.5.25"
VERSION = "3.5.24"
DB_PATH = os.path.join(get_astrbot_data_path(), "data_v3.db")
# 默认配置

View File

@@ -47,19 +47,12 @@ class AstrBotCoreLifecycle:
self.db = db # 初始化数据库
# 设置代理
proxy_config = self.astrbot_config.get("http_proxy", "")
if proxy_config != "":
os.environ["https_proxy"] = proxy_config
os.environ["http_proxy"] = proxy_config
logger.debug(f"Using proxy: {proxy_config}")
else:
# 清空代理环境变量
if "https_proxy" in os.environ:
del os.environ["https_proxy"]
if "http_proxy" in os.environ:
del os.environ["http_proxy"]
logger.debug("HTTP proxy cleared")
os.environ["no_proxy"] = "localhost,127.0.0.1,::1"
if self.astrbot_config.get("http_proxy", ""):
os.environ["https_proxy"] = self.astrbot_config["http_proxy"]
os.environ["http_proxy"] = self.astrbot_config["http_proxy"]
if proxy := os.environ.get("https_proxy"):
logger.debug(f"Using proxy: {proxy}")
os.environ["no_proxy"] = "localhost"
async def initialize(self):
"""

View File

@@ -335,10 +335,6 @@ class LLMRequestSubStage(Stage):
):
return
if not llm_response.completion_text and not req.tool_calls_result:
logger.debug("LLM 响应为空,不保存记录。")
return
# 历史上下文
messages = copy.deepcopy(req.contexts)
# 这一轮对话请求的用户输入

View File

@@ -144,6 +144,8 @@ class RespondStage(Stage):
try:
if await self._is_empty_message_chain(result.chain):
logger.info("消息为空,跳过发送阶段")
event.clear_result()
event.stop_event()
return
except Exception as e:
logger.warning(f"空内容检查异常: {e}")

View File

@@ -223,9 +223,10 @@ class TelegramPlatformAdapter(Platform):
message.type = MessageType.GROUP_MESSAGE
message.group_id = str(update.message.chat.id)
if update.message.message_thread_id:
# Topic Group
# Topic Group - keep topic info in group_id for message routing,
# but use base group_id for session_id to share conversations
message.group_id += "#" + str(update.message.message_thread_id)
message.session_id = message.group_id
# session_id remains the base group_id for shared conversation
message.message_id = str(update.message.message_id)
message.sender = MessageMember(
@@ -349,6 +350,13 @@ class TelegramPlatformAdapter(Platform):
session_id=message.session_id,
client=self.client,
)
# Store topic information for shared conversations
if message.type == MessageType.GROUP_MESSAGE and "#" in message.group_id:
group_id, topic_id = message.group_id.split("#")
message_event.set_extra("telegram_topic_id", topic_id)
message_event.set_extra("telegram_base_group_id", group_id)
self.commit_event(message_event)
def get_client(self) -> ExtBot:

View File

@@ -66,7 +66,9 @@ class TelegramPlatformEvent(AstrMessageEvent):
return chunks
@classmethod
async def send_with_client(cls, client: ExtBot, message: MessageChain, user_name: str):
async def send_with_client(
cls, client: ExtBot, message: MessageChain, user_name: str
):
image_path = None
has_reply = False
@@ -148,7 +150,7 @@ class TelegramPlatformEvent(AstrMessageEvent):
"chat_id": user_name,
}
if message_thread_id:
payload["reply_to_message_id"] = message_thread_id
payload["message_thread_id"] = message_thread_id
delta = ""
current_content = ""

View File

@@ -1,13 +0,0 @@
# What's Changed
1. 修复: 修复插件可能存在的无法正常禁用的问题 ([#2352](https://github.com/Soulter/AstrBot/issues/2352))
2. ❗修复:当返回文本为空并且存在函数调用时错误地被终止事件,导致函数调用结果未被正常返回 ([#2491](https://github.com/Soulter/AstrBot/issues/2491))
3. 修复:修复无法清空 AstrBot 配置下的 http_proxy 代理的问题 ([#2434](https://github.com/Soulter/AstrBot/issues/2434))
4. ❗修复Gemini 下开启流式输出时,持久化的消息结果不完整 ([#2424](https://github.com/Soulter/AstrBot/issues/2424))
5. 修复:注册文件时由于 file:/// 前缀,导致文件被误判为不存在的问题 ([#2325](https://github.com/Soulter/AstrBot/issues/2325))
6. 优化: 为部分类型供应商添加默认的温度选项 ([#2321](https://github.com/Soulter/AstrBot/issues/2321))
7. 优化: 适配 Qwen3 模型非流式输出下需要传入 enable_think 参数(否则报错) ([#2424](https://github.com/Soulter/AstrBot/issues/2424))
8. 优化:支持配置工具调用轮数上限,默认 30
9. 新增: 添加 WebUI 语义化预发布版本提醒和检测功能
> 新版本预告: v4.0.0 即将发布。

View File

@@ -25,12 +25,6 @@
"dev": "🧐 Development (master branch)"
},
"updateToLatest": "Update to Latest Version",
"preRelease": "Pre-release",
"preReleaseWarning": {
"title": "Pre-release Version Notice",
"description": "Versions marked as pre-release may contain unknown issues or bugs and are not recommended for production use. If you encounter any problems, please visit ",
"issueLink": "GitHub Issues"
},
"tip": "💡 TIP: Switching to an older version or a specific version will not re-download the dashboard files, which may cause some data display errors. You can find the corresponding dashboard files dist.zip at",
"tipLink": "here",
"tipContinue": ", extract and replace the data/dist folder. Of course, the frontend source code is in the dashboard directory, you can also build it yourself using npm install and npm build.",

View File

@@ -25,12 +25,6 @@
"dev": "🧐 开发版(master 分支)"
},
"updateToLatest": "更新到最新版本",
"preRelease": "预发布",
"preReleaseWarning": {
"title": "预发布版本提醒",
"description": "标有预发布标签的版本可能存在未知问题或 Bug不建议在生产环境使用。如发现问题请提交至 ",
"issueLink": "GitHub Issues"
},
"tip": "💡 TIP: 跳到旧版本或者切换到某个版本不会重新下载管理面板文件,这可能会造成部分数据显示错误。您可在",
"tipLink": "此处",
"tipContinue": "找到对应的面板文件 dist.zip解压后替换 data/dist 文件夹即可。当然,前端源代码在 dashboard 目录下,你也可以自己使用 npm install 和 npm build 构建。",

View File

@@ -76,13 +76,6 @@ const open = (link: string) => {
window.open(link, '_blank');
};
// 检测是否为预发布版本
const isPreRelease = (version: string) => {
const preReleaseKeywords = ['alpha', 'beta', 'rc', 'pre', 'preview', 'dev'];
const lowerVersion = version.toLowerCase();
return preReleaseKeywords.some(keyword => lowerVersion.includes(keyword));
};
// 账户修改
function accountEdit() {
accountEditStatus.value.loading = true;
@@ -312,7 +305,7 @@ commonStore.getStartTime();
</v-btn>
<!-- 更新对话框 -->
<v-dialog v-model="updateStatusDialog" :width="$vuetify.display.smAndDown ? '100%' : '1200'" :fullscreen="$vuetify.display.xs">
<v-dialog v-model="updateStatusDialog" :width="$vuetify.display.smAndDown ? '100%' : '1000'" :fullscreen="$vuetify.display.xs">
<template v-slot:activator="{ props }">
<v-btn size="small" @click="checkUpdate(); getReleases(); getDevCommits();" class="action-btn"
color="var(--v-theme-surface)" variant="flat" rounded="sm" v-bind="props">
@@ -364,44 +357,11 @@ commonStore.getStartTime();
href="https://containrrr.dev/watchtower/usage-overview/">{{ t('core.header.updateDialog.dockerTipLink') }}</a> {{ t('core.header.updateDialog.dockerTipContinue') }}</small>
</div>
<v-alert
v-if="releases.some(item => isPreRelease(item['tag_name']))"
type="warning"
variant="tonal"
border="start"
>
<template v-slot:prepend>
<v-icon>mdi-alert-circle-outline</v-icon>
</template>
<div class="text-body-2">
<strong>{{ t('core.header.updateDialog.preReleaseWarning.title') }}</strong>
<br>
{{ t('core.header.updateDialog.preReleaseWarning.description') }}
<a href="https://github.com/Soulter/AstrBot/issues" target="_blank" class="text-decoration-none">
{{ t('core.header.updateDialog.preReleaseWarning.issueLink') }}
</a>
</div>
</v-alert>
<v-data-table :headers="releasesHeader" :items="releases" item-key="name">
<template v-slot:item.tag_name="{ item }: { item: { tag_name: string } }">
<div class="d-flex align-center">
<span>{{ item.tag_name }}</span>
<v-chip
v-if="isPreRelease(item.tag_name)"
size="x-small"
color="warning"
variant="tonal"
class="ml-2"
>
{{ t('core.header.updateDialog.preRelease') }}
</v-chip>
</div>
</template>
<template v-slot:item.body="{ item }: { item: { body: string } }">
<v-tooltip :text="item.body">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" rounded="xl" variant="tonal" color="primary" size="x-small">{{ t('core.header.updateDialog.table.view') }}</v-btn>
<v-btn v-bind="props" rounded="xl" variant="tonal" color="primary" size="small">{{ t('core.header.updateDialog.table.view') }}</v-btn>
</template>
</v-tooltip>
</template>

View File

@@ -1316,6 +1316,16 @@ UID: {user_id} 此 ID 可用于设置管理员。
except BaseException as e:
logger.error(f"处理引用图片失败: {e}")
# Add Telegram topic context for shared conversations
if event.get_platform_name() == "telegram":
topic_id = event.get_extra("telegram_topic_id")
base_group_id = event.get_extra("telegram_base_group_id")
if topic_id and base_group_id:
req.system_prompt += (
f"\n[Context: This message is from Telegram topic "
f"#{topic_id} in group {base_group_id}]\n"
)
if self.ltm:
try:
await self.ltm.on_req_llm(event, req)

View File

@@ -1,6 +1,6 @@
[project]
name = "AstrBot"
version = "3.5.25"
version = "3.5.24"
description = "易上手的多平台 LLM 聊天机器人及开发框架"
readme = "README.md"
requires-python = ">=3.10"