@elizaos/plugin-telegram 1.6.4 → 2.0.0-alpha.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.
package/dist/types.d.ts DELETED
@@ -1,99 +0,0 @@
1
- import type { Content, EntityPayload, MessagePayload, WorldPayload } from '@elizaos/core';
2
- import type { Chat, Message, ReactionType } from '@telegraf/types';
3
- import type { Context } from 'telegraf';
4
- /**
5
- * Extention of the core Content type just for Telegram
6
- */
7
- export interface TelegramContent extends Content {
8
- /** Array of buttons */
9
- buttons?: Button[];
10
- }
11
- /**
12
- * Represents a flexible button configuration
13
- */
14
- export type Button = {
15
- /** The type of button */
16
- kind: 'login' | 'url';
17
- /** The text to display on the button */
18
- text: string;
19
- /** The URL or endpoint the button should link to */
20
- url: string;
21
- };
22
- /**
23
- * Telegram-specific event types
24
- */
25
- export declare enum TelegramEventTypes {
26
- WORLD_JOINED = "TELEGRAM_WORLD_JOINED",
27
- WORLD_CONNECTED = "TELEGRAM_WORLD_CONNECTED",
28
- WORLD_LEFT = "TELEGRAM_WORLD_LEFT",
29
- ENTITY_JOINED = "TELEGRAM_ENTITY_JOINED",
30
- ENTITY_LEFT = "TELEGRAM_ENTITY_LEFT",
31
- ENTITY_UPDATED = "TELEGRAM_ENTITY_UPDATED",
32
- MESSAGE_RECEIVED = "TELEGRAM_MESSAGE_RECEIVED",
33
- MESSAGE_SENT = "TELEGRAM_MESSAGE_SENT",
34
- REACTION_RECEIVED = "TELEGRAM_REACTION_RECEIVED",
35
- INTERACTION_RECEIVED = "TELEGRAM_INTERACTION_RECEIVED",
36
- SLASH_START = "TELEGRAM_SLASH_START"
37
- }
38
- /**
39
- * Telegram-specific event payload map
40
- */
41
- export interface TelegramEventPayloadMap {
42
- [TelegramEventTypes.MESSAGE_RECEIVED]: TelegramMessageReceivedPayload;
43
- [TelegramEventTypes.MESSAGE_SENT]: TelegramMessageSentPayload;
44
- [TelegramEventTypes.REACTION_RECEIVED]: TelegramReactionReceivedPayload;
45
- [TelegramEventTypes.WORLD_JOINED]: TelegramWorldPayload;
46
- [TelegramEventTypes.WORLD_CONNECTED]: TelegramWorldPayload;
47
- [TelegramEventTypes.WORLD_LEFT]: TelegramWorldPayload;
48
- [TelegramEventTypes.SLASH_START]: {
49
- ctx: Context;
50
- };
51
- [TelegramEventTypes.ENTITY_JOINED]: TelegramEntityPayload;
52
- [TelegramEventTypes.ENTITY_LEFT]: TelegramEntityPayload;
53
- [TelegramEventTypes.ENTITY_UPDATED]: TelegramEntityPayload;
54
- [TelegramEventTypes.INTERACTION_RECEIVED]: TelegramReactionReceivedPayload;
55
- }
56
- /**
57
- * Telegram-specific message received payload
58
- */
59
- export interface TelegramMessageReceivedPayload extends MessagePayload {
60
- /** The original Telegram context */
61
- ctx: Context;
62
- /** The original Telegram message */
63
- originalMessage: Message;
64
- }
65
- /**
66
- * Telegram-specific message sent payload
67
- */
68
- export interface TelegramMessageSentPayload extends MessagePayload {
69
- /** The original Telegram messages */
70
- originalMessages: Message[];
71
- /** The chat ID where the message was sent */
72
- chatId: number | string;
73
- }
74
- /**
75
- * Telegram-specific reaction received payload
76
- */
77
- export interface TelegramReactionReceivedPayload extends TelegramMessageReceivedPayload {
78
- /** The reaction type as a string */
79
- reactionString: string;
80
- /** The original reaction object */
81
- originalReaction: ReactionType;
82
- }
83
- /**
84
- * Telegram-specific world payload
85
- */
86
- export interface TelegramWorldPayload extends WorldPayload {
87
- chat: Chat;
88
- botUsername?: string;
89
- }
90
- /**
91
- * Telegram-specific entity payload
92
- */
93
- export interface TelegramEntityPayload extends EntityPayload {
94
- telegramUser: {
95
- id: number;
96
- username?: string;
97
- first_name?: string;
98
- };
99
- }
package/dist/utils.d.ts DELETED
@@ -1,35 +0,0 @@
1
- import type { Button } from './types';
2
- import type { InlineKeyboardButton } from '@telegraf/types';
3
- /**
4
- * This function converts standard markdown to Telegram MarkdownV2.
5
- *
6
- * In addition to processing code blocks, inline code, links, bold, strikethrough, and italic,
7
- * it converts any header lines (those starting with one or more `#`) to bold text.
8
- *
9
- * Note: This solution uses a sequence of regex‐replacements and placeholders.
10
- * It makes assumptions about non–nested formatting and does not cover every edge case.
11
- */
12
- export declare function convertMarkdownToTelegram(markdown: string): string;
13
- /**
14
- * Splits a message into chunks that fit within Telegram's message length limit
15
- */
16
- /**
17
- * Splits a text message into chunks based on a maximum length for each chunk.
18
- *
19
- * @param {string} text - The text message to split.
20
- * @param {number} maxLength - The maximum length for each chunk (default is 4096).
21
- * @returns {string[]} An array containing the text message split into chunks.
22
- */
23
- export declare function splitMessage(text: string, maxLength?: number): string[];
24
- /**
25
- * Converts Eliza buttons into Telegram buttons
26
- * @param {Button[]} buttons - The buttons from Eliza content
27
- * @returns {InlineKeyboardButton[]} Array of Telegram buttons
28
- */
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;