@zhin.js/adapter-telegram 5.0.1 → 5.0.3
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 +56 -0
- package/README.md +65 -139
- package/adapters/telegram.ts +27 -0
- package/agent/tools/create_invite.ts +20 -0
- package/agent/tools/list_admins.ts +26 -0
- package/agent/tools/member_count.ts +18 -0
- package/agent/tools/pin_message.ts +21 -0
- package/agent/tools/react.ts +20 -0
- package/agent/tools/send_poll.ts +34 -0
- package/agent/tools/send_sticker.ts +19 -0
- package/agent/tools/set_description.ts +19 -0
- package/agent/tools/set_permissions.ts +33 -0
- package/agent/tools/unpin_message.ts +21 -0
- package/lib/endpoint.d.ts +58 -148
- package/lib/endpoint.js +273 -987
- package/lib/index.d.ts +4 -18
- package/lib/index.js +4 -462
- package/lib/platform-permit.d.ts +1 -2
- package/lib/platform-permit.js +4 -2
- package/lib/polling.d.ts +9 -0
- package/lib/polling.js +52 -0
- package/lib/protocol.d.ts +250 -0
- package/lib/protocol.js +324 -0
- package/lib/telegram-agent-deps.d.ts +28 -0
- package/lib/telegram-agent-deps.js +30 -0
- package/lib/webhook.d.ts +13 -0
- package/lib/webhook.js +45 -0
- package/package.json +46 -33
- package/plugin.ts +13 -0
- package/schema.json +39 -0
- package/src/endpoint.ts +339 -1103
- package/src/index.ts +39 -435
- package/src/platform-permit.ts +1 -2
- package/src/polling.ts +71 -0
- package/src/protocol.ts +573 -0
- package/src/telegram-agent-deps.ts +63 -0
- package/src/webhook.ts +67 -0
- package/client/Dashboard.tsx +0 -295
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -32
- package/lib/adapter.d.ts +0 -21
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -58
- package/lib/adapter.js.map +0 -1
- package/lib/endpoint.d.ts.map +0 -1
- package/lib/endpoint.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/platform-permit.d.ts.map +0 -1
- package/lib/platform-permit.js.map +0 -1
- package/lib/segment-mapper.d.ts +0 -2
- package/lib/segment-mapper.d.ts.map +0 -1
- package/lib/segment-mapper.js +0 -2
- package/lib/segment-mapper.js.map +0 -1
- package/lib/types.d.ts +0 -29
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/adapter.ts +0 -66
- package/src/segment-mapper.ts +0 -1
- package/src/types.ts +0 -32
- /package/{skills/telegram → agent}/PERMITS.md +0 -0
- /package/{skills/telegram/SKILL.md → agent/skills/telegram.md} +0 -0
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,155 +1,65 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* TelegramEndpoint — lifecycle, outbound, admit, Bot API helpers for agent tools.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
8
|
-
import type
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* @param userId 用户 ID
|
|
52
|
-
*/
|
|
53
|
-
unbanMember(chatId: number, userId: number): Promise<boolean>;
|
|
54
|
-
/**
|
|
55
|
-
* 限制用户权限(禁言等)
|
|
56
|
-
* @param chatId 聊天 ID
|
|
57
|
-
* @param userId 用户 ID
|
|
58
|
-
* @param permissions 权限设置
|
|
59
|
-
* @param untilDate 限制截止时间
|
|
60
|
-
*/
|
|
61
|
-
restrictMember(chatId: number, userId: number, permissions: {
|
|
62
|
-
can_send_messages?: boolean;
|
|
63
|
-
can_send_media_messages?: boolean;
|
|
64
|
-
can_send_polls?: boolean;
|
|
65
|
-
can_send_other_messages?: boolean;
|
|
66
|
-
can_add_web_page_previews?: boolean;
|
|
67
|
-
can_change_info?: boolean;
|
|
68
|
-
can_invite_users?: boolean;
|
|
69
|
-
can_pin_messages?: boolean;
|
|
70
|
-
}, untilDate?: number): Promise<boolean>;
|
|
71
|
-
/**
|
|
72
|
-
* 禁言用户
|
|
73
|
-
* @param chatId 聊天 ID
|
|
74
|
-
* @param userId 用户 ID
|
|
75
|
-
* @param duration 禁言时长(秒),0 表示解除禁言
|
|
76
|
-
*/
|
|
77
|
-
muteMember(chatId: number, userId: number, duration?: number): Promise<boolean>;
|
|
78
|
-
/**
|
|
79
|
-
* 提升/降级管理员
|
|
80
|
-
* @param chatId 聊天 ID
|
|
81
|
-
* @param userId 用户 ID
|
|
82
|
-
* @param promote 是否提升为管理员
|
|
83
|
-
*/
|
|
84
|
-
setAdmin(chatId: number, userId: number, promote?: boolean): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* 设置聊天标题
|
|
87
|
-
* @param chatId 聊天 ID
|
|
88
|
-
* @param title 新标题
|
|
89
|
-
*/
|
|
90
|
-
setChatTitle(chatId: number, title: string): Promise<boolean>;
|
|
91
|
-
/**
|
|
92
|
-
* 设置聊天描述
|
|
93
|
-
* @param chatId 聊天 ID
|
|
94
|
-
* @param description 新描述
|
|
95
|
-
*/
|
|
96
|
-
setChatDescription(chatId: number, description: string): Promise<boolean>;
|
|
97
|
-
/**
|
|
98
|
-
* 置顶消息
|
|
99
|
-
* @param chatId 聊天 ID
|
|
100
|
-
* @param messageId 消息 ID
|
|
101
|
-
*/
|
|
4
|
+
import type { EndpointInstance } from '@zhin.js/adapter';
|
|
5
|
+
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
6
|
+
import type { HttpHost } from '@zhin.js/host-http';
|
|
7
|
+
import type { CapabilityId } from '@zhin.js/plugin-runtime';
|
|
8
|
+
import { type ResolvedTelegramConfig, type TelegramCallbackQuery, type TelegramChatMember, type TelegramMessage, type TelegramUpdate } from './protocol.js';
|
|
9
|
+
export type TelegramFetch = (url: string, init?: {
|
|
10
|
+
readonly method?: string;
|
|
11
|
+
readonly headers?: Record<string, string>;
|
|
12
|
+
readonly body?: string;
|
|
13
|
+
readonly signal?: AbortSignal;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
readonly ok: boolean;
|
|
16
|
+
readonly status: number;
|
|
17
|
+
text(): Promise<string>;
|
|
18
|
+
json(): Promise<unknown>;
|
|
19
|
+
}>;
|
|
20
|
+
export interface TelegramEndpointOptions {
|
|
21
|
+
readonly id: CapabilityId;
|
|
22
|
+
readonly gateway: MessageGateway;
|
|
23
|
+
readonly config: ResolvedTelegramConfig;
|
|
24
|
+
readonly http?: HttpHost;
|
|
25
|
+
readonly fetch?: TelegramFetch;
|
|
26
|
+
}
|
|
27
|
+
export declare class TelegramEndpoint implements EndpointInstance {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(options: TelegramEndpointOptions);
|
|
30
|
+
/** Used by webhook handler. */
|
|
31
|
+
get isOpen(): boolean;
|
|
32
|
+
get config(): ResolvedTelegramConfig;
|
|
33
|
+
get allowedUpdates(): readonly string[];
|
|
34
|
+
getUpdateOffset(): number;
|
|
35
|
+
setUpdateOffset(offset: number): void;
|
|
36
|
+
start(): Promise<void>;
|
|
37
|
+
open(): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
stop(): Promise<void>;
|
|
40
|
+
send({ target, payload }: {
|
|
41
|
+
readonly target: string;
|
|
42
|
+
readonly payload: unknown;
|
|
43
|
+
}): Promise<string>;
|
|
44
|
+
/** Test / internal: admit a message when open. */
|
|
45
|
+
admit(msg: TelegramMessage): void;
|
|
46
|
+
/** Test / internal: admit a callback query when open. */
|
|
47
|
+
admitCallback(query: TelegramCallbackQuery): void;
|
|
48
|
+
/** Used by webhook / polling handlers. */
|
|
49
|
+
handleUpdate(update: TelegramUpdate): void;
|
|
50
|
+
callApi<T = unknown>(method: string, params?: Record<string, unknown>, signal?: AbortSignal): Promise<T>;
|
|
102
51
|
pinMessage(chatId: number, messageId: number): Promise<boolean>;
|
|
103
|
-
/**
|
|
104
|
-
* 取消置顶消息
|
|
105
|
-
* @param chatId 聊天 ID
|
|
106
|
-
* @param messageId 消息 ID(可选,不提供则取消所有置顶)
|
|
107
|
-
*/
|
|
108
52
|
unpinMessage(chatId: number, messageId?: number): Promise<boolean>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* @param chatId 聊天 ID
|
|
112
|
-
*/
|
|
113
|
-
getChatInfo(chatId: number): Promise<any>;
|
|
114
|
-
/**
|
|
115
|
-
* 获取聊天成员
|
|
116
|
-
* @param chatId 聊天 ID
|
|
117
|
-
* @param userId 用户 ID
|
|
118
|
-
*/
|
|
119
|
-
getChatMember(chatId: number, userId: number): Promise<ChatMember>;
|
|
120
|
-
/**
|
|
121
|
-
* 获取管理员列表
|
|
122
|
-
* @param chatId 聊天 ID
|
|
123
|
-
*/
|
|
124
|
-
getChatAdmins(chatId: number): Promise<ChatMember[]>;
|
|
125
|
-
/**
|
|
126
|
-
* 获取聊天成员数量
|
|
127
|
-
* @param chatId 聊天 ID
|
|
128
|
-
*/
|
|
53
|
+
setChatDescription(chatId: number, description: string): Promise<boolean>;
|
|
54
|
+
setMessageReaction(chatId: number, messageId: number, reaction: string): Promise<boolean>;
|
|
129
55
|
getChatMemberCount(chatId: number): Promise<number>;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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>;
|
|
134
61
|
createInviteLink(chatId: number): Promise<string>;
|
|
135
|
-
sendPoll(chatId: number, question: string, options: string[], isAnonymous?: boolean, allowsMultipleAnswers?: boolean): Promise<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
setChatPermissionsAll(chatId: number, permissions: {
|
|
139
|
-
can_send_messages?: boolean;
|
|
140
|
-
can_send_audios?: boolean;
|
|
141
|
-
can_send_documents?: boolean;
|
|
142
|
-
can_send_photos?: boolean;
|
|
143
|
-
can_send_videos?: boolean;
|
|
144
|
-
can_send_video_notes?: boolean;
|
|
145
|
-
can_send_voice_notes?: boolean;
|
|
146
|
-
can_send_polls?: boolean;
|
|
147
|
-
can_send_other_messages?: boolean;
|
|
148
|
-
can_add_web_page_previews?: boolean;
|
|
149
|
-
can_change_info?: boolean;
|
|
150
|
-
can_invite_users?: boolean;
|
|
151
|
-
can_pin_messages?: boolean;
|
|
152
|
-
can_manage_topics?: boolean;
|
|
153
|
-
}): Promise<boolean>;
|
|
62
|
+
sendPoll(chatId: number, question: string, options: string[], isAnonymous?: boolean, allowsMultipleAnswers?: boolean): Promise<{
|
|
63
|
+
message_id: number;
|
|
64
|
+
}>;
|
|
154
65
|
}
|
|
155
|
-
//# sourceMappingURL=endpoint.d.ts.map
|