@daemux/telegram-adapter 1.0.0
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/.claude-plugin/plugin.json +8 -0
- package/dist/api-send.d.ts +40 -0
- package/dist/api-send.d.ts.map +1 -0
- package/dist/api-send.js +77 -0
- package/dist/api-send.js.map +1 -0
- package/dist/api.d.ts +39 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +123 -0
- package/dist/api.js.map +1 -0
- package/dist/channel-convert.d.ts +9 -0
- package/dist/channel-convert.d.ts.map +1 -0
- package/dist/channel-convert.js +67 -0
- package/dist/channel-convert.js.map +1 -0
- package/dist/channel.d.ts +60 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +234 -0
- package/dist/channel.js.map +1 -0
- package/dist/format.d.ts +13 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +129 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/message-resolver.d.ts +26 -0
- package/dist/message-resolver.d.ts.map +1 -0
- package/dist/message-resolver.js +155 -0
- package/dist/message-resolver.js.map +1 -0
- package/dist/poller.d.ts +40 -0
- package/dist/poller.d.ts.map +1 -0
- package/dist/poller.js +95 -0
- package/dist/poller.js.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Type & File ID Resolver
|
|
3
|
+
* Extracts message type and primary file ID from a Telegram message.
|
|
4
|
+
*/
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Message type resolution
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
/**
|
|
9
|
+
* Determine the message type from a Telegram message.
|
|
10
|
+
* Priority order matches Telegram's conventions: animation before video
|
|
11
|
+
* (since animations have both animation and document fields).
|
|
12
|
+
*/
|
|
13
|
+
export function resolveMessageType(msg) {
|
|
14
|
+
if (msg.photo && msg.photo.length > 0)
|
|
15
|
+
return 'photo';
|
|
16
|
+
if (msg.animation)
|
|
17
|
+
return 'animation';
|
|
18
|
+
if (msg.video)
|
|
19
|
+
return 'video';
|
|
20
|
+
if (msg.video_note)
|
|
21
|
+
return 'video_note';
|
|
22
|
+
if (msg.voice)
|
|
23
|
+
return 'voice';
|
|
24
|
+
if (msg.audio)
|
|
25
|
+
return 'audio';
|
|
26
|
+
if (msg.sticker)
|
|
27
|
+
return 'sticker';
|
|
28
|
+
if (msg.document)
|
|
29
|
+
return 'document';
|
|
30
|
+
if (msg.contact)
|
|
31
|
+
return 'contact';
|
|
32
|
+
if (msg.location)
|
|
33
|
+
return 'location';
|
|
34
|
+
return 'text';
|
|
35
|
+
}
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// File ID resolution
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/** Extract the primary file_id from a Telegram message, if it has a file attachment. */
|
|
40
|
+
export function resolveFileId(msg) {
|
|
41
|
+
if (msg.photo && msg.photo.length > 0) {
|
|
42
|
+
return pickLargestPhoto(msg.photo);
|
|
43
|
+
}
|
|
44
|
+
if (msg.animation)
|
|
45
|
+
return msg.animation.file_id;
|
|
46
|
+
if (msg.video)
|
|
47
|
+
return msg.video.file_id;
|
|
48
|
+
if (msg.video_note)
|
|
49
|
+
return msg.video_note.file_id;
|
|
50
|
+
if (msg.voice)
|
|
51
|
+
return msg.voice.file_id;
|
|
52
|
+
if (msg.audio)
|
|
53
|
+
return msg.audio.file_id;
|
|
54
|
+
if (msg.sticker)
|
|
55
|
+
return msg.sticker.file_id;
|
|
56
|
+
if (msg.document)
|
|
57
|
+
return msg.document.file_id;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Full attachment resolution
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
/** Extract all attachment metadata from a Telegram message. */
|
|
64
|
+
export function resolveAttachment(msg) {
|
|
65
|
+
if (msg.photo && msg.photo.length > 0) {
|
|
66
|
+
const largest = pickLargestPhotoSize(msg.photo);
|
|
67
|
+
return {
|
|
68
|
+
type: 'photo',
|
|
69
|
+
fileId: largest.file_id,
|
|
70
|
+
fileSize: largest.file_size,
|
|
71
|
+
width: largest.width,
|
|
72
|
+
height: largest.height,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (msg.animation) {
|
|
76
|
+
return {
|
|
77
|
+
type: 'animation',
|
|
78
|
+
fileId: msg.animation.file_id,
|
|
79
|
+
mimeType: msg.animation.mime_type,
|
|
80
|
+
fileSize: msg.animation.file_size,
|
|
81
|
+
duration: msg.animation.duration,
|
|
82
|
+
width: msg.animation.width,
|
|
83
|
+
height: msg.animation.height,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (msg.video) {
|
|
87
|
+
return {
|
|
88
|
+
type: 'video',
|
|
89
|
+
fileId: msg.video.file_id,
|
|
90
|
+
mimeType: msg.video.mime_type,
|
|
91
|
+
fileSize: msg.video.file_size,
|
|
92
|
+
duration: msg.video.duration,
|
|
93
|
+
width: msg.video.width,
|
|
94
|
+
height: msg.video.height,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (msg.video_note) {
|
|
98
|
+
return {
|
|
99
|
+
type: 'video_note',
|
|
100
|
+
fileId: msg.video_note.file_id,
|
|
101
|
+
fileSize: msg.video_note.file_size,
|
|
102
|
+
duration: msg.video_note.duration,
|
|
103
|
+
width: msg.video_note.length,
|
|
104
|
+
height: msg.video_note.length,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (msg.voice) {
|
|
108
|
+
return {
|
|
109
|
+
type: 'voice',
|
|
110
|
+
fileId: msg.voice.file_id,
|
|
111
|
+
mimeType: msg.voice.mime_type,
|
|
112
|
+
fileSize: msg.voice.file_size,
|
|
113
|
+
duration: msg.voice.duration,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (msg.audio) {
|
|
117
|
+
return {
|
|
118
|
+
type: 'audio',
|
|
119
|
+
fileId: msg.audio.file_id,
|
|
120
|
+
mimeType: msg.audio.mime_type,
|
|
121
|
+
fileName: msg.audio.title,
|
|
122
|
+
fileSize: msg.audio.file_size,
|
|
123
|
+
duration: msg.audio.duration,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (msg.sticker) {
|
|
127
|
+
return {
|
|
128
|
+
type: 'sticker',
|
|
129
|
+
fileId: msg.sticker.file_id,
|
|
130
|
+
fileSize: msg.sticker.file_size,
|
|
131
|
+
width: msg.sticker.width,
|
|
132
|
+
height: msg.sticker.height,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (msg.document) {
|
|
136
|
+
return {
|
|
137
|
+
type: 'document',
|
|
138
|
+
fileId: msg.document.file_id,
|
|
139
|
+
mimeType: msg.document.mime_type,
|
|
140
|
+
fileName: msg.document.file_name,
|
|
141
|
+
fileSize: msg.document.file_size,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
// Internal helpers
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
function pickLargestPhotoSize(photos) {
|
|
150
|
+
return photos.reduce((a, b) => (a.file_size ?? 0) > (b.file_size ?? 0) ? a : b);
|
|
151
|
+
}
|
|
152
|
+
function pickLargestPhoto(photos) {
|
|
153
|
+
return pickLargestPhotoSize(photos).file_id;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=message-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-resolver.js","sourceRoot":"","sources":["../src/message-resolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,8E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1
|
+
/**
|
|
2
|
+
* Telegram Long-Polling Manager
|
|
3
|
+
* Handles update fetching with exponential backoff and graceful shutdown.
|
|
4
|
+
*/
|
|
5
|
+
import type { TelegramUpdate } from './types';
|
|
6
|
+
import type { TelegramApi } from './api';
|
|
7
|
+
export type UpdateHandler = (update: TelegramUpdate) => Promise<void>;
|
|
8
|
+
export type PollerLogger = {
|
|
9
|
+
info(message: string): void;
|
|
10
|
+
warn(message: string): void;
|
|
11
|
+
error(message: string, err?: unknown): void;
|
|
12
|
+
};
|
|
13
|
+
export declare class TelegramPoller {
|
|
14
|
+
private api;
|
|
15
|
+
private handler;
|
|
16
|
+
private running;
|
|
17
|
+
private offset;
|
|
18
|
+
private pollTimeoutSec;
|
|
19
|
+
private abortController;
|
|
20
|
+
private consecutiveErrors;
|
|
21
|
+
private maxBackoffMs;
|
|
22
|
+
private logger;
|
|
23
|
+
constructor(options: {
|
|
24
|
+
api: TelegramApi;
|
|
25
|
+
handler: UpdateHandler;
|
|
26
|
+
pollTimeoutSec?: number;
|
|
27
|
+
maxBackoffMs?: number;
|
|
28
|
+
logger?: PollerLogger;
|
|
29
|
+
});
|
|
30
|
+
/** Start the polling loop. This method runs until stop() is called. */
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
/** Signal the polling loop to stop. */
|
|
33
|
+
stop(): void;
|
|
34
|
+
/** Whether the poller is currently running. */
|
|
35
|
+
isRunning(): boolean;
|
|
36
|
+
private processUpdate;
|
|
37
|
+
private handlePollingError;
|
|
38
|
+
private sleep;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=poller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poller.d.ts","sourceRoot":"","sources":["../src/poller.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAOzC,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7C,CAAC;AAYF,qBAAa,cAAc;IACzB,OAAO,CAAC,GAAG,CAAc;IACzB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,MAAM,CAAe;gBAEjB,OAAO,EAAE;QACnB,GAAG,EAAE,WAAW,CAAC;QACjB,OAAO,EAAE,aAAa,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,CAAC,EAAE,YAAY,CAAC;KACvB;IAQD,uEAAuE;IACjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B5B,uCAAuC;IACvC,IAAI,IAAI,IAAI;IAMZ,+CAA+C;IAC/C,SAAS,IAAI,OAAO;YAQN,aAAa;YAWb,kBAAkB;IAuBhC,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/poller.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Long-Polling Manager
|
|
3
|
+
* Handles update fetching with exponential backoff and graceful shutdown.
|
|
4
|
+
*/
|
|
5
|
+
import { TelegramApiError } from './api';
|
|
6
|
+
const defaultLogger = {
|
|
7
|
+
info: (msg) => console.log(`[telegram-poller] ${msg}`),
|
|
8
|
+
warn: (msg) => console.warn(`[telegram-poller] ${msg}`),
|
|
9
|
+
error: (msg, err) => console.error(`[telegram-poller] ${msg}`, err ?? ''),
|
|
10
|
+
};
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Poller
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
export class TelegramPoller {
|
|
15
|
+
api;
|
|
16
|
+
handler;
|
|
17
|
+
running = false;
|
|
18
|
+
offset;
|
|
19
|
+
pollTimeoutSec;
|
|
20
|
+
abortController = null;
|
|
21
|
+
consecutiveErrors = 0;
|
|
22
|
+
maxBackoffMs;
|
|
23
|
+
logger;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.api = options.api;
|
|
26
|
+
this.handler = options.handler;
|
|
27
|
+
this.pollTimeoutSec = options.pollTimeoutSec ?? 30;
|
|
28
|
+
this.maxBackoffMs = options.maxBackoffMs ?? 30_000;
|
|
29
|
+
this.logger = options.logger ?? defaultLogger;
|
|
30
|
+
}
|
|
31
|
+
/** Start the polling loop. This method runs until stop() is called. */
|
|
32
|
+
async start() {
|
|
33
|
+
if (this.running)
|
|
34
|
+
return;
|
|
35
|
+
this.running = true;
|
|
36
|
+
this.abortController = new AbortController();
|
|
37
|
+
this.logger.info('Polling started');
|
|
38
|
+
while (this.running) {
|
|
39
|
+
try {
|
|
40
|
+
const updates = await this.api.getUpdates(this.offset, this.pollTimeoutSec, this.abortController?.signal);
|
|
41
|
+
this.consecutiveErrors = 0;
|
|
42
|
+
for (const update of updates) {
|
|
43
|
+
this.offset = update.update_id + 1;
|
|
44
|
+
await this.processUpdate(update);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
if (!this.running)
|
|
49
|
+
break;
|
|
50
|
+
await this.handlePollingError(err);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.logger.info('Polling stopped');
|
|
54
|
+
}
|
|
55
|
+
/** Signal the polling loop to stop. */
|
|
56
|
+
stop() {
|
|
57
|
+
this.running = false;
|
|
58
|
+
this.abortController?.abort();
|
|
59
|
+
this.abortController = null;
|
|
60
|
+
}
|
|
61
|
+
/** Whether the poller is currently running. */
|
|
62
|
+
isRunning() {
|
|
63
|
+
return this.running;
|
|
64
|
+
}
|
|
65
|
+
// -----------------------------------------------------------------------
|
|
66
|
+
// Internal
|
|
67
|
+
// -----------------------------------------------------------------------
|
|
68
|
+
async processUpdate(update) {
|
|
69
|
+
try {
|
|
70
|
+
await this.handler(update);
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
this.logger.error(`Update handler error for update_id=${update.update_id}`, err instanceof Error ? err.message : err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async handlePollingError(err) {
|
|
77
|
+
this.consecutiveErrors++;
|
|
78
|
+
// Telegram rate limit: respect the retry_after value.
|
|
79
|
+
if (err instanceof TelegramApiError && err.retryAfter) {
|
|
80
|
+
const waitMs = err.retryAfter * 1000;
|
|
81
|
+
this.logger.warn(`Rate limited, waiting ${err.retryAfter}s`);
|
|
82
|
+
await this.sleep(waitMs);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Exponential backoff: 1s, 2s, 4s, 8s, ... up to maxBackoffMs.
|
|
86
|
+
const backoffMs = Math.min(1000 * Math.pow(2, this.consecutiveErrors - 1), this.maxBackoffMs);
|
|
87
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
88
|
+
this.logger.error(`Polling error (retry in ${backoffMs}ms): ${errorMessage}`);
|
|
89
|
+
await this.sleep(backoffMs);
|
|
90
|
+
}
|
|
91
|
+
sleep(ms) {
|
|
92
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=poller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../src/poller.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|
|
2
|
+
* Telegram Bot API Type Definitions
|
|
3
|
+
* Covers all message types, media attachments, and API responses.
|
|
4
|
+
*/
|
|
5
|
+
export interface TelegramUser {
|
|
6
|
+
id: number;
|
|
7
|
+
is_bot: boolean;
|
|
8
|
+
first_name: string;
|
|
9
|
+
last_name?: string;
|
|
10
|
+
username?: string;
|
|
11
|
+
language_code?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TelegramChat {
|
|
14
|
+
id: number;
|
|
15
|
+
type: 'private' | 'group' | 'supergroup' | 'channel';
|
|
16
|
+
title?: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
first_name?: string;
|
|
19
|
+
last_name?: string;
|
|
20
|
+
is_forum?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface TelegramPhotoSize {
|
|
23
|
+
file_id: string;
|
|
24
|
+
file_unique_id: string;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
file_size?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TelegramDocument {
|
|
30
|
+
file_id: string;
|
|
31
|
+
file_unique_id: string;
|
|
32
|
+
file_name?: string;
|
|
33
|
+
mime_type?: string;
|
|
34
|
+
file_size?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface TelegramAudio {
|
|
37
|
+
file_id: string;
|
|
38
|
+
file_unique_id: string;
|
|
39
|
+
duration: number;
|
|
40
|
+
performer?: string;
|
|
41
|
+
title?: string;
|
|
42
|
+
mime_type?: string;
|
|
43
|
+
file_size?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface TelegramVideo {
|
|
46
|
+
file_id: string;
|
|
47
|
+
file_unique_id: string;
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
duration: number;
|
|
51
|
+
mime_type?: string;
|
|
52
|
+
file_size?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface TelegramVoice {
|
|
55
|
+
file_id: string;
|
|
56
|
+
file_unique_id: string;
|
|
57
|
+
duration: number;
|
|
58
|
+
mime_type?: string;
|
|
59
|
+
file_size?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface TelegramVideoNote {
|
|
62
|
+
file_id: string;
|
|
63
|
+
file_unique_id: string;
|
|
64
|
+
length: number;
|
|
65
|
+
duration: number;
|
|
66
|
+
file_size?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface TelegramSticker {
|
|
69
|
+
file_id: string;
|
|
70
|
+
file_unique_id: string;
|
|
71
|
+
type: 'regular' | 'mask' | 'custom_emoji';
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
is_animated: boolean;
|
|
75
|
+
is_video: boolean;
|
|
76
|
+
emoji?: string;
|
|
77
|
+
set_name?: string;
|
|
78
|
+
file_size?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface TelegramAnimation {
|
|
81
|
+
file_id: string;
|
|
82
|
+
file_unique_id: string;
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
duration: number;
|
|
86
|
+
mime_type?: string;
|
|
87
|
+
file_size?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface TelegramContact {
|
|
90
|
+
phone_number: string;
|
|
91
|
+
first_name: string;
|
|
92
|
+
last_name?: string;
|
|
93
|
+
user_id?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface TelegramLocation {
|
|
96
|
+
longitude: number;
|
|
97
|
+
latitude: number;
|
|
98
|
+
}
|
|
99
|
+
export interface TelegramMessage {
|
|
100
|
+
message_id: number;
|
|
101
|
+
from?: TelegramUser;
|
|
102
|
+
chat: TelegramChat;
|
|
103
|
+
date: number;
|
|
104
|
+
text?: string;
|
|
105
|
+
caption?: string;
|
|
106
|
+
reply_to_message?: TelegramMessage;
|
|
107
|
+
message_thread_id?: number;
|
|
108
|
+
photo?: TelegramPhotoSize[];
|
|
109
|
+
document?: TelegramDocument;
|
|
110
|
+
audio?: TelegramAudio;
|
|
111
|
+
video?: TelegramVideo;
|
|
112
|
+
voice?: TelegramVoice;
|
|
113
|
+
video_note?: TelegramVideoNote;
|
|
114
|
+
sticker?: TelegramSticker;
|
|
115
|
+
animation?: TelegramAnimation;
|
|
116
|
+
contact?: TelegramContact;
|
|
117
|
+
location?: TelegramLocation;
|
|
118
|
+
forward_date?: number;
|
|
119
|
+
forward_from?: TelegramUser;
|
|
120
|
+
}
|
|
121
|
+
export interface TelegramUpdate {
|
|
122
|
+
update_id: number;
|
|
123
|
+
message?: TelegramMessage;
|
|
124
|
+
edited_message?: TelegramMessage;
|
|
125
|
+
}
|
|
126
|
+
export interface TelegramApiResponse<T> {
|
|
127
|
+
ok: boolean;
|
|
128
|
+
result?: T;
|
|
129
|
+
description?: string;
|
|
130
|
+
error_code?: number;
|
|
131
|
+
parameters?: {
|
|
132
|
+
retry_after?: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface TelegramFileInfo {
|
|
136
|
+
file_id: string;
|
|
137
|
+
file_unique_id: string;
|
|
138
|
+
file_size?: number;
|
|
139
|
+
file_path?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface TelegramBotInfo {
|
|
142
|
+
id: number;
|
|
143
|
+
is_bot: boolean;
|
|
144
|
+
first_name: string;
|
|
145
|
+
username: string;
|
|
146
|
+
}
|
|
147
|
+
export interface TelegramChannelConfig {
|
|
148
|
+
/** Bot token from @BotFather */
|
|
149
|
+
botToken: string;
|
|
150
|
+
/** Allowed user IDs (whitelist). Empty array = allow all. */
|
|
151
|
+
allowedUserIds: number[];
|
|
152
|
+
/** Long-polling timeout in seconds (default: 30) */
|
|
153
|
+
pollTimeoutSec?: number;
|
|
154
|
+
/** Maximum file download size in bytes (default: 20MB) */
|
|
155
|
+
maxFileSize?: number;
|
|
156
|
+
}
|
|
157
|
+
export type ChannelMessageType = 'text' | 'photo' | 'audio' | 'video' | 'voice' | 'video_note' | 'document' | 'sticker' | 'location' | 'contact' | 'animation';
|
|
158
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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,CAAC,CAAC;IACpC,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAMD,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,YAAY,GACZ,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,WAAW,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daemux/telegram-adapter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Telegram Bot API channel adapter for daemux",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@daemux/plugin-sdk": "^0.5.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^22.19.9",
|
|
19
|
+
"typescript": "^5.9.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"daemux": "^0.1.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependenciesMeta": {
|
|
25
|
+
"daemux": {
|
|
26
|
+
"optional": true
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
".claude-plugin"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"daemux",
|
|
35
|
+
"telegram",
|
|
36
|
+
"channel",
|
|
37
|
+
"bot"
|
|
38
|
+
],
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/daemux/daemux-plugins.git",
|
|
46
|
+
"directory": "channels/telegram-adapter"
|
|
47
|
+
}
|
|
48
|
+
}
|