Telegram-user: add group skill filters
This commit is contained in:
parent
0eeabe404a
commit
b04142bfd5
@ -257,6 +257,7 @@ export function createTelegramUserMessageHandler(params: TelegramUserHandlerPara
|
|||||||
.catch(() => []);
|
.catch(() => []);
|
||||||
const combinedAllowFrom = [...allowFrom, ...storeAllowFrom];
|
const combinedAllowFrom = [...allowFrom, ...storeAllowFrom];
|
||||||
const chatId = msg.chat.type === "chat" ? msg.chat.id : undefined;
|
const chatId = msg.chat.type === "chat" ? msg.chat.id : undefined;
|
||||||
|
const isForum = msg.chat.type === "chat" && msg.chat.isForum === true;
|
||||||
const threadId =
|
const threadId =
|
||||||
isGroup && msg.isTopicMessage
|
isGroup && msg.isTopicMessage
|
||||||
? msg.replyToMessage?.threadId ?? undefined
|
? msg.replyToMessage?.threadId ?? undefined
|
||||||
@ -489,6 +490,16 @@ export function createTelegramUserMessageHandler(params: TelegramUserHandlerPara
|
|||||||
const conversationLabel = isGroup && chatId != null
|
const conversationLabel = isGroup && chatId != null
|
||||||
? buildTelegramUserGroupLabel(groupTitle, chatId, threadId)
|
? buildTelegramUserGroupLabel(groupTitle, chatId, threadId)
|
||||||
: senderName;
|
: senderName;
|
||||||
|
const skillFilter = firstDefined(
|
||||||
|
topicConfig?.skills,
|
||||||
|
groupConfig?.skills,
|
||||||
|
);
|
||||||
|
const systemPromptParts = [
|
||||||
|
groupConfig?.systemPrompt?.trim() || null,
|
||||||
|
topicConfig?.systemPrompt?.trim() || null,
|
||||||
|
].filter((entry): entry is string => Boolean(entry));
|
||||||
|
const groupSystemPrompt =
|
||||||
|
systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : undefined;
|
||||||
const mediaSuffix =
|
const mediaSuffix =
|
||||||
!rawBody && allMedia.length > 1 ? ` (${allMedia.length} items)` : "";
|
!rawBody && allMedia.length > 1 ? ` (${allMedia.length} items)` : "";
|
||||||
const body = core.channel.reply.formatAgentEnvelope({
|
const body = core.channel.reply.formatAgentEnvelope({
|
||||||
@ -511,7 +522,7 @@ export function createTelegramUserMessageHandler(params: TelegramUserHandlerPara
|
|||||||
ChatType: isGroup ? "group" : "direct",
|
ChatType: isGroup ? "group" : "direct",
|
||||||
ConversationLabel: conversationLabel,
|
ConversationLabel: conversationLabel,
|
||||||
GroupSubject: isGroup ? groupTitle ?? undefined : undefined,
|
GroupSubject: isGroup ? groupTitle ?? undefined : undefined,
|
||||||
GroupSystemPrompt: isGroup ? groupConfig?.systemPrompt ?? undefined : undefined,
|
GroupSystemPrompt: isGroup ? groupSystemPrompt : undefined,
|
||||||
SenderName: senderName,
|
SenderName: senderName,
|
||||||
SenderId: senderId,
|
SenderId: senderId,
|
||||||
SenderUsername: senderUsername ?? undefined,
|
SenderUsername: senderUsername ?? undefined,
|
||||||
@ -542,6 +553,7 @@ export function createTelegramUserMessageHandler(params: TelegramUserHandlerPara
|
|||||||
: `telegram-user:${senderId}`,
|
: `telegram-user:${senderId}`,
|
||||||
WasMentioned: isGroup ? effectiveWasMentioned : undefined,
|
WasMentioned: isGroup ? effectiveWasMentioned : undefined,
|
||||||
MessageThreadId: threadId,
|
MessageThreadId: threadId,
|
||||||
|
IsForum: isForum,
|
||||||
...(locationData ? toLocationContext(locationData) : undefined),
|
...(locationData ? toLocationContext(locationData) : undefined),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -626,7 +638,10 @@ export function createTelegramUserMessageHandler(params: TelegramUserHandlerPara
|
|||||||
ctx: ctxPayload,
|
ctx: ctxPayload,
|
||||||
cfg,
|
cfg,
|
||||||
dispatcher,
|
dispatcher,
|
||||||
replyOptions,
|
replyOptions: {
|
||||||
|
...replyOptions,
|
||||||
|
skillFilter,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
markDispatchIdle();
|
markDispatchIdle();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user