Compare commits
2 Commits
v4.0.0-bet
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
817ef94742 | ||
|
|
10e91fe375 |
@@ -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:
|
||||
|
||||
@@ -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 = ""
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user