@gonzih/cc-tg 0.2.15 → 0.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bot.js +14 -2
- package/package.json +1 -1
package/dist/bot.js
CHANGED
|
@@ -146,7 +146,7 @@ export class CcTgBot {
|
|
|
146
146
|
}
|
|
147
147
|
const session = this.getOrCreateSession(chatId);
|
|
148
148
|
try {
|
|
149
|
-
session.claude.sendPrompt(text);
|
|
149
|
+
session.claude.sendPrompt(buildPromptWithReplyContext(text, msg));
|
|
150
150
|
this.startTyping(chatId, session);
|
|
151
151
|
}
|
|
152
152
|
catch (err) {
|
|
@@ -171,7 +171,7 @@ export class CcTgBot {
|
|
|
171
171
|
// Feed transcript into Claude as if user typed it
|
|
172
172
|
const session = this.getOrCreateSession(chatId);
|
|
173
173
|
try {
|
|
174
|
-
session.claude.sendPrompt(transcript);
|
|
174
|
+
session.claude.sendPrompt(buildPromptWithReplyContext(transcript, msg));
|
|
175
175
|
this.startTyping(chatId, session);
|
|
176
176
|
}
|
|
177
177
|
catch (err) {
|
|
@@ -756,6 +756,18 @@ export class CcTgBot {
|
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
|
+
function buildPromptWithReplyContext(text, msg) {
|
|
760
|
+
const reply = msg.reply_to_message;
|
|
761
|
+
if (!reply)
|
|
762
|
+
return text;
|
|
763
|
+
const quotedText = reply.text || reply.caption || null;
|
|
764
|
+
if (!quotedText)
|
|
765
|
+
return text;
|
|
766
|
+
const truncated = quotedText.length > 500
|
|
767
|
+
? quotedText.slice(0, 500) + "... [truncated]"
|
|
768
|
+
: quotedText;
|
|
769
|
+
return `[Replying to: "${truncated}"]\n\n${text}`;
|
|
770
|
+
}
|
|
759
771
|
/** Download a URL and return its contents as a base64 string */
|
|
760
772
|
function fetchAsBase64(url) {
|
|
761
773
|
return new Promise((resolve, reject) => {
|