@overpod/mcp-telegram 1.25.0 → 1.26.1
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/CHANGELOG.md +35 -0
- package/README.md +35 -5
- package/dist/index.js +4 -1
- package/dist/rate-limiter.d.ts +9 -3
- package/dist/rate-limiter.js +23 -16
- package/dist/telegram-client.d.ts +134 -18
- package/dist/telegram-client.js +601 -136
- package/dist/telegram-helpers.d.ts +470 -0
- package/dist/telegram-helpers.js +870 -0
- package/dist/tools/account.js +22 -6
- package/dist/tools/boosts.d.ts +3 -0
- package/dist/tools/boosts.js +65 -0
- package/dist/tools/chats.js +155 -5
- package/dist/tools/contacts.js +3 -3
- package/dist/tools/extras.js +3 -3
- package/dist/tools/group-calls.d.ts +4 -0
- package/dist/tools/group-calls.js +77 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/messages.js +203 -11
- package/dist/tools/quick-replies.d.ts +4 -0
- package/dist/tools/quick-replies.js +58 -0
- package/dist/tools/reactions.js +45 -2
- package/dist/tools/shared.d.ts +3 -3
- package/dist/tools/shared.js +8 -7
- package/dist/tools/stars.d.ts +4 -0
- package/dist/tools/stars.js +71 -0
- package/dist/tools/stickers.js +5 -5
- package/dist/tools/stories.d.ts +3 -0
- package/dist/tools/stories.js +107 -0
- package/package.json +1 -1
- package/dist/__tests__/admin-log.test.d.ts +0 -1
- package/dist/__tests__/admin-log.test.js +0 -41
- package/dist/__tests__/rate-limiter.test.d.ts +0 -1
- package/dist/__tests__/rate-limiter.test.js +0 -81
- package/dist/__tests__/reactions.test.d.ts +0 -1
- package/dist/__tests__/reactions.test.js +0 -23
- package/dist/__tests__/set-chat-permissions-merge.test.d.ts +0 -1
- package/dist/__tests__/set-chat-permissions-merge.test.js +0 -107
- package/dist/__tests__/tools/shared.test.d.ts +0 -1
- package/dist/__tests__/tools/shared.test.js +0 -110
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.26.0] - 2026-04-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Phase 2 — Admin Toggles, Customization, Stats (8 tools)**
|
|
12
|
+
- `telegram-toggle-channel-signatures` — toggle post signatures on a channel
|
|
13
|
+
- `telegram-toggle-anti-spam` — toggle native anti-spam in a supergroup (`ban_users` admin)
|
|
14
|
+
- `telegram-toggle-forum-mode` — enable/disable forum mode on a supergroup (disable requires `confirm: true` — destructive, removes all topics)
|
|
15
|
+
- `telegram-approve-join-request` — approve or reject a single chat join request
|
|
16
|
+
- `telegram-toggle-prehistory-hidden` — show/hide pre-history for new supergroup members
|
|
17
|
+
- `telegram-set-chat-reactions` — set allowed reactions on a chat (`all` / `some` / `none`)
|
|
18
|
+
- `telegram-get-broadcast-stats` — channel stats overview (Premium admin may be required; pass `includeGraphs: true` for raw series)
|
|
19
|
+
- `telegram-get-megagroup-stats` — supergroup stats overview (rate-limited by Telegram to ~1 req/30 min per channel)
|
|
20
|
+
- **Phase 3 — Inline Bots, Buttons, Real-Time Updates (7 tools)**
|
|
21
|
+
- `telegram-inline-query` — query an inline bot in a chat context (queryId TTL ≈ 1 min)
|
|
22
|
+
- `telegram-inline-query-send` — send an inline bot result by queryId + result id
|
|
23
|
+
- `telegram-press-button` — press a callback button on a message by row/col or raw data
|
|
24
|
+
- `telegram-get-message-buttons` — list a message's reply-markup buttons with indices and types
|
|
25
|
+
- `telegram-get-state` — initialize a polling cursor (`pts`, `qts`, `date`, `seq`)
|
|
26
|
+
- `telegram-get-updates` — fetch global updates since a known cursor via `updates.GetDifference`; returns `{newMessages, deletedMessageIds, otherUpdates, state, isFinal}` and surfaces `DifferenceTooLong` as a history-fallback hint
|
|
27
|
+
- `telegram-get-channel-updates` — per-channel polling via `updates.GetChannelDifference`
|
|
28
|
+
- Cursors are client-owned (stateless server) — the agent stores `{pts, qts, date}` between calls
|
|
29
|
+
- **Phase 4 ship — Stories, Boosts, Business (8 tools)**
|
|
30
|
+
- `telegram-get-all-stories` — list stories across peers with pagination state
|
|
31
|
+
- `telegram-get-peer-stories` — list stories posted by one peer (compact, media refs only)
|
|
32
|
+
- `telegram-get-stories-by-id` — fetch specific story items by id
|
|
33
|
+
- `telegram-get-story-views` — list views on your own stories (Premium for full stats)
|
|
34
|
+
- `telegram-get-my-boosts` — list boost slots assigned by your account
|
|
35
|
+
- `telegram-get-boosts-status` — boost status for a channel/supergroup
|
|
36
|
+
- `telegram-get-boosts-list` — list boosters for a channel (admin)
|
|
37
|
+
- `telegram-get-business-chat-links` — list your Telegram Business chat links
|
|
38
|
+
- **Phase 4 opt-in (env-gated, 6 tools)** — registered only when the corresponding flag is set:
|
|
39
|
+
- `MCP_TELEGRAM_ENABLE_GROUP_CALLS=1` → `telegram-get-group-call`, `telegram-get-group-call-participants`
|
|
40
|
+
- `MCP_TELEGRAM_ENABLE_STARS=1` → `telegram-get-stars-status`, `telegram-get-stars-transactions`
|
|
41
|
+
- `MCP_TELEGRAM_ENABLE_QUICK_REPLIES=1` → `telegram-get-quick-replies`, `telegram-get-quick-reply-messages`
|
|
42
|
+
|
|
8
43
|
## [1.25.0] - 2026-04-20
|
|
9
44
|
|
|
10
45
|
### Added
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ An MCP (Model Context Protocol) server that connects AI assistants like Claude t
|
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
21
|
-
- **Comprehensive tool coverage** -- the most full-featured Telegram MCP server available
|
|
21
|
+
- **Comprehensive tool coverage** -- the most full-featured Telegram MCP server available (80+ tools)
|
|
22
22
|
- **MTProto protocol** -- direct Telegram API access, not the limited Bot API
|
|
23
23
|
- **Userbot** -- operates as your personal account, not a bot
|
|
24
24
|
- **Full-featured** -- messaging, reactions, polls, scheduled messages, stickers, media, contacts, and more
|
|
@@ -26,6 +26,12 @@ An MCP (Model Context Protocol) server that connects AI assistants like Claude t
|
|
|
26
26
|
- **Stickers** -- search sticker sets, browse installed/recent stickers, send stickers to any chat
|
|
27
27
|
- **Account management** -- update profile, manage privacy settings, sessions, auto-delete timers
|
|
28
28
|
- **Global search** -- search messages across all chats at once
|
|
29
|
+
- **Real-time polling** -- fetch updates via stateless cursors; agent owns `{pts, qts, date}` state
|
|
30
|
+
- **Inline bots & buttons** -- query inline bots, send results, press callback buttons
|
|
31
|
+
- **Stories** -- read stories from peers, get story view stats
|
|
32
|
+
- **Admin controls** -- toggle channel signatures, anti-spam, forum mode, prehistory; approve join requests
|
|
33
|
+
- **Stats** -- channel and supergroup analytics (GetBroadcastStats / GetMegagroupStats)
|
|
34
|
+
- **Boosts & Business** -- boost status, boosters list, Telegram Business chat links
|
|
29
35
|
- **QR code login** -- authenticate by scanning a QR code in the Telegram app
|
|
30
36
|
- **Session persistence** -- login once, stay connected across restarts
|
|
31
37
|
- **Human-readable output** -- sender names are resolved, not just numeric IDs
|
|
@@ -329,9 +335,28 @@ All tools are auto-discoverable via MCP — your AI client will see the full lis
|
|
|
329
335
|
| **Account** | `telegram-get-sessions`, `telegram-terminate-session`, `telegram-set-privacy`, `telegram-set-auto-delete` |
|
|
330
336
|
| **Pinning** | `telegram-pin-message`, `telegram-unpin-message` |
|
|
331
337
|
| **Chat Settings** | `telegram-mute-chat`, `telegram-archive-chat`, `telegram-pin-chat`, `telegram-mark-dialog-unread` |
|
|
338
|
+
| **Admin Toggles** | `telegram-toggle-channel-signatures`, `telegram-toggle-anti-spam`, `telegram-toggle-forum-mode`, `telegram-toggle-prehistory-hidden`, `telegram-set-chat-reactions`, `telegram-approve-join-request` |
|
|
339
|
+
| **Stats** | `telegram-get-broadcast-stats`, `telegram-get-megagroup-stats` |
|
|
340
|
+
| **Inline Bots & Buttons** | `telegram-inline-query`, `telegram-inline-query-send`, `telegram-press-button`, `telegram-get-message-buttons` |
|
|
341
|
+
| **Real-Time Polling** | `telegram-get-state`, `telegram-get-updates`, `telegram-get-channel-updates` |
|
|
342
|
+
| **Stories** | `telegram-get-all-stories`, `telegram-get-peer-stories`, `telegram-get-stories-by-id`, `telegram-get-story-views` |
|
|
343
|
+
| **Boosts & Business** | `telegram-get-my-boosts`, `telegram-get-boosts-status`, `telegram-get-boosts-list`, `telegram-get-business-chat-links` |
|
|
344
|
+
| **Opt-in (env-gated)** | `telegram-get-group-call`, `telegram-get-group-call-participants` (requires `MCP_TELEGRAM_ENABLE_GROUP_CALLS=1`), `telegram-get-stars-status`, `telegram-get-stars-transactions` (requires `MCP_TELEGRAM_ENABLE_STARS=1`), `telegram-get-quick-replies`, `telegram-get-quick-reply-messages` (requires `MCP_TELEGRAM_ENABLE_QUICK_REPLIES=1`) |
|
|
332
345
|
|
|
333
346
|
> **Tip**: Ask your AI assistant *"What Telegram tools are available?"* to get the full list with parameters and descriptions.
|
|
334
347
|
|
|
348
|
+
## Optional Features
|
|
349
|
+
|
|
350
|
+
Some tools are disabled by default and must be opted in via environment variables:
|
|
351
|
+
|
|
352
|
+
| Variable | Value | Tools enabled |
|
|
353
|
+
|----------|-------|---------------|
|
|
354
|
+
| `MCP_TELEGRAM_ENABLE_GROUP_CALLS` | `1` | `telegram-get-group-call`, `telegram-get-group-call-participants` |
|
|
355
|
+
| `MCP_TELEGRAM_ENABLE_STARS` | `1` | `telegram-get-stars-status`, `telegram-get-stars-transactions` |
|
|
356
|
+
| `MCP_TELEGRAM_ENABLE_QUICK_REPLIES` | `1` | `telegram-get-quick-replies`, `telegram-get-quick-reply-messages` |
|
|
357
|
+
|
|
358
|
+
Add these to your `.env` file or MCP client config to enable them.
|
|
359
|
+
|
|
335
360
|
## Development
|
|
336
361
|
|
|
337
362
|
```bash
|
|
@@ -353,14 +378,19 @@ src/
|
|
|
353
378
|
qr-login-cli.ts -- CLI utility for QR code login
|
|
354
379
|
tools/ -- Modular tool definitions
|
|
355
380
|
auth.ts -- Connection & login
|
|
356
|
-
messages.ts -- Send, read, search, edit, delete, forward
|
|
357
|
-
chats.ts -- Chat listing, group management, admin
|
|
381
|
+
messages.ts -- Send, read, search, edit, delete, forward; inline bots; real-time polling
|
|
382
|
+
chats.ts -- Chat listing, group management, admin toggles, stats
|
|
358
383
|
contacts.ts -- Contacts, profiles, moderation
|
|
359
384
|
media.ts -- Files, photos, downloads
|
|
360
|
-
reactions.ts -- Reactions
|
|
385
|
+
reactions.ts -- Reactions, set-chat-reactions
|
|
361
386
|
extras.ts -- Pin, schedule, polls, topics
|
|
362
387
|
stickers.ts -- Sticker sets, send, search, browse
|
|
363
|
-
account.ts -- Sessions, privacy, auto-delete, profile, chat mute/folders, invite links
|
|
388
|
+
account.ts -- Sessions, privacy, auto-delete, profile, chat mute/folders, invite links, business chat links
|
|
389
|
+
boosts.ts -- Boost status, my boosts, boosters list
|
|
390
|
+
stories.ts -- Stories: list all, peer, by-id, view stats
|
|
391
|
+
group-calls.ts -- Group call info and participants (opt-in: MCP_TELEGRAM_ENABLE_GROUP_CALLS)
|
|
392
|
+
stars.ts -- Stars wallet status and transactions (opt-in: MCP_TELEGRAM_ENABLE_STARS)
|
|
393
|
+
quick-replies.ts -- Quick replies and messages (opt-in: MCP_TELEGRAM_ENABLE_QUICK_REPLIES)
|
|
364
394
|
shared.ts -- Shared utilities
|
|
365
395
|
```
|
|
366
396
|
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,13 @@ console.log = (...args) => {
|
|
|
6
6
|
console.error(...args);
|
|
7
7
|
};
|
|
8
8
|
import "dotenv/config";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
9
10
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
11
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
12
|
import { TelegramService } from "./telegram-client.js";
|
|
12
13
|
import { registerTools } from "./tools/index.js";
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const { version } = require("../package.json");
|
|
13
16
|
// Telegram API credentials from env
|
|
14
17
|
const API_ID = Number(process.env.TELEGRAM_API_ID);
|
|
15
18
|
const API_HASH = process.env.TELEGRAM_API_HASH;
|
|
@@ -22,7 +25,7 @@ if (!API_ID || !API_HASH) {
|
|
|
22
25
|
const telegram = new TelegramService(API_ID, API_HASH);
|
|
23
26
|
const server = new McpServer({
|
|
24
27
|
name: "mcp-telegram",
|
|
25
|
-
version
|
|
28
|
+
version,
|
|
26
29
|
});
|
|
27
30
|
registerTools(server, telegram);
|
|
28
31
|
async function main() {
|
package/dist/rate-limiter.d.ts
CHANGED
|
@@ -13,14 +13,20 @@ export interface RateLimiterOptions {
|
|
|
13
13
|
maxRetryDelay?: number;
|
|
14
14
|
}
|
|
15
15
|
export declare class RateLimiter {
|
|
16
|
-
private lastRequestTime;
|
|
17
16
|
private minInterval;
|
|
18
17
|
private maxRetries;
|
|
19
18
|
private initialRetryDelay;
|
|
20
19
|
private maxRetryDelay;
|
|
20
|
+
private slotQueue;
|
|
21
21
|
constructor(options?: RateLimiterOptions);
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Execute a function with rate limiting and automatic retry.
|
|
24
|
+
* @param throwOnFloodWait If true, throw immediately on FLOOD_WAIT instead of sleeping (use for
|
|
25
|
+
* endpoints with very long rate-limit windows like stats APIs).
|
|
26
|
+
*/
|
|
27
|
+
execute<T>(fn: () => Promise<T>, context?: string, options?: {
|
|
28
|
+
throwOnFloodWait?: boolean;
|
|
29
|
+
}): Promise<T>;
|
|
24
30
|
private executeWithRetry;
|
|
25
31
|
private waitForSlot;
|
|
26
32
|
}
|
package/dist/rate-limiter.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Handles FLOOD_WAIT errors and implements exponential backoff.
|
|
4
4
|
*/
|
|
5
5
|
export class RateLimiter {
|
|
6
|
-
lastRequestTime = 0;
|
|
7
6
|
minInterval;
|
|
8
7
|
maxRetries;
|
|
9
8
|
initialRetryDelay;
|
|
10
9
|
maxRetryDelay;
|
|
10
|
+
// Serializes concurrent calls so each waits for the previous slot to clear
|
|
11
|
+
slotQueue = Promise.resolve();
|
|
11
12
|
constructor(options = {}) {
|
|
12
13
|
const maxRequestsPerSecond = options.maxRequestsPerSecond ?? 20;
|
|
13
14
|
this.minInterval = 1000 / maxRequestsPerSecond;
|
|
@@ -15,27 +16,34 @@ export class RateLimiter {
|
|
|
15
16
|
this.initialRetryDelay = options.initialRetryDelay ?? 1000;
|
|
16
17
|
this.maxRetryDelay = options.maxRetryDelay ?? 60000;
|
|
17
18
|
}
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Execute a function with rate limiting and automatic retry.
|
|
21
|
+
* @param throwOnFloodWait If true, throw immediately on FLOOD_WAIT instead of sleeping (use for
|
|
22
|
+
* endpoints with very long rate-limit windows like stats APIs).
|
|
23
|
+
*/
|
|
24
|
+
async execute(fn, context = "API call", options) {
|
|
25
|
+
return this.executeWithRetry(fn, context, 0, options);
|
|
21
26
|
}
|
|
22
|
-
async executeWithRetry(fn, context, attempt) {
|
|
27
|
+
async executeWithRetry(fn, context, attempt, options) {
|
|
23
28
|
await this.waitForSlot();
|
|
24
29
|
try {
|
|
25
30
|
return await fn();
|
|
26
31
|
}
|
|
27
32
|
catch (error) {
|
|
28
33
|
const errorMessage = error.errorMessage || error.message || String(error);
|
|
29
|
-
// FLOOD_WAIT — wait the exact time Telegram requires
|
|
34
|
+
// FLOOD_WAIT — wait the exact time Telegram requires (or throw immediately if requested)
|
|
30
35
|
const floodMatch = errorMessage.match(/FLOOD_WAIT[_]?(\d+)/i);
|
|
31
36
|
if (floodMatch) {
|
|
32
37
|
const waitSeconds = Number.parseInt(floodMatch[1], 10);
|
|
38
|
+
if (options?.throwOnFloodWait) {
|
|
39
|
+
throw new Error(`Rate limit: Telegram requires a ${waitSeconds}s wait for ${context}. Try again in ${Math.ceil(waitSeconds / 60)} minute(s).`);
|
|
40
|
+
}
|
|
33
41
|
if (attempt >= this.maxRetries) {
|
|
34
42
|
throw new Error(`Rate limit exceeded after ${this.maxRetries} retries. Telegram requires ${waitSeconds}s wait. Try again later.`);
|
|
35
43
|
}
|
|
36
44
|
console.error(`[rate-limiter] FLOOD_WAIT for ${context}. Waiting ${waitSeconds}s (attempt ${attempt + 1}/${this.maxRetries})`);
|
|
37
45
|
await sleep(waitSeconds * 1000);
|
|
38
|
-
return this.executeWithRetry(fn, context, attempt + 1);
|
|
46
|
+
return this.executeWithRetry(fn, context, attempt + 1, options);
|
|
39
47
|
}
|
|
40
48
|
// Network/timeout errors — exponential backoff
|
|
41
49
|
if (isNetworkError(errorMessage)) {
|
|
@@ -45,7 +53,7 @@ export class RateLimiter {
|
|
|
45
53
|
const delay = Math.min(this.initialRetryDelay * 2 ** attempt, this.maxRetryDelay);
|
|
46
54
|
console.error(`[rate-limiter] Network error for ${context}. Retrying in ${delay}ms (attempt ${attempt + 1}/${this.maxRetries})`);
|
|
47
55
|
await sleep(delay);
|
|
48
|
-
return this.executeWithRetry(fn, context, attempt + 1);
|
|
56
|
+
return this.executeWithRetry(fn, context, attempt + 1, options);
|
|
49
57
|
}
|
|
50
58
|
// Temporary server errors (5xx) — exponential backoff
|
|
51
59
|
if (isTemporaryError(errorMessage)) {
|
|
@@ -54,19 +62,18 @@ export class RateLimiter {
|
|
|
54
62
|
}
|
|
55
63
|
const delay = Math.min(this.initialRetryDelay * 2 ** attempt, this.maxRetryDelay);
|
|
56
64
|
await sleep(delay);
|
|
57
|
-
return this.executeWithRetry(fn, context, attempt + 1);
|
|
65
|
+
return this.executeWithRetry(fn, context, attempt + 1, options);
|
|
58
66
|
}
|
|
59
67
|
// Non-retryable — throw immediately
|
|
60
68
|
throw error;
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.lastRequestTime = Date.now();
|
|
71
|
+
waitForSlot() {
|
|
72
|
+
// Chain onto the previous slot so concurrent callers queue up sequentially.
|
|
73
|
+
// Each turn: wait minInterval from when the previous turn started, then resolve.
|
|
74
|
+
const nextSlot = this.slotQueue.then(() => sleep(this.minInterval));
|
|
75
|
+
this.slotQueue = nextSlot;
|
|
76
|
+
return nextSlot;
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
function isNetworkError(msg) {
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import bigInt from "big-integer";
|
|
2
1
|
import { TelegramClient } from "telegram";
|
|
3
2
|
import { Api } from "telegram/tl/index.js";
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export type
|
|
8
|
-
sendMessages?: boolean;
|
|
9
|
-
sendMedia?: boolean;
|
|
10
|
-
sendStickers?: boolean;
|
|
11
|
-
sendGifs?: boolean;
|
|
12
|
-
sendPolls?: boolean;
|
|
13
|
-
sendInline?: boolean;
|
|
14
|
-
embedLinks?: boolean;
|
|
15
|
-
changeInfo?: boolean;
|
|
16
|
-
inviteUsers?: boolean;
|
|
17
|
-
pinMessages?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare function mergeBannedRights(current: Record<string, unknown> | undefined | null, permissions: ChatPermissions): Record<string, boolean>;
|
|
3
|
+
import type { AllStoriesSummary, BoostsListSummary, BoostsStatusSummary, BroadcastStatsSummary, BusinessChatLinksSummary, ChannelDifferenceSummary, ChatPermissions, GroupCallParticipantsSummary, GroupCallSummary, MegagroupStatsSummary, MessageButtonDescriptor, MyBoostsSummary, PeerStoriesSummary, QuickRepliesSummary, QuickReplyMessagesSummary, StarsStatusSummary, StoriesByIdSummary, StoryViewsListSummary, UpdatesDifferenceSummary } from "./telegram-helpers.js";
|
|
4
|
+
export type { AllStoriesSummary, BoostSummary, BoostsListSummary, BoostsStatusSummary, BroadcastStatsSummary, BusinessChatLinkSummary, BusinessChatLinksSummary, ChannelDifferenceSummary, ChatPermissions, CompactPeer, CompactStatsGraph, GroupCallInfoSummary, GroupCallParticipantSummary, GroupCallParticipantsSummary, GroupCallSummary, MegagroupStatsSummary, MessageButtonDescriptor, MyBoostSummary, MyBoostsSummary, PeerStoriesSummary, PrepaidGiveawaySummary, QuickRepliesSummary, QuickReplyMessageSummary, QuickReplyMessagesSummary, QuickReplySummary, StarsAmountSummary, StarsStatusSummary, StarsSubscriptionPricingSummary, StarsSubscriptionSummary, StarsTransactionPeerSummary, StarsTransactionSummary, StatsValue, StoriesByIdSummary, StoryItemSummary, StoryViewSummary, StoryViewsListSummary, UpdatesDifferenceSummary, UpdatesMessageSummary, } from "./telegram-helpers.js";
|
|
5
|
+
export { describeAdminLogAction, describeAdminLogDetails, describeKeyboardButton, mergeBannedRights, peerToCompact, reactionToEmoji, summarizeAllStories, summarizeBoost, summarizeBoostsList, summarizeBoostsStatus, summarizeBroadcastStats, summarizeBusinessChatLink, summarizeBusinessChatLinks, summarizeChannelDifference, summarizeGroupCall, summarizeGroupCallInfo, summarizeGroupCallParticipant, summarizeGroupCallParticipants, summarizeMegagroupStats, summarizeMyBoost, summarizeMyBoosts, summarizePeerStories, summarizePrepaidGiveaway, summarizeQuickReplies, summarizeQuickReply, summarizeQuickReplyMessage, summarizeQuickReplyMessages, summarizeStarsAmount, summarizeStarsStatus, summarizeStarsSubscription, summarizeStarsTransaction, summarizeStarsTransactionPeer, summarizeStoriesById, summarizeStoryItem, summarizeStoryView, summarizeStoryViewsList, summarizeUpdatesDifference, } from "./telegram-helpers.js";
|
|
6
|
+
export type ChatEntity = Api.User | Api.Chat | Api.Channel | Api.TypeUser | Api.TypeChat;
|
|
20
7
|
export declare class TelegramService {
|
|
21
8
|
private client;
|
|
22
9
|
private apiId;
|
|
@@ -26,6 +13,7 @@ export declare class TelegramService {
|
|
|
26
13
|
private sessionPath;
|
|
27
14
|
private rateLimiter;
|
|
28
15
|
private lastTypingAt;
|
|
16
|
+
private entityCache;
|
|
29
17
|
lastError: string;
|
|
30
18
|
get sessionDir(): string;
|
|
31
19
|
getClient(): TelegramClient | null;
|
|
@@ -190,7 +178,7 @@ export declare class TelegramService {
|
|
|
190
178
|
* Resolve a chat by ID, username, or display name.
|
|
191
179
|
* Falls back to searching user's dialogs if getEntity() fails.
|
|
192
180
|
*/
|
|
193
|
-
resolveChat(chatId: string): Promise<
|
|
181
|
+
resolveChat(chatId: string): Promise<ChatEntity>;
|
|
194
182
|
/**
|
|
195
183
|
* Resolve chatId to a peer string that GramJS methods accept.
|
|
196
184
|
* Handles display names by searching dialogs.
|
|
@@ -425,6 +413,86 @@ export declare class TelegramService {
|
|
|
425
413
|
}>>;
|
|
426
414
|
setChatPermissions(chatId: string, permissions: ChatPermissions): Promise<void>;
|
|
427
415
|
setSlowMode(chatId: string, seconds: number): Promise<void>;
|
|
416
|
+
toggleChannelSignatures(chatId: string, enabled: boolean): Promise<void>;
|
|
417
|
+
toggleAntiSpam(chatId: string, enabled: boolean): Promise<void>;
|
|
418
|
+
toggleForumMode(chatId: string, enabled: boolean): Promise<void>;
|
|
419
|
+
togglePrehistoryHidden(chatId: string, hidden: boolean): Promise<void>;
|
|
420
|
+
setChatAvailableReactions(chatId: string, reactions: {
|
|
421
|
+
type: "all";
|
|
422
|
+
allowCustom?: boolean;
|
|
423
|
+
} | {
|
|
424
|
+
type: "some";
|
|
425
|
+
emoji: string[];
|
|
426
|
+
} | {
|
|
427
|
+
type: "none";
|
|
428
|
+
}): Promise<void>;
|
|
429
|
+
approveChatJoinRequest(chatId: string, userId: string, approved: boolean): Promise<void>;
|
|
430
|
+
getInlineBotResults(bot: string, chatId: string, query: string, offset?: string): Promise<{
|
|
431
|
+
queryId: string;
|
|
432
|
+
nextOffset?: string;
|
|
433
|
+
cacheTime: number;
|
|
434
|
+
gallery: boolean;
|
|
435
|
+
results: Array<{
|
|
436
|
+
id: string;
|
|
437
|
+
type: string;
|
|
438
|
+
title?: string;
|
|
439
|
+
description?: string;
|
|
440
|
+
url?: string;
|
|
441
|
+
}>;
|
|
442
|
+
}>;
|
|
443
|
+
sendInlineBotResult(chatId: string, queryId: string, resultId: string, options?: {
|
|
444
|
+
replyTo?: number;
|
|
445
|
+
silent?: boolean;
|
|
446
|
+
hideVia?: boolean;
|
|
447
|
+
clearDraft?: boolean;
|
|
448
|
+
}): Promise<{
|
|
449
|
+
messageId: number;
|
|
450
|
+
}>;
|
|
451
|
+
pressButton(chatId: string, messageId: number, options: {
|
|
452
|
+
buttonIndex?: {
|
|
453
|
+
row: number;
|
|
454
|
+
column: number;
|
|
455
|
+
};
|
|
456
|
+
data?: string;
|
|
457
|
+
}): Promise<{
|
|
458
|
+
alert?: boolean;
|
|
459
|
+
hasUrl?: boolean;
|
|
460
|
+
nativeUi?: boolean;
|
|
461
|
+
message?: string;
|
|
462
|
+
url?: string;
|
|
463
|
+
cacheTime: number;
|
|
464
|
+
}>;
|
|
465
|
+
getMessageButtons(chatId: string, messageId: number): Promise<{
|
|
466
|
+
markupType: string;
|
|
467
|
+
buttons: MessageButtonDescriptor[];
|
|
468
|
+
}>;
|
|
469
|
+
getBroadcastStats(chatId: string, options?: {
|
|
470
|
+
dark?: boolean;
|
|
471
|
+
includeGraphs?: boolean;
|
|
472
|
+
}): Promise<BroadcastStatsSummary>;
|
|
473
|
+
getMegagroupStats(chatId: string, options?: {
|
|
474
|
+
dark?: boolean;
|
|
475
|
+
includeGraphs?: boolean;
|
|
476
|
+
}): Promise<MegagroupStatsSummary>;
|
|
477
|
+
getUpdatesState(): Promise<{
|
|
478
|
+
pts: number;
|
|
479
|
+
qts: number;
|
|
480
|
+
date: number;
|
|
481
|
+
seq: number;
|
|
482
|
+
unreadCount: number;
|
|
483
|
+
}>;
|
|
484
|
+
getUpdates(cursor: {
|
|
485
|
+
pts: number;
|
|
486
|
+
date: number;
|
|
487
|
+
qts: number;
|
|
488
|
+
ptsLimit?: number;
|
|
489
|
+
ptsTotalLimit?: number;
|
|
490
|
+
}): Promise<UpdatesDifferenceSummary>;
|
|
491
|
+
getChannelUpdates(chatId: string, cursor: {
|
|
492
|
+
pts: number;
|
|
493
|
+
limit?: number;
|
|
494
|
+
force?: boolean;
|
|
495
|
+
}): Promise<ChannelDifferenceSummary>;
|
|
428
496
|
createForumTopic(chatId: string, title: string, iconColor?: number, iconEmojiId?: string): Promise<{
|
|
429
497
|
id: number;
|
|
430
498
|
title: string;
|
|
@@ -525,4 +593,52 @@ export declare class TelegramService {
|
|
|
525
593
|
accessHash: string;
|
|
526
594
|
emoji: string;
|
|
527
595
|
}>>;
|
|
596
|
+
getAllStories(options?: {
|
|
597
|
+
next?: boolean;
|
|
598
|
+
hidden?: boolean;
|
|
599
|
+
state?: string;
|
|
600
|
+
}): Promise<AllStoriesSummary>;
|
|
601
|
+
getPeerStories(chatId: string): Promise<PeerStoriesSummary | null>;
|
|
602
|
+
getStoriesById(chatId: string, ids: number[]): Promise<StoriesByIdSummary>;
|
|
603
|
+
getStoryViewsList(chatId: string, options: {
|
|
604
|
+
id: number;
|
|
605
|
+
q?: string;
|
|
606
|
+
justContacts?: boolean;
|
|
607
|
+
reactionsFirst?: boolean;
|
|
608
|
+
forwardsFirst?: boolean;
|
|
609
|
+
offset?: string;
|
|
610
|
+
limit?: number;
|
|
611
|
+
}): Promise<StoryViewsListSummary>;
|
|
612
|
+
getMyBoosts(): Promise<MyBoostsSummary>;
|
|
613
|
+
getBoostsStatus(chatId: string): Promise<BoostsStatusSummary>;
|
|
614
|
+
getBoostsList(chatId: string, options?: {
|
|
615
|
+
gifts?: boolean;
|
|
616
|
+
offset?: string;
|
|
617
|
+
limit?: number;
|
|
618
|
+
}): Promise<BoostsListSummary>;
|
|
619
|
+
getBusinessChatLinks(): Promise<BusinessChatLinksSummary>;
|
|
620
|
+
getGroupCall(chatId: string, options?: {
|
|
621
|
+
limit?: number;
|
|
622
|
+
}): Promise<GroupCallSummary>;
|
|
623
|
+
getGroupCallParticipants(chatId: string, options?: {
|
|
624
|
+
ids?: string[];
|
|
625
|
+
sources?: number[];
|
|
626
|
+
offset?: string;
|
|
627
|
+
limit?: number;
|
|
628
|
+
}): Promise<GroupCallParticipantsSummary>;
|
|
629
|
+
getStarsStatus(chatId: string): Promise<StarsStatusSummary>;
|
|
630
|
+
getStarsTransactions(chatId: string, options?: {
|
|
631
|
+
inbound?: boolean;
|
|
632
|
+
outbound?: boolean;
|
|
633
|
+
ascending?: boolean;
|
|
634
|
+
subscriptionId?: string;
|
|
635
|
+
offset?: string;
|
|
636
|
+
limit?: number;
|
|
637
|
+
}): Promise<StarsStatusSummary>;
|
|
638
|
+
getQuickReplies(hash?: string): Promise<QuickRepliesSummary>;
|
|
639
|
+
getQuickReplyMessages(shortcutId: number, options?: {
|
|
640
|
+
ids?: number[];
|
|
641
|
+
hash?: string;
|
|
642
|
+
}): Promise<QuickReplyMessagesSummary>;
|
|
643
|
+
private resolveInputGroupCall;
|
|
528
644
|
}
|