Skip to content

Commit 5222bae

Browse files
committed
fix(bot): send silent model replies and notify on final footer
1 parent 0580a73 commit 5222bae

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/bot/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ async function ensureEventSubscription(directory: string): Promise<void> {
780780
elapsedMs: Date.now() - completedRun.startedAt,
781781
}),
782782
{
783-
disable_notification: true,
784783
...(keyboard ? { reply_markup: keyboard } : {}),
785784
},
786785
);

src/bot/utils/finalize-assistant-response.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ interface FinalizeAssistantResponseOptions {
1616
sendText: (
1717
text: string,
1818
rawFallbackText: string | undefined,
19-
options: { reply_markup: unknown } | undefined,
19+
options:
20+
| {
21+
reply_markup?: unknown;
22+
disable_notification?: boolean;
23+
}
24+
| undefined,
2025
format: TelegramTextFormat,
2126
) => Promise<void>;
2227
}
@@ -36,9 +41,12 @@ export async function finalizeAssistantResponse({
3641
}: FinalizeAssistantResponseOptions): Promise<boolean> {
3742
const keyboard = getReplyKeyboard();
3843
const replyOptions = keyboard ? { reply_markup: keyboard } : undefined;
39-
const streamSendOptions = {
44+
const silentReplyOptions = {
4045
disable_notification: true,
4146
...(replyOptions ?? {}),
47+
};
48+
const streamSendOptions = {
49+
...silentReplyOptions,
4250
} as StreamingMessagePayload["sendOptions"];
4351

4452
const preparedStreamPayload = prepareStreamingPayload(messageText);
@@ -69,7 +77,7 @@ export async function finalizeAssistantResponse({
6977
for (let partIndex = 0; partIndex < parts.length; partIndex++) {
7078
const part = parts[partIndex];
7179
const rawFallbackText = rawParts[partIndex];
72-
await sendText(part, rawFallbackText, replyOptions, format);
80+
await sendText(part, rawFallbackText, silentReplyOptions, format);
7381
}
7482

7583
return false;

tests/bot/utils/finalize-assistant-response.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ describe("bot/utils/finalize-assistant-response", () => {
3636
1,
3737
"part 1",
3838
"part 1",
39-
{ reply_markup: keyboard },
39+
{ disable_notification: true, reply_markup: keyboard },
4040
"markdown_v2",
4141
);
4242
expect(sendText).toHaveBeenNthCalledWith(
4343
2,
4444
"part 2",
4545
"part 2",
46-
{ reply_markup: keyboard },
46+
{ disable_notification: true, reply_markup: keyboard },
4747
"markdown_v2",
4848
);
4949
});
@@ -104,6 +104,6 @@ describe("bot/utils/finalize-assistant-response", () => {
104104
});
105105

106106
expect(sendText).toHaveBeenCalledTimes(1);
107-
expect(sendText).toHaveBeenCalledWith("reply", "reply", undefined, "raw");
107+
expect(sendText).toHaveBeenCalledWith("reply", "reply", { disable_notification: true }, "raw");
108108
});
109109
});

0 commit comments

Comments
 (0)