@zhin.js/adapter-telegram 1.0.69 → 1.1.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +909 -17
  2. package/PERMITS.md +24 -0
  3. package/README.md +106 -77
  4. package/adapters/telegram/index.js +34 -0
  5. package/adapters/telegram/index.ts +39 -0
  6. package/agents/telegram/agent.json +20 -0
  7. package/agents/telegram/boundaries.md +3 -0
  8. package/agents/telegram/conventions.md +3 -0
  9. package/agents/telegram/skills/telegram-chat-admin/SKILL.md +24 -0
  10. package/agents/telegram/skills/telegram-chat-admin/tools/create_invite/index.js +18 -0
  11. package/agents/telegram/skills/telegram-chat-admin/tools/create_invite/index.ts +18 -0
  12. package/agents/telegram/skills/telegram-chat-admin/tools/list_admins/index.js +24 -0
  13. package/agents/telegram/skills/telegram-chat-admin/tools/list_admins/index.ts +24 -0
  14. package/agents/telegram/skills/telegram-chat-admin/tools/member_count/index.js +16 -0
  15. package/agents/telegram/skills/telegram-chat-admin/tools/member_count/index.ts +16 -0
  16. package/agents/telegram/skills/telegram-chat-admin/tools/pin_message/index.js +19 -0
  17. package/agents/telegram/skills/telegram-chat-admin/tools/pin_message/index.ts +19 -0
  18. package/agents/telegram/skills/telegram-chat-admin/tools/set_description/index.js +17 -0
  19. package/agents/telegram/skills/telegram-chat-admin/tools/set_description/index.ts +17 -0
  20. package/agents/telegram/skills/telegram-chat-admin/tools/set_permissions/index.js +32 -0
  21. package/agents/telegram/skills/telegram-chat-admin/tools/set_permissions/index.ts +31 -0
  22. package/agents/telegram/skills/telegram-chat-admin/tools/unpin_message/index.js +19 -0
  23. package/agents/telegram/skills/telegram-chat-admin/tools/unpin_message/index.ts +19 -0
  24. package/agents/telegram/skills/telegram-messages/SKILL.md +19 -0
  25. package/agents/telegram/skills/telegram-messages/tools/react/index.js +18 -0
  26. package/agents/telegram/skills/telegram-messages/tools/react/index.ts +18 -0
  27. package/agents/telegram/skills/telegram-messages/tools/send_poll/index.js +30 -0
  28. package/agents/telegram/skills/telegram-messages/tools/send_poll/index.ts +32 -0
  29. package/agents/telegram/skills/telegram-messages/tools/send_sticker/index.js +17 -0
  30. package/agents/telegram/skills/telegram-messages/tools/send_sticker/index.ts +17 -0
  31. package/agents/telegram/system.md +3 -0
  32. package/commands/telegram/endpoint/add/[id]/index.js +3 -0
  33. package/commands/telegram/endpoint/add/[id]/index.ts +3 -0
  34. package/commands/telegram/endpoint/definition.js +17 -0
  35. package/commands/telegram/endpoint/definition.ts +17 -0
  36. package/commands/telegram/endpoint/list/index.js +3 -0
  37. package/commands/telegram/endpoint/list/index.ts +3 -0
  38. package/commands/telegram/endpoint/remove/[id]/index.js +3 -0
  39. package/commands/telegram/endpoint/remove/[id]/index.ts +3 -0
  40. package/lib/client.d.ts +12 -0
  41. package/lib/client.js +2 -0
  42. package/lib/endpoint.d.ts +112 -0
  43. package/lib/endpoint.js +535 -0
  44. package/lib/index.d.ts +4 -18
  45. package/lib/index.js +4 -455
  46. package/lib/markdown-to-html.d.ts +9 -0
  47. package/lib/markdown-to-html.js +75 -0
  48. package/lib/platform-permit.d.ts +17 -0
  49. package/lib/platform-permit.js +51 -0
  50. package/lib/polling.d.ts +9 -0
  51. package/lib/polling.js +57 -0
  52. package/lib/protocol.d.ts +291 -0
  53. package/lib/protocol.js +463 -0
  54. package/lib/telegram-runtime-state.d.ts +1 -0
  55. package/lib/telegram-runtime-state.js +6 -0
  56. package/lib/webhook.d.ts +12 -0
  57. package/lib/webhook.js +55 -0
  58. package/package.json +72 -29
  59. package/plugin.js +19 -0
  60. package/schema.json +141 -0
  61. package/src/client.ts +16 -0
  62. package/src/endpoint.ts +679 -0
  63. package/src/index.ts +39 -426
  64. package/src/markdown-to-html.ts +86 -0
  65. package/src/platform-permit.ts +65 -0
  66. package/src/polling.ts +76 -0
  67. package/src/protocol.ts +744 -0
  68. package/src/telegram-runtime-state.ts +7 -0
  69. package/src/webhook.ts +75 -0
  70. package/client/Dashboard.tsx +0 -295
  71. package/client/index.tsx +0 -11
  72. package/client/tsconfig.json +0 -7
  73. package/client/utils/api.ts +0 -17
  74. package/dist/index.js +0 -32
  75. package/lib/adapter.d.ts +0 -18
  76. package/lib/adapter.d.ts.map +0 -1
  77. package/lib/adapter.js +0 -55
  78. package/lib/adapter.js.map +0 -1
  79. package/lib/bot.d.ts +0 -140
  80. package/lib/bot.d.ts.map +0 -1
  81. package/lib/bot.js +0 -866
  82. package/lib/bot.js.map +0 -1
  83. package/lib/index.d.ts.map +0 -1
  84. package/lib/index.js.map +0 -1
  85. package/lib/types.d.ts +0 -29
  86. package/lib/types.d.ts.map +0 -1
  87. package/lib/types.js +0 -2
  88. package/lib/types.js.map +0 -1
  89. package/plugin.yml +0 -3
  90. package/skills/telegram/SKILL.md +0 -103
  91. package/src/adapter.ts +0 -64
  92. package/src/bot.ts +0 -983
  93. package/src/types.ts +0 -32
@@ -0,0 +1,19 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ import { platformPermission } from '@zhin.js/permission';
5
+ export default defineAgentTool({
6
+ description: '取消置顶 Telegram 群组消息',
7
+ inputSchema: z.object({
8
+ chat_id: z.string().describe('聊天 ID'),
9
+ message_id: z.string().optional().describe('消息 ID(可选,不提供则取消所有置顶)'),
10
+ }),
11
+ adapter: 'telegram',
12
+ tags: ['telegram'],
13
+ permissions: [platformPermission('telegram', 'pin_messages')],
14
+ async execute({ chat_id, message_id }, context) {
15
+ const endpoint = context.$client;
16
+ const success = await endpoint.unpinMessage(Number(chat_id), message_id ? Number(message_id) : undefined);
17
+ return { success, message: success ? '已取消置顶' : '操作失败' };
18
+ },
19
+ });
@@ -0,0 +1,19 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+ import { platformPermission } from '@zhin.js/permission';
4
+
5
+ export default defineAgentTool<{ chat_id: string; message_id?: string }>({
6
+ description: '取消置顶 Telegram 群组消息',
7
+ inputSchema: z.object({
8
+ chat_id: z.string().describe('聊天 ID'),
9
+ message_id: z.string().optional().describe('消息 ID(可选,不提供则取消所有置顶)'),
10
+ }),
11
+ adapter: 'telegram',
12
+ tags: ['telegram'],
13
+ permissions: [platformPermission('telegram', 'pin_messages')],
14
+ async execute({ chat_id, message_id }: { chat_id: string; message_id?: string }, context) {
15
+ const endpoint = context.$client;
16
+ const success = await endpoint.unpinMessage(Number(chat_id), message_id ? Number(message_id) : undefined);
17
+ return { success, message: success ? '已取消置顶' : '操作失败' };
18
+ },
19
+ });
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: telegram-messages
3
+ platforms:
4
+ - telegram
5
+ description: Telegram 投票、reaction 和贴纸消息能力。
6
+ keywords:
7
+ - "telegram"
8
+ - "poll"
9
+ - "reaction"
10
+ - "sticker"
11
+ tools:
12
+ - "send_poll"
13
+ - "react"
14
+ - "send_sticker"
15
+ ---
16
+
17
+ # telegram-messages
18
+
19
+ 用于消息互动。确认聊天和目标消息后调用,避免重复发送。
@@ -0,0 +1,18 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ export default defineAgentTool({
5
+ description: '对 Telegram 消息添加表情反应',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ message_id: z.string().describe('消息 ID'),
9
+ reaction: z.string().describe('反应表情(如 👍、❤️、🔥)'),
10
+ }),
11
+ adapter: 'telegram',
12
+ tags: ['telegram'],
13
+ async execute({ chat_id, message_id, reaction }, context) {
14
+ const endpoint = context.$client;
15
+ const success = await endpoint.setMessageReaction(Number(chat_id), Number(message_id), reaction);
16
+ return { success, message: success ? `已添加反应 ${reaction}` : '操作失败' };
17
+ },
18
+ });
@@ -0,0 +1,18 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+
4
+ export default defineAgentTool<{ chat_id: string; message_id: string; reaction: string }>({
5
+ description: '对 Telegram 消息添加表情反应',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ message_id: z.string().describe('消息 ID'),
9
+ reaction: z.string().describe('反应表情(如 👍、❤️、🔥)'),
10
+ }),
11
+ adapter: 'telegram',
12
+ tags: ['telegram'],
13
+ async execute({ chat_id, message_id, reaction }: { chat_id: string; message_id: string; reaction: string }, context) {
14
+ const endpoint = context.$client;
15
+ const success = await endpoint.setMessageReaction(Number(chat_id), Number(message_id), reaction);
16
+ return { success, message: success ? `已添加反应 ${reaction}` : '操作失败' };
17
+ },
18
+ });
@@ -0,0 +1,30 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ export default defineAgentTool({
5
+ description: '在 Telegram 群组中发起投票',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ question: z.string().describe('投票问题'),
9
+ options: z.string().describe('选项 JSON 数组,如 ["A","B","C"]'),
10
+ is_anonymous: z.boolean().optional().describe('是否匿名投票,默认 true'),
11
+ allows_multiple: z.boolean().optional().describe('是否允许多选,默认 false'),
12
+ }),
13
+ adapter: 'telegram',
14
+ tags: ['telegram'],
15
+ async execute({ chat_id, question, options, is_anonymous, allows_multiple }, context) {
16
+ const endpoint = context.$client;
17
+ let optList;
18
+ try {
19
+ optList = JSON.parse(options);
20
+ }
21
+ catch {
22
+ return { success: false, message: 'options 格式错误,应为 JSON 数组' };
23
+ }
24
+ if (!Array.isArray(optList) || optList.length < 2) {
25
+ return { success: false, message: '至少需要 2 个选项' };
26
+ }
27
+ const result = await endpoint.sendPoll(Number(chat_id), question, optList, is_anonymous ?? true, allows_multiple ?? false);
28
+ return { success: true, message_id: result.message_id, message: '投票已发送' };
29
+ },
30
+ });
@@ -0,0 +1,32 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+
4
+ export default defineAgentTool<{ chat_id: string; question: string; options: string; is_anonymous?: boolean; allows_multiple?: boolean }>({
5
+ description: '在 Telegram 群组中发起投票',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ question: z.string().describe('投票问题'),
9
+ options: z.string().describe('选项 JSON 数组,如 ["A","B","C"]'),
10
+ is_anonymous: z.boolean().optional().describe('是否匿名投票,默认 true'),
11
+ allows_multiple: z.boolean().optional().describe('是否允许多选,默认 false'),
12
+ }),
13
+ adapter: 'telegram',
14
+ tags: ['telegram'],
15
+ async execute({ chat_id, question, options, is_anonymous, allows_multiple }: { chat_id: string; question: string; options: string; is_anonymous?: boolean; allows_multiple?: boolean }, context) {
16
+ const endpoint = context.$client;
17
+ let optList: string[];
18
+ try {
19
+ optList = JSON.parse(options);
20
+ } catch {
21
+ return { success: false, message: 'options 格式错误,应为 JSON 数组' };
22
+ }
23
+ if (!Array.isArray(optList) || optList.length < 2) {
24
+ return { success: false, message: '至少需要 2 个选项' };
25
+ }
26
+ const result = await endpoint.sendPoll(
27
+ Number(chat_id), question, optList,
28
+ is_anonymous ?? true, allows_multiple ?? false,
29
+ );
30
+ return { success: true, message_id: result.message_id, message: '投票已发送' };
31
+ },
32
+ });
@@ -0,0 +1,17 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { defineAgentTool } from '@zhin.js/tool';
3
+ import { z } from 'zod';
4
+ export default defineAgentTool({
5
+ description: '发送 Telegram 贴纸',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ sticker: z.string().describe('贴纸 file_id 或 URL'),
9
+ }),
10
+ adapter: 'telegram',
11
+ tags: ['telegram'],
12
+ async execute({ chat_id, sticker }, context) {
13
+ const endpoint = context.$client;
14
+ const result = await endpoint.sendStickerMessage(Number(chat_id), sticker);
15
+ return { success: true, message_id: result.message_id, message: '贴纸已发送' };
16
+ },
17
+ });
@@ -0,0 +1,17 @@
1
+ import { defineAgentTool } from '@zhin.js/tool';
2
+ import { z } from 'zod';
3
+
4
+ export default defineAgentTool<{ chat_id: string; sticker: string }>({
5
+ description: '发送 Telegram 贴纸',
6
+ inputSchema: z.object({
7
+ chat_id: z.string().describe('聊天 ID'),
8
+ sticker: z.string().describe('贴纸 file_id 或 URL'),
9
+ }),
10
+ adapter: 'telegram',
11
+ tags: ['telegram'],
12
+ async execute({ chat_id, sticker }: { chat_id: string; sticker: string }, context) {
13
+ const endpoint = context.$client;
14
+ const result = await endpoint.sendStickerMessage(Number(chat_id), sticker);
15
+ return { success: true, message_id: result.message_id, message: '贴纸已发送' };
16
+ },
17
+ });
@@ -0,0 +1,3 @@
1
+ # TELEGRAM Platform Agent
2
+
3
+ You are the telegram platform specialist. Interpret requests in the current telegram conversation and load only the narrowest private Skill needed for the task.
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { telegramEndpointCommands } from '../../definition.js';
3
+ export default telegramEndpointCommands.add;
@@ -0,0 +1,3 @@
1
+ import { telegramEndpointCommands } from '../../definition.js';
2
+
3
+ export default telegramEndpointCommands.add;
@@ -0,0 +1,17 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ /**
3
+ * `telegram endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
4
+ * commands/telegram/endpoint/ 下的 list / add / remove 直接默认导出这三项。
5
+ */
6
+ import { createEndpointCommands } from 'zhin.js/adapter';
7
+ import { defineCommand } from 'zhin.js/command';
8
+ import { telegramRuntimeStateToken } from "../../../lib/telegram-runtime-state.js";
9
+ export const telegramEndpointCommands = createEndpointCommands({
10
+ adapterKey: 'telegram',
11
+ adapterDisplayName: 'Telegram',
12
+ fields: [
13
+ { key: 'token', required: true, env: true, description: 'Telegram bot token' },
14
+ ],
15
+ running: (use) => use(telegramRuntimeStateToken).endpoints.values(),
16
+ describeEntry: (entry) => `token: ${String(entry.token)}`,
17
+ }, defineCommand);
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `telegram endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
3
+ * commands/telegram/endpoint/ 下的 list / add / remove 直接默认导出这三项。
4
+ */
5
+ import { createEndpointCommands } from 'zhin.js/adapter';
6
+ import { defineCommand } from 'zhin.js/command';
7
+ import { telegramRuntimeStateToken } from '../../../src/telegram-runtime-state.js';
8
+
9
+ export const telegramEndpointCommands = createEndpointCommands({
10
+ adapterKey: 'telegram',
11
+ adapterDisplayName: 'Telegram',
12
+ fields: [
13
+ { key: 'token', required: true, env: true, description: 'Telegram bot token' },
14
+ ],
15
+ running: (use) => use(telegramRuntimeStateToken).endpoints.values(),
16
+ describeEntry: (entry) => `token: ${String(entry.token)}`,
17
+ }, defineCommand);
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { telegramEndpointCommands } from '../definition.js';
3
+ export default telegramEndpointCommands.list;
@@ -0,0 +1,3 @@
1
+ import { telegramEndpointCommands } from '../definition.js';
2
+
3
+ export default telegramEndpointCommands.list;
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { telegramEndpointCommands } from '../../definition.js';
3
+ export default telegramEndpointCommands.remove;
@@ -0,0 +1,3 @@
1
+ import { telegramEndpointCommands } from '../../definition.js';
2
+
3
+ export default telegramEndpointCommands.remove;
@@ -0,0 +1,12 @@
1
+ import type { TelegramClient } from './endpoint.js';
2
+ import type { TelegramUpdate } from './protocol.js';
3
+ export type TelegramClientEventMap = Record<string, TelegramUpdate>;
4
+ declare module '@zhin.js/feature-kit' {
5
+ interface AdapterClientRegistry {
6
+ readonly telegram: {
7
+ readonly client: TelegramClient;
8
+ readonly events: TelegramClientEventMap;
9
+ };
10
+ }
11
+ }
12
+ export declare const telegramClient: import("@zhin.js/adapter").EndpointClientToken<TelegramClient, TelegramClientEventMap>;
package/lib/client.js ADDED
@@ -0,0 +1,2 @@
1
+ import { defineEndpointClient } from 'zhin.js/adapter';
2
+ export const telegramClient = defineEndpointClient('telegram');
@@ -0,0 +1,112 @@
1
+ import { Endpoint, type EndpointContentPort, type EndpointControl, type EndpointSendRequest } from 'zhin.js/adapter';
2
+ import type { HttpHost } from '@zhin.js/host-http';
3
+ import { type MessageRef } from '@zhin.js/im-contract';
4
+ import type { CapabilityId } from 'zhin.js';
5
+ import { type ResolvedTelegramConfig, type TelegramCallbackQuery, type TelegramChatMember, type TelegramMessage, type TelegramUpdate } from './protocol.js';
6
+ export type TelegramFetch = (url: string, init?: {
7
+ readonly method?: string;
8
+ readonly headers?: Record<string, string>;
9
+ readonly body?: string | FormData;
10
+ readonly signal?: AbortSignal;
11
+ }) => Promise<{
12
+ readonly ok: boolean;
13
+ readonly status: number;
14
+ text(): Promise<string>;
15
+ json(): Promise<unknown>;
16
+ arrayBuffer?(): Promise<ArrayBuffer>;
17
+ readonly headers?: {
18
+ get(name: string): string | null;
19
+ };
20
+ }>;
21
+ export interface TelegramEndpointOptions {
22
+ readonly id: CapabilityId;
23
+ readonly config: ResolvedTelegramConfig;
24
+ readonly http?: HttpHost;
25
+ readonly fetch?: TelegramFetch;
26
+ }
27
+ export interface TelegramClientApi {
28
+ callApi<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
29
+ callApiForm<T = unknown>(method: string, form: FormData): Promise<T>;
30
+ pinMessage(chatId: number, messageId: number): Promise<boolean>;
31
+ unpinMessage(chatId: number, messageId?: number): Promise<boolean>;
32
+ setChatDescription(chatId: number, description: string): Promise<boolean>;
33
+ setMessageReaction(chatId: number, messageId: number, reaction: string): Promise<boolean>;
34
+ getChatMemberCount(chatId: number): Promise<number>;
35
+ getChatAdmins(chatId: number): Promise<TelegramChatMember[]>;
36
+ sendStickerMessage(chatId: number, sticker: string): Promise<{
37
+ message_id: number;
38
+ }>;
39
+ setChatPermissionsAll(chatId: number, permissions: Record<string, boolean | undefined>): Promise<boolean>;
40
+ createInviteLink(chatId: number): Promise<string>;
41
+ sendPoll(chatId: number, question: string, options: string[], isAnonymous?: boolean, allowsMultipleAnswers?: boolean): Promise<{
42
+ message_id: number;
43
+ }>;
44
+ }
45
+ /** Telegram Bot API client carried by message, update and lifecycle events. */
46
+ export declare class TelegramClient implements TelegramClientApi {
47
+ readonly api: TelegramClientApi;
48
+ constructor(api: TelegramClientApi);
49
+ callApi: <T = unknown>(method: string, params?: Record<string, unknown>) => Promise<T>;
50
+ callApiForm: <T = unknown>(method: string, form: FormData) => Promise<T>;
51
+ pinMessage: (chatId: number, messageId: number) => Promise<boolean>;
52
+ unpinMessage: (chatId: number, messageId?: number) => Promise<boolean>;
53
+ setChatDescription: (chatId: number, description: string) => Promise<boolean>;
54
+ setMessageReaction: (chatId: number, messageId: number, reaction: string) => Promise<boolean>;
55
+ getChatMemberCount: (chatId: number) => Promise<number>;
56
+ getChatAdmins: (chatId: number) => Promise<TelegramChatMember[]>;
57
+ sendStickerMessage: (chatId: number, sticker: string) => Promise<{
58
+ message_id: number;
59
+ }>;
60
+ setChatPermissionsAll: (chatId: number, permissions: Record<string, boolean | undefined>) => Promise<boolean>;
61
+ createInviteLink: (chatId: number) => Promise<string>;
62
+ sendPoll: (chatId: number, question: string, options: string[], anonymous?: boolean, multiple?: boolean) => Promise<{
63
+ message_id: number;
64
+ }>;
65
+ }
66
+ /**
67
+ * Telegram Bot API 无列表类接口(无 getMyChats/getChatMembers),
68
+ * 仅 getChat/getChatMember 按已知 id 单查,不构成列表能力;
69
+ * 因此本 endpoint 不暴露 EndpointManagement(Console 社交面 RPC 对该平台保持未接线)。
70
+ */
71
+ export declare class TelegramEndpoint extends Endpoint<TelegramClient> {
72
+ #private;
73
+ readonly client: TelegramClient;
74
+ readonly control: EndpointControl;
75
+ readonly content: EndpointContentPort;
76
+ constructor(options: TelegramEndpointOptions);
77
+ /** Used by webhook handler. */
78
+ get isOpen(): boolean;
79
+ get config(): ResolvedTelegramConfig;
80
+ get allowedUpdates(): readonly string[];
81
+ getUpdateOffset(): number;
82
+ setUpdateOffset(offset: number): void;
83
+ start(): Promise<void>;
84
+ open(): void;
85
+ close(): void;
86
+ stop(): Promise<void>;
87
+ send({ conversation, payload }: EndpointSendRequest): Promise<string>;
88
+ recallMessage(message: MessageRef): Promise<void>;
89
+ /** Test / internal: admit a message when open. */
90
+ admit(msg: TelegramMessage): void;
91
+ /** Test / internal: admit a callback query when open. */
92
+ admitCallback(query: TelegramCallbackQuery): void;
93
+ /** Used by webhook / polling handlers. */
94
+ handleUpdate(update: TelegramUpdate): void;
95
+ callApi<T = unknown>(method: string, params?: Record<string, unknown>, signal?: AbortSignal): Promise<T>;
96
+ /** multipart/form-data 变体(attach:// 媒体上传;Content-Type 边界由 FormData 自带)。 */
97
+ callApiForm<T = unknown>(method: string, form: FormData, signal?: AbortSignal): Promise<T>;
98
+ pinMessage(chatId: number, messageId: number): Promise<boolean>;
99
+ unpinMessage(chatId: number, messageId?: number): Promise<boolean>;
100
+ setChatDescription(chatId: number, description: string): Promise<boolean>;
101
+ setMessageReaction(chatId: number, messageId: number, reaction: string): Promise<boolean>;
102
+ getChatMemberCount(chatId: number): Promise<number>;
103
+ getChatAdmins(chatId: number): Promise<TelegramChatMember[]>;
104
+ sendStickerMessage(chatId: number, sticker: string): Promise<{
105
+ message_id: number;
106
+ }>;
107
+ setChatPermissionsAll(chatId: number, permissions: Record<string, boolean | undefined>): Promise<boolean>;
108
+ createInviteLink(chatId: number): Promise<string>;
109
+ sendPoll(chatId: number, question: string, options: string[], isAnonymous?: boolean, allowsMultipleAnswers?: boolean): Promise<{
110
+ message_id: number;
111
+ }>;
112
+ }