Compare commits
1 Commits
backup-202
...
backup-202
| Author | SHA1 | Date | |
|---|---|---|---|
| bc87681085 |
17
bot/bot.ts
17
bot/bot.ts
@@ -1460,10 +1460,19 @@ bot.on("message:text", async (ctx) => {
|
|||||||
// Stream the reply word-by-word so the message animates into the chat like
|
// Stream the reply word-by-word so the message animates into the chat like
|
||||||
// an LLM typing. @grammyjs/stream uses sendMessageDraft (Bot API 9.5) to push
|
// an LLM typing. @grammyjs/stream uses sendMessageDraft (Bot API 9.5) to push
|
||||||
// each delta as a native, animated draft and finalizes with sendMessage.
|
// each delta as a native, animated draft and finalizes with sendMessage.
|
||||||
const messages = await ctx.replyWithStream(streamWords(out), {}, {
|
// sendMessageDraft is only supported in private chats — group / supergroup
|
||||||
reply_parameters: { message_id: ctx.message.message_id },
|
// / channel peers return TEXTDRAFT_PEER_INVALID. Use plain reply there.
|
||||||
});
|
let finalMessage: { message_id: number } | undefined;
|
||||||
const finalMessage = messages[messages.length - 1];
|
if (chatType === "private") {
|
||||||
|
const messages = await ctx.replyWithStream(streamWords(out), {}, {
|
||||||
|
reply_parameters: { message_id: ctx.message.message_id },
|
||||||
|
});
|
||||||
|
finalMessage = messages[messages.length - 1];
|
||||||
|
} else {
|
||||||
|
finalMessage = await ctx.reply(out, {
|
||||||
|
reply_parameters: { message_id: ctx.message.message_id },
|
||||||
|
});
|
||||||
|
}
|
||||||
if (finalMessage) {
|
if (finalMessage) {
|
||||||
Q.insMsg.run(chatId, finalMessage.message_id, null, "out", "text", out, ctx.message.message_id);
|
Q.insMsg.run(chatId, finalMessage.message_id, null, "out", "text", out, ctx.message.message_id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user