agent-messenger 2.12.0 → 2.12.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/.claude-plugin/README.md +11 -1
- package/.claude-plugin/marketplace.json +14 -1
- package/.claude-plugin/plugin.json +4 -2
- package/CONTRIBUTING.md +12 -0
- package/README.md +30 -4
- package/dist/package.json +10 -2
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +3 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/telegrambot/cli.d.ts +5 -0
- package/dist/src/platforms/telegrambot/cli.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/cli.js +29 -0
- package/dist/src/platforms/telegrambot/cli.js.map +1 -0
- package/dist/src/platforms/telegrambot/client.d.ts +85 -0
- package/dist/src/platforms/telegrambot/client.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/client.js +282 -0
- package/dist/src/platforms/telegrambot/client.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/auth.d.ts +31 -0
- package/dist/src/platforms/telegrambot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/auth.js +173 -0
- package/dist/src/platforms/telegrambot/commands/auth.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/chat.d.ts +25 -0
- package/dist/src/platforms/telegrambot/commands/chat.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/chat.js +69 -0
- package/dist/src/platforms/telegrambot/commands/chat.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/index.d.ts +6 -0
- package/dist/src/platforms/telegrambot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/index.js +6 -0
- package/dist/src/platforms/telegrambot/commands/index.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/message.d.ts +39 -0
- package/dist/src/platforms/telegrambot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/message.js +145 -0
- package/dist/src/platforms/telegrambot/commands/message.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/reaction.d.ts +16 -0
- package/dist/src/platforms/telegrambot/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/reaction.js +49 -0
- package/dist/src/platforms/telegrambot/commands/reaction.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/shared.d.ts +12 -0
- package/dist/src/platforms/telegrambot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/shared.js +21 -0
- package/dist/src/platforms/telegrambot/commands/shared.js.map +1 -0
- package/dist/src/platforms/telegrambot/commands/whoami.d.ts +17 -0
- package/dist/src/platforms/telegrambot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/commands/whoami.js +30 -0
- package/dist/src/platforms/telegrambot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/telegrambot/credential-manager.d.ts +17 -0
- package/dist/src/platforms/telegrambot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/credential-manager.js +113 -0
- package/dist/src/platforms/telegrambot/credential-manager.js.map +1 -0
- package/dist/src/platforms/telegrambot/index.d.ts +7 -0
- package/dist/src/platforms/telegrambot/index.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/index.js +5 -0
- package/dist/src/platforms/telegrambot/index.js.map +1 -0
- package/dist/src/platforms/telegrambot/listener.d.ts +30 -0
- package/dist/src/platforms/telegrambot/listener.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/listener.js +186 -0
- package/dist/src/platforms/telegrambot/listener.js.map +1 -0
- package/dist/src/platforms/telegrambot/types.d.ts +256 -0
- package/dist/src/platforms/telegrambot/types.d.ts.map +1 -0
- package/dist/src/platforms/telegrambot/types.js +96 -0
- package/dist/src/platforms/telegrambot/types.js.map +1 -0
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/telegrambot.mdx +149 -0
- package/docs/content/docs/index.mdx +10 -9
- package/docs/content/docs/quick-start.mdx +2 -0
- package/docs/content/docs/sdk/meta.json +1 -0
- package/docs/content/docs/sdk/telegrambot.mdx +216 -0
- package/e2e/config.ts +24 -0
- package/e2e/helpers.ts +1 -0
- package/e2e/telegrambot.e2e.test.ts +185 -0
- package/examples/telegrambot-listen.ts +54 -0
- package/package.json +10 -2
- package/scripts/postbuild.ts +1 -0
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +12 -5
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-telegrambot/SKILL.md +357 -0
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/cli.ts +4 -0
- package/src/platforms/telegrambot/cli.ts +34 -0
- package/src/platforms/telegrambot/client.test.ts +454 -0
- package/src/platforms/telegrambot/client.ts +404 -0
- package/src/platforms/telegrambot/commands/auth.test.ts +244 -0
- package/src/platforms/telegrambot/commands/auth.ts +220 -0
- package/src/platforms/telegrambot/commands/chat.ts +96 -0
- package/src/platforms/telegrambot/commands/index.ts +5 -0
- package/src/platforms/telegrambot/commands/message.ts +235 -0
- package/src/platforms/telegrambot/commands/reaction.ts +70 -0
- package/src/platforms/telegrambot/commands/shared.ts +32 -0
- package/src/platforms/telegrambot/commands/whoami.ts +45 -0
- package/src/platforms/telegrambot/credential-manager.test.ts +196 -0
- package/src/platforms/telegrambot/credential-manager.ts +141 -0
- package/src/platforms/telegrambot/index.ts +44 -0
- package/src/platforms/telegrambot/listener.test.ts +398 -0
- package/src/platforms/telegrambot/listener.ts +198 -0
- package/src/platforms/telegrambot/types.test.ts +128 -0
- package/src/platforms/telegrambot/types.ts +282 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
TelegramBotConfigSchema,
|
|
5
|
+
TelegramBotCredentialsSchema,
|
|
6
|
+
TelegramBotEntrySchema,
|
|
7
|
+
TelegramBotError,
|
|
8
|
+
TelegramBotUserSchema,
|
|
9
|
+
TelegramChatSchema,
|
|
10
|
+
TelegramMessageSchema,
|
|
11
|
+
} from './types'
|
|
12
|
+
|
|
13
|
+
describe('TelegramBotError', () => {
|
|
14
|
+
it('creates error with message and code', () => {
|
|
15
|
+
const err = new TelegramBotError('Test error', 'TEST_CODE')
|
|
16
|
+
expect(err.message).toBe('Test error')
|
|
17
|
+
expect(err.code).toBe('TEST_CODE')
|
|
18
|
+
expect(err.name).toBe('TelegramBotError')
|
|
19
|
+
expect(err).toBeInstanceOf(Error)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('TelegramBotEntrySchema', () => {
|
|
24
|
+
it('validates correct bot entry', () => {
|
|
25
|
+
const result = TelegramBotEntrySchema.safeParse({
|
|
26
|
+
bot_id: 'mybot',
|
|
27
|
+
bot_name: 'My Bot',
|
|
28
|
+
token: '123456789:ABC-DEF',
|
|
29
|
+
})
|
|
30
|
+
expect(result.success).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('rejects missing bot_id', () => {
|
|
34
|
+
const result = TelegramBotEntrySchema.safeParse({ bot_name: 'My Bot', token: 'tok' })
|
|
35
|
+
expect(result.success).toBe(false)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('TelegramBotConfigSchema', () => {
|
|
40
|
+
it('accepts empty config', () => {
|
|
41
|
+
const result = TelegramBotConfigSchema.safeParse({ current: null, bots: {} })
|
|
42
|
+
expect(result.success).toBe(true)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('accepts config with bots and current', () => {
|
|
46
|
+
const result = TelegramBotConfigSchema.safeParse({
|
|
47
|
+
current: { bot_id: 'mybot' },
|
|
48
|
+
bots: {
|
|
49
|
+
mybot: { bot_id: 'mybot', bot_name: 'My Bot', token: '123:abc' },
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
expect(result.success).toBe(true)
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('TelegramBotCredentialsSchema', () => {
|
|
57
|
+
it('validates credentials', () => {
|
|
58
|
+
const result = TelegramBotCredentialsSchema.safeParse({
|
|
59
|
+
token: '123:abc',
|
|
60
|
+
bot_id: 'mybot',
|
|
61
|
+
bot_name: 'My Bot',
|
|
62
|
+
})
|
|
63
|
+
expect(result.success).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('TelegramBotUserSchema', () => {
|
|
68
|
+
it('validates a bot user', () => {
|
|
69
|
+
const result = TelegramBotUserSchema.safeParse({
|
|
70
|
+
id: 123456789,
|
|
71
|
+
is_bot: true,
|
|
72
|
+
first_name: 'My Bot',
|
|
73
|
+
username: 'mybot',
|
|
74
|
+
})
|
|
75
|
+
expect(result.success).toBe(true)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('rejects missing id', () => {
|
|
79
|
+
const result = TelegramBotUserSchema.safeParse({ is_bot: true, first_name: 'X' })
|
|
80
|
+
expect(result.success).toBe(false)
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
describe('TelegramChatSchema', () => {
|
|
85
|
+
it('validates private chat', () => {
|
|
86
|
+
const result = TelegramChatSchema.safeParse({ id: 1, type: 'private', first_name: 'Alice' })
|
|
87
|
+
expect(result.success).toBe(true)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('validates supergroup', () => {
|
|
91
|
+
const result = TelegramChatSchema.safeParse({ id: -1001234567890, type: 'supergroup', title: 'Eng' })
|
|
92
|
+
expect(result.success).toBe(true)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('rejects invalid type', () => {
|
|
96
|
+
const result = TelegramChatSchema.safeParse({ id: 1, type: 'invalid' })
|
|
97
|
+
expect(result.success).toBe(false)
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
describe('TelegramMessageSchema', () => {
|
|
102
|
+
it('validates a text message', () => {
|
|
103
|
+
const result = TelegramMessageSchema.safeParse({
|
|
104
|
+
message_id: 42,
|
|
105
|
+
date: 1735689600,
|
|
106
|
+
chat: { id: -1001234567890, type: 'supergroup', title: 'Eng' },
|
|
107
|
+
from: { id: 1, is_bot: false, first_name: 'Alice' },
|
|
108
|
+
text: 'Hello',
|
|
109
|
+
})
|
|
110
|
+
expect(result.success).toBe(true)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('validates message with reply', () => {
|
|
114
|
+
const result = TelegramMessageSchema.safeParse({
|
|
115
|
+
message_id: 43,
|
|
116
|
+
date: 1735689700,
|
|
117
|
+
chat: { id: -1001234567890, type: 'supergroup', title: 'Eng' },
|
|
118
|
+
text: 'Reply',
|
|
119
|
+
reply_to_message: {
|
|
120
|
+
message_id: 42,
|
|
121
|
+
date: 1735689600,
|
|
122
|
+
chat: { id: -1001234567890, type: 'supergroup', title: 'Eng' },
|
|
123
|
+
text: 'Original',
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
expect(result.success).toBe(true)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export interface TelegramBotEntry {
|
|
4
|
+
bot_id: string
|
|
5
|
+
bot_name: string
|
|
6
|
+
token: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface TelegramBotConfig {
|
|
10
|
+
current: { bot_id: string } | null
|
|
11
|
+
bots: Record<string, TelegramBotEntry>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TelegramBotCredentials {
|
|
15
|
+
token: string
|
|
16
|
+
bot_id: string
|
|
17
|
+
bot_name: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class TelegramBotError extends Error {
|
|
21
|
+
code: string
|
|
22
|
+
|
|
23
|
+
constructor(message: string, code: string) {
|
|
24
|
+
super(message)
|
|
25
|
+
this.name = 'TelegramBotError'
|
|
26
|
+
this.code = code
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TelegramBotUser {
|
|
31
|
+
id: number
|
|
32
|
+
is_bot: boolean
|
|
33
|
+
first_name: string
|
|
34
|
+
last_name?: string
|
|
35
|
+
username?: string
|
|
36
|
+
language_code?: string
|
|
37
|
+
is_premium?: boolean
|
|
38
|
+
can_join_groups?: boolean
|
|
39
|
+
can_read_all_group_messages?: boolean
|
|
40
|
+
supports_inline_queries?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TelegramChat {
|
|
44
|
+
id: number
|
|
45
|
+
type: 'private' | 'group' | 'supergroup' | 'channel'
|
|
46
|
+
title?: string
|
|
47
|
+
username?: string
|
|
48
|
+
first_name?: string
|
|
49
|
+
last_name?: string
|
|
50
|
+
is_forum?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface TelegramChatFullInfo extends TelegramChat {
|
|
54
|
+
bio?: string
|
|
55
|
+
description?: string
|
|
56
|
+
invite_link?: string
|
|
57
|
+
pinned_message?: TelegramMessage
|
|
58
|
+
permissions?: Record<string, boolean>
|
|
59
|
+
member_count?: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface TelegramChatMember {
|
|
63
|
+
user: TelegramBotUser
|
|
64
|
+
status: 'creator' | 'administrator' | 'member' | 'restricted' | 'left' | 'kicked'
|
|
65
|
+
is_anonymous?: boolean
|
|
66
|
+
custom_title?: string
|
|
67
|
+
until_date?: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TelegramMessageEntity {
|
|
71
|
+
type: string
|
|
72
|
+
offset: number
|
|
73
|
+
length: number
|
|
74
|
+
url?: string
|
|
75
|
+
user?: TelegramBotUser
|
|
76
|
+
language?: string
|
|
77
|
+
custom_emoji_id?: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TelegramPhotoSize {
|
|
81
|
+
file_id: string
|
|
82
|
+
file_unique_id: string
|
|
83
|
+
width: number
|
|
84
|
+
height: number
|
|
85
|
+
file_size?: number
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface TelegramDocument {
|
|
89
|
+
file_id: string
|
|
90
|
+
file_unique_id: string
|
|
91
|
+
thumbnail?: TelegramPhotoSize
|
|
92
|
+
file_name?: string
|
|
93
|
+
mime_type?: string
|
|
94
|
+
file_size?: number
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface TelegramMessage {
|
|
98
|
+
message_id: number
|
|
99
|
+
message_thread_id?: number
|
|
100
|
+
date: number
|
|
101
|
+
chat: TelegramChat
|
|
102
|
+
from?: TelegramBotUser
|
|
103
|
+
sender_chat?: TelegramChat
|
|
104
|
+
text?: string
|
|
105
|
+
caption?: string
|
|
106
|
+
entities?: TelegramMessageEntity[]
|
|
107
|
+
caption_entities?: TelegramMessageEntity[]
|
|
108
|
+
reply_to_message?: TelegramMessage
|
|
109
|
+
edit_date?: number
|
|
110
|
+
photo?: TelegramPhotoSize[]
|
|
111
|
+
document?: TelegramDocument
|
|
112
|
+
is_topic_message?: boolean
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface TelegramReactionType {
|
|
116
|
+
type: 'emoji' | 'custom_emoji' | 'paid'
|
|
117
|
+
emoji?: string
|
|
118
|
+
custom_emoji_id?: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface TelegramCallbackQuery {
|
|
122
|
+
id: string
|
|
123
|
+
from: TelegramBotUser
|
|
124
|
+
message?: TelegramMessage
|
|
125
|
+
inline_message_id?: string
|
|
126
|
+
chat_instance: string
|
|
127
|
+
data?: string
|
|
128
|
+
game_short_name?: string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface TelegramInlineQuery {
|
|
132
|
+
id: string
|
|
133
|
+
from: TelegramBotUser
|
|
134
|
+
query: string
|
|
135
|
+
offset: string
|
|
136
|
+
chat_type?: string
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface TelegramChatMemberUpdated {
|
|
140
|
+
chat: TelegramChat
|
|
141
|
+
from: TelegramBotUser
|
|
142
|
+
date: number
|
|
143
|
+
old_chat_member: TelegramChatMember
|
|
144
|
+
new_chat_member: TelegramChatMember
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface TelegramUpdate {
|
|
148
|
+
update_id: number
|
|
149
|
+
message?: TelegramMessage
|
|
150
|
+
edited_message?: TelegramMessage
|
|
151
|
+
channel_post?: TelegramMessage
|
|
152
|
+
edited_channel_post?: TelegramMessage
|
|
153
|
+
inline_query?: TelegramInlineQuery
|
|
154
|
+
chosen_inline_result?: Record<string, unknown>
|
|
155
|
+
callback_query?: TelegramCallbackQuery
|
|
156
|
+
shipping_query?: Record<string, unknown>
|
|
157
|
+
pre_checkout_query?: Record<string, unknown>
|
|
158
|
+
poll?: Record<string, unknown>
|
|
159
|
+
poll_answer?: Record<string, unknown>
|
|
160
|
+
my_chat_member?: TelegramChatMemberUpdated
|
|
161
|
+
chat_member?: TelegramChatMemberUpdated
|
|
162
|
+
chat_join_request?: Record<string, unknown>
|
|
163
|
+
message_reaction?: Record<string, unknown>
|
|
164
|
+
message_reaction_count?: Record<string, unknown>
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const TelegramBotEntrySchema = z.object({
|
|
168
|
+
bot_id: z.string(),
|
|
169
|
+
bot_name: z.string(),
|
|
170
|
+
token: z.string(),
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export const TelegramBotConfigSchema = z.object({
|
|
174
|
+
current: z
|
|
175
|
+
.object({
|
|
176
|
+
bot_id: z.string(),
|
|
177
|
+
})
|
|
178
|
+
.nullable(),
|
|
179
|
+
bots: z.record(z.string(), TelegramBotEntrySchema),
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
export const TelegramBotCredentialsSchema = z.object({
|
|
183
|
+
token: z.string(),
|
|
184
|
+
bot_id: z.string(),
|
|
185
|
+
bot_name: z.string(),
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
export const TelegramBotUserSchema = z
|
|
189
|
+
.object({
|
|
190
|
+
id: z.number(),
|
|
191
|
+
is_bot: z.boolean(),
|
|
192
|
+
first_name: z.string(),
|
|
193
|
+
last_name: z.string().optional(),
|
|
194
|
+
username: z.string().optional(),
|
|
195
|
+
language_code: z.string().optional(),
|
|
196
|
+
is_premium: z.boolean().optional(),
|
|
197
|
+
can_join_groups: z.boolean().optional(),
|
|
198
|
+
can_read_all_group_messages: z.boolean().optional(),
|
|
199
|
+
supports_inline_queries: z.boolean().optional(),
|
|
200
|
+
})
|
|
201
|
+
.passthrough()
|
|
202
|
+
|
|
203
|
+
export const TelegramChatSchema = z
|
|
204
|
+
.object({
|
|
205
|
+
id: z.number(),
|
|
206
|
+
type: z.enum(['private', 'group', 'supergroup', 'channel']),
|
|
207
|
+
title: z.string().optional(),
|
|
208
|
+
username: z.string().optional(),
|
|
209
|
+
first_name: z.string().optional(),
|
|
210
|
+
last_name: z.string().optional(),
|
|
211
|
+
is_forum: z.boolean().optional(),
|
|
212
|
+
})
|
|
213
|
+
.passthrough()
|
|
214
|
+
|
|
215
|
+
export const TelegramMessageEntitySchema = z.object({
|
|
216
|
+
type: z.string(),
|
|
217
|
+
offset: z.number(),
|
|
218
|
+
length: z.number(),
|
|
219
|
+
url: z.string().optional(),
|
|
220
|
+
user: TelegramBotUserSchema.optional(),
|
|
221
|
+
language: z.string().optional(),
|
|
222
|
+
custom_emoji_id: z.string().optional(),
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
export const TelegramPhotoSizeSchema = z.object({
|
|
226
|
+
file_id: z.string(),
|
|
227
|
+
file_unique_id: z.string(),
|
|
228
|
+
width: z.number(),
|
|
229
|
+
height: z.number(),
|
|
230
|
+
file_size: z.number().optional(),
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
export const TelegramDocumentSchema = z.object({
|
|
234
|
+
file_id: z.string(),
|
|
235
|
+
file_unique_id: z.string(),
|
|
236
|
+
thumbnail: TelegramPhotoSizeSchema.optional(),
|
|
237
|
+
file_name: z.string().optional(),
|
|
238
|
+
mime_type: z.string().optional(),
|
|
239
|
+
file_size: z.number().optional(),
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
export const TelegramMessageSchema = z
|
|
243
|
+
.object({
|
|
244
|
+
message_id: z.number(),
|
|
245
|
+
message_thread_id: z.number().optional(),
|
|
246
|
+
date: z.number(),
|
|
247
|
+
chat: TelegramChatSchema,
|
|
248
|
+
from: TelegramBotUserSchema.optional(),
|
|
249
|
+
sender_chat: TelegramChatSchema.optional(),
|
|
250
|
+
text: z.string().optional(),
|
|
251
|
+
caption: z.string().optional(),
|
|
252
|
+
entities: z.array(TelegramMessageEntitySchema).optional(),
|
|
253
|
+
caption_entities: z.array(TelegramMessageEntitySchema).optional(),
|
|
254
|
+
reply_to_message: z.lazy(() => TelegramMessageSchema).optional(),
|
|
255
|
+
edit_date: z.number().optional(),
|
|
256
|
+
photo: z.array(TelegramPhotoSizeSchema).optional(),
|
|
257
|
+
document: TelegramDocumentSchema.optional(),
|
|
258
|
+
is_topic_message: z.boolean().optional(),
|
|
259
|
+
})
|
|
260
|
+
.passthrough() as z.ZodType<TelegramMessage>
|
|
261
|
+
|
|
262
|
+
export interface TelegramBotListenerOptions {
|
|
263
|
+
timeoutSeconds?: number
|
|
264
|
+
limit?: number
|
|
265
|
+
allowedUpdates?: string[]
|
|
266
|
+
dropPendingUpdates?: boolean
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface TelegramBotListenerEventMap {
|
|
270
|
+
message: [event: TelegramMessage]
|
|
271
|
+
edited_message: [event: TelegramMessage]
|
|
272
|
+
channel_post: [event: TelegramMessage]
|
|
273
|
+
edited_channel_post: [event: TelegramMessage]
|
|
274
|
+
callback_query: [event: TelegramCallbackQuery]
|
|
275
|
+
inline_query: [event: TelegramInlineQuery]
|
|
276
|
+
my_chat_member: [event: TelegramChatMemberUpdated]
|
|
277
|
+
chat_member: [event: TelegramChatMemberUpdated]
|
|
278
|
+
telegram_update: [event: TelegramUpdate]
|
|
279
|
+
connected: [info: { user: TelegramBotUser }]
|
|
280
|
+
disconnected: []
|
|
281
|
+
error: [error: Error]
|
|
282
|
+
}
|