@elizaos/plugin-telegram 1.0.10 → 1.6.2

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.
@@ -1,7 +1,19 @@
1
- import { type Content, type IAgentRuntime } from '@elizaos/core';
1
+ import { type Content, type IAgentRuntime, type Media } from '@elizaos/core';
2
2
  import type { Message, Update } from '@telegraf/types';
3
3
  import type { Context, NarrowedContext, Telegraf } from 'telegraf';
4
- import { TelegramContent } from './types';
4
+ import { type TelegramContent } from './types';
5
+ /**
6
+ * Interface for structured document processing results.
7
+ */
8
+ interface DocumentProcessingResult {
9
+ title: string;
10
+ fullText: string;
11
+ formattedDescription: string;
12
+ fileName: string;
13
+ mimeType: string | undefined;
14
+ fileSize: number | undefined;
15
+ error?: string;
16
+ }
5
17
  /**
6
18
  * Enum representing different types of media.
7
19
  * @enum { string }
@@ -37,6 +49,37 @@ export declare class MessageManager {
37
49
  processImage(message: Message): Promise<{
38
50
  description: string;
39
51
  } | null>;
52
+ /**
53
+ * Process a document from a Telegram message to extract the document URL and description.
54
+ * Handles PDFs and other document types by converting them to text when possible.
55
+ *
56
+ * @param {Message} message - The Telegram message object containing the document.
57
+ * @returns {Promise<{ description: string } | null>} The description of the processed document or null if no document found.
58
+ */
59
+ processDocument(message: Message): Promise<DocumentProcessingResult | null>;
60
+ /**
61
+ * Get the appropriate document processor based on MIME type.
62
+ */
63
+ private getDocumentProcessor;
64
+ /**
65
+ * Process PDF documents by converting them to text.
66
+ */
67
+ private processPdfDocument;
68
+ /**
69
+ * Process text documents by fetching their content.
70
+ */
71
+ private processTextDocument;
72
+ /**
73
+ * Processes the message content, documents, and images to generate
74
+ * processed content and media attachments.
75
+ *
76
+ * @param {Message} message The message to process
77
+ * @returns {Promise<{ processedContent: string; attachments: Media[] }>} Processed content and media attachments
78
+ */
79
+ processMessage(message: Message): Promise<{
80
+ processedContent: string;
81
+ attachments: Media[];
82
+ }>;
40
83
  /**
41
84
  * Sends a message in chunks, handling attachments and splitting the message if necessary
42
85
  *
@@ -85,3 +128,4 @@ export declare class MessageManager {
85
128
  */
86
129
  sendMessage(chatId: number | string, content: Content, replyToMessageId?: number): Promise<Message.TextMessage[]>;
87
130
  }
131
+ export {};
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { InlineKeyboardButton } from '@telegraf/types';
2
- import { Button } from './types';
1
+ import type { Button } from './types';
2
+ import type { InlineKeyboardButton } from '@telegraf/types';
3
3
  /**
4
4
  * This function converts standard markdown to Telegram MarkdownV2.
5
5
  *
@@ -27,3 +27,9 @@ export declare function splitMessage(text: string, maxLength?: number): string[]
27
27
  * @returns {InlineKeyboardButton[]} Array of Telegram buttons
28
28
  */
29
29
  export declare function convertToTelegramButtons(buttons?: Button[] | null): InlineKeyboardButton[];
30
+ /**
31
+ * Clean text by removing all NULL (\u0000) characters
32
+ * @param {string | undefined | null} text - The text to clean
33
+ * @returns {string} The cleaned text
34
+ */
35
+ export declare function cleanText(text: string | undefined | null): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-telegram",
3
- "version": "1.0.10",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@elizaos/core": "^1.0.19",
21
+ "@elizaos/core": "^1.6.2",
22
22
  "@telegraf/types": "7.1.0",
23
23
  "@types/node": "^24.0.10",
24
24
  "strip-literal": "^3.0.0",