@gonzih/cc-tg 0.2.14 → 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.d.ts CHANGED
@@ -43,3 +43,4 @@ export declare class CcTgBot {
43
43
  private killSession;
44
44
  stop(): void;
45
45
  }
46
+ export declare function splitMessage(text: string, maxLen?: number): string[];
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) => {
@@ -780,7 +792,7 @@ function downloadToFile(url, destPath) {
780
792
  }).on("error", reject);
781
793
  });
782
794
  }
783
- function splitMessage(text, maxLen = 4096) {
795
+ export function splitMessage(text, maxLen = 4096) {
784
796
  if (text.length <= maxLen)
785
797
  return [text];
786
798
  const chunks = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,10 @@
9
9
  "scripts": {
10
10
  "build": "tsc",
11
11
  "start": "node dist/index.js",
12
- "dev": "node --loader ts-node/esm src/index.ts"
12
+ "dev": "node --loader ts-node/esm src/index.ts",
13
+ "test": "vitest run",
14
+ "test:watch": "vitest",
15
+ "test:coverage": "vitest run --coverage"
13
16
  },
14
17
  "files": [
15
18
  "dist/"
@@ -20,7 +23,9 @@
20
23
  "devDependencies": {
21
24
  "@types/node": "^22.0.0",
22
25
  "@types/node-telegram-bot-api": "^0.64.0",
23
- "typescript": "^5.5.0"
26
+ "@vitest/coverage-v8": "^4.1.0",
27
+ "typescript": "^5.5.0",
28
+ "vitest": "^4.1.0"
24
29
  },
25
30
  "repository": {
26
31
  "type": "git",