teledzik 1.1.4 → 1.2.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.
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Telegram Bot API 10.0 - 10.3 Recent Updates
3
+ * @see https://core.telegram.org/bots/api#recent-changes
4
+ */
5
+
6
+ import { Chat, User, MessageEntity, PhotoSize, Video } from '@telegraf/types'
7
+ import { InputFile } from './typegram'
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // Bot API 10.3 (August 24, 2026)
11
+ // ---------------------------------------------------------------------------
12
+
13
+ /**
14
+ * Ephemeral message parameters.
15
+ * Allows sending messages visible only to a specific user and the bot.
16
+ */
17
+ export interface EphemeralMessageParameters {
18
+ /** Target user who will see the ephemeral message */
19
+ receiver_user_id?: number
20
+ /** Callback query ID if replying to a callback */
21
+ callback_query_id?: string
22
+ /** If true, replace the original message that generated the callback query */
23
+ replace_callback_query_message?: boolean
24
+ }
25
+
26
+ /**
27
+ * Disabled button representation in reply markup.
28
+ */
29
+ export interface DisabledButton {
30
+ text: string
31
+ disabled: true
32
+ }
33
+
34
+ /**
35
+ * Information about a unique gift.
36
+ */
37
+ export interface UniqueGiftInfo {
38
+ text?: string
39
+ entities?: MessageEntity[]
40
+ is_private?: boolean
41
+ [key: string]: any
42
+ }
43
+
44
+ /**
45
+ * Update when a user stops streaming/message generation.
46
+ */
47
+ export interface MessageGenerationStopped {
48
+ chat_id: number
49
+ draft_id: number
50
+ user?: User
51
+ }
52
+
53
+ /**
54
+ * Service message when a chat joins a community.
55
+ */
56
+ export interface CommunityChatJoined {
57
+ community: Community
58
+ chat: Chat
59
+ }
60
+
61
+ // ---------------------------------------------------------------------------
62
+ // Bot API 10.2 (July 14, 2026)
63
+ // ---------------------------------------------------------------------------
64
+
65
+ /**
66
+ * Represents a community — group of chats and channels linked together.
67
+ */
68
+ export interface Community {
69
+ id: number
70
+ title: string
71
+ username?: string
72
+ is_channel?: boolean
73
+ }
74
+
75
+ /**
76
+ * Service message when a chat is added to a community.
77
+ */
78
+ export interface CommunityChatAdded {
79
+ community: Community
80
+ chat: Chat
81
+ }
82
+
83
+ /**
84
+ * Service message when a chat is removed from a community.
85
+ */
86
+ export interface CommunityChatRemoved {
87
+ community: Community
88
+ chat: Chat
89
+ }
90
+
91
+ /**
92
+ * Represents an update to a user payment subscription.
93
+ */
94
+ export interface BotSubscriptionUpdated {
95
+ chat: Chat
96
+ user?: User
97
+ date: number
98
+ subscription_expiration_date?: number
99
+ is_canceled?: boolean
100
+ }
101
+
102
+ // ---------------------------------------------------------------------------
103
+ // Bot API 10.1 (June 11, 2026)
104
+ // ---------------------------------------------------------------------------
105
+
106
+ /**
107
+ * Represents a link in poll media.
108
+ */
109
+ export interface PollMediaLink {
110
+ url: string
111
+ }
112
+
113
+ /**
114
+ * Input media link for poll options.
115
+ */
116
+ export interface InputMediaLink {
117
+ type: 'link'
118
+ url: string
119
+ }
120
+
121
+ // ---------------------------------------------------------------------------
122
+ // Bot API 10.0 (May 8, 2026)
123
+ // ---------------------------------------------------------------------------
124
+
125
+ /**
126
+ * Represents a live photo (photo with short video).
127
+ */
128
+ export interface LivePhoto {
129
+ file_id: string
130
+ file_unique_id: string
131
+ width: number
132
+ height: number
133
+ duration: number
134
+ file_size?: number
135
+ }
136
+
137
+ /**
138
+ * Input media representation for sending live photos.
139
+ */
140
+ export interface InputMediaLivePhoto<File = InputFile> {
141
+ type: 'live_photo'
142
+ media: string | File
143
+ video: string | File
144
+ caption?: string
145
+ parse_mode?: string
146
+ caption_entities?: MessageEntity[]
147
+ has_spoiler?: boolean
148
+ }
149
+
150
+ /**
151
+ * Describes paid media containing a live photo.
152
+ */
153
+ export interface PaidMediaLivePhoto {
154
+ type: 'live_photo'
155
+ photo: PhotoSize[]
156
+ video: Video
157
+ }
158
+
159
+ /**
160
+ * Input media representation for sending live photos as paid media.
161
+ */
162
+ export interface InputPaidMediaLivePhoto<File = InputFile> {
163
+ type: 'live_photo'
164
+ media: string | File
165
+ video: string | File
166
+ }
167
+
168
+ /**
169
+ * Represents a sent guest message.
170
+ */
171
+ export interface SentGuestMessage {
172
+ message_id: number
173
+ chat: Chat
174
+ }
175
+
176
+ /**
177
+ * Access settings for managed secretary bots.
178
+ */
179
+ export interface BotAccessSettings {
180
+ can_manage_messages?: boolean
181
+ can_send_messages?: boolean
182
+ can_read_messages?: boolean
183
+ can_post_messages?: boolean
184
+ can_edit_messages?: boolean
185
+ can_delete_messages?: boolean
186
+ [key: string]: any
187
+ }
@@ -15,16 +15,31 @@ export interface RichMessage {
15
15
  blocks: object[]
16
16
  is_rtl?: boolean
17
17
  }
18
+ export interface RichMessageButton {
19
+ text: string
20
+ url?: string
21
+ callback_data?: string
22
+ web_app?: any
23
+ [key: string]: any
24
+ }
25
+
26
+ export interface InputRichMessageMedia {
27
+ type: string
28
+ media: string
29
+ [key: string]: any
30
+ }
18
31
 
19
32
  /**
20
33
  * Describes a rich message to send.
21
- * Exactly ONE of `html` or `markdown` must be specified.
34
+ * Exactly ONE of `html` or `markdown` must be specified, or `blocks`.
22
35
  */
23
36
  export interface InputRichMessage {
24
37
  html?: string
25
38
  markdown?: string
26
39
  is_rtl?: boolean
27
40
  skip_entity_detection?: boolean
41
+ media?: InputRichMessageMedia[]
42
+ blocks?: object[]
28
43
  }
29
44
 
30
45
  /** Can be used as InputMessageContent in inline, guest, and Web App queries. */
@@ -139,11 +154,22 @@ export class RichHTMLBuilder {
139
154
  return this
140
155
  }
141
156
 
157
+ expandableBlockQuote(html: string) {
158
+ this._parts.push(`<blockquote expandable>${html}</blockquote>`)
159
+ return this
160
+ }
161
+
142
162
  pullQuote(html: string, cite?: string) {
143
163
  this._parts.push(`<aside>${html}${cite ? `<cite>${cite}</cite>` : ''}</aside>`)
144
164
  return this
145
165
  }
146
166
 
167
+ document(src: string, caption?: string) {
168
+ const doc = `<tg-document src="${src}"></tg-document>`
169
+ this._parts.push(caption ? `<figure>${doc}<figcaption>${caption}</figcaption></figure>` : doc)
170
+ return this
171
+ }
172
+
147
173
  photo(src: string, caption?: string, spoiler?: boolean) {
148
174
  const img = `<img src="${src}"${spoiler ? ' tg-spoiler' : ''}/>`
149
175
  this._parts.push(caption ? `<figure>${img}<figcaption>${caption}</figcaption></figure>` : img)
@@ -180,9 +206,13 @@ export class RichHTMLBuilder {
180
206
 
181
207
  table(
182
208
  rows: string[][],
183
- options?: { bordered?: boolean; striped?: boolean; hasHeader?: boolean }
209
+ options?: { bordered?: boolean; striped?: boolean; hasHeader?: boolean; isCompact?: boolean }
184
210
  ) {
185
- const attrs = [options?.bordered && 'bordered', options?.striped && 'striped']
211
+ const attrs = [
212
+ options?.bordered && 'bordered',
213
+ options?.striped && 'striped',
214
+ options?.isCompact && 'compact',
215
+ ]
186
216
  .filter(Boolean)
187
217
  .join(' ')
188
218
  const [header, ...body] = rows
@@ -1,6 +1,7 @@
1
1
  import * as Typegram from '@telegraf/types'
2
2
  export * from '@telegraf/types'
3
3
  export * from './rich-message'
4
+ export * from './bot-api-recent'
4
5
 
5
6
  // telegraf input file definition
6
7
  interface InputFileByPath {
package/src/future.ts CHANGED
@@ -123,6 +123,10 @@ const replyContext: ReplyContext = {
123
123
  this.assert(this.chat, 'replyWithPhoto')
124
124
  return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra))
125
125
  },
126
+ replyWithLivePhoto(this: Context, photo, video, extra) {
127
+ this.assert(this.chat, 'replyWithLivePhoto')
128
+ return this.telegram.sendLivePhoto(this.chat.id, photo, video, makeReply(this, extra))
129
+ },
126
130
  replyWithPoll(this: Context, question, options, extra) {
127
131
  this.assert(this.chat, 'replyWithPoll')
128
132
  return this.telegram.sendPoll(
@@ -226,6 +230,7 @@ export function useNewReplies<C extends Context>(): Middleware<C> {
226
230
  ctx.replyWithHTML = replyContext.replyWithHTML
227
231
  ctx.replyWithRichMessage = replyContext.replyWithRichMessage
228
232
  ctx.replyWithRichMessageContent = replyContext.replyWithRichMessageContent
233
+ ctx.replyWithLivePhoto = replyContext.replyWithLivePhoto
229
234
  return next()
230
235
  }
231
236
  }
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ export { session, MemorySessionStore, SessionStore } from './session'
16
16
 
17
17
  export * as Scenes from './scenes'
18
18
  export * as RichMessage from './core/types/rich-message'
19
+ export * as RecentTypes from './core/types/bot-api-recent'
19
20
  export { RichHTMLBuilder, RichMarkdownBuilder, RichHTMLBuilder as HTML, MD } from './core/types/rich-message'
20
21
 
21
22
  export { SmartQueue } from './core/helpers/smart-queue'
@@ -16,6 +16,8 @@ import {
16
16
  ForceReply,
17
17
  ReplyParameters,
18
18
  ParseMode,
19
+ MessageEntity,
20
+ EphemeralMessageParameters,
19
21
  } from './core/types/typegram'
20
22
  import type { InputRichMessage } from './core/types/rich-message'
21
23
 
@@ -239,11 +241,14 @@ export type ExtraSendRichMessage = {
239
241
  message_effect_id?: string
240
242
  reply_parameters?: ReplyParameters
241
243
  reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply
244
+ ephemeral_message_parameters?: EphemeralMessageParameters
242
245
  }
243
246
 
244
247
  /** sendRichMessageDraft only works in private chats; chat_id must be a number. */
245
248
  export type ExtraSendRichMessageDraft = {
246
249
  message_thread_id?: number
250
+ can_stop?: boolean
251
+ keep_on_stop?: boolean
247
252
  }
248
253
 
249
254
  export type ExtraEditMessageRichText = {
@@ -254,3 +259,70 @@ export type ExtraEditMessageRichText = {
254
259
  parse_mode?: ParseMode
255
260
  reply_markup?: InlineKeyboardMarkup
256
261
  }
262
+
263
+ // ---------------------------------------------------------------------------
264
+ // Bot API 10.0 - 10.3 Extra types
265
+ // ---------------------------------------------------------------------------
266
+
267
+ export type ExtraSendLivePhoto = {
268
+ business_connection_id?: string
269
+ message_thread_id?: number
270
+ caption?: string
271
+ parse_mode?: ParseMode
272
+ caption_entities?: MessageEntity[]
273
+ has_spoiler?: boolean
274
+ disable_notification?: boolean
275
+ protect_content?: boolean
276
+ message_effect_id?: string
277
+ reply_parameters?: ReplyParameters
278
+ reply_markup?: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply
279
+ ephemeral_message_parameters?: EphemeralMessageParameters
280
+ allow_paid_broadcast?: boolean
281
+ }
282
+
283
+ export type ExtraEditEphemeralMessageText = {
284
+ parse_mode?: ParseMode
285
+ entities?: MessageEntity[]
286
+ rich_message?: InputRichMessage
287
+ link_preview_options?: any
288
+ reply_markup?: InlineKeyboardMarkup
289
+ }
290
+
291
+ export type ExtraEditEphemeralMessageMedia = {
292
+ reply_markup?: InlineKeyboardMarkup
293
+ }
294
+
295
+ export type ExtraEditEphemeralMessageCaption = {
296
+ caption?: string
297
+ parse_mode?: ParseMode
298
+ caption_entities?: MessageEntity[]
299
+ show_caption_above_media?: boolean
300
+ reply_markup?: InlineKeyboardMarkup
301
+ }
302
+
303
+ export type ExtraSendMessageDraft = {
304
+ message_thread_id?: number
305
+ can_stop?: boolean
306
+ keep_on_stop?: boolean
307
+ parse_mode?: ParseMode
308
+ entities?: MessageEntity[]
309
+ }
310
+
311
+ export type ExtraAnswerGuestQuery = {
312
+ cache_time?: number
313
+ is_personal?: boolean
314
+ next_offset?: string
315
+ }
316
+
317
+ export type ExtraAnswerChatJoinRequestQuery = {
318
+ error_message?: string
319
+ }
320
+
321
+ export type ExtraSendChatJoinRequestWebApp = {
322
+ button_text?: string
323
+ }
324
+
325
+ export type ExtraDeleteMessageReaction = {
326
+ user_id?: number
327
+ reaction?: any[]
328
+ }
package/src/telegram.ts CHANGED
@@ -1762,6 +1762,237 @@ export class Telegram extends ApiClient {
1762
1762
  throw err
1763
1763
  }
1764
1764
  }
1765
+
1766
+ // -------------------------------------------------------------------------
1767
+ // Bot API 10.0 - 10.3 Methods
1768
+ // -------------------------------------------------------------------------
1769
+
1770
+ /**
1771
+ * Send a live photo (photo with short video).
1772
+ * @see https://core.telegram.org/bots/api#sendlivephoto
1773
+ */
1774
+ sendLivePhoto(
1775
+ chatId: number | string,
1776
+ photo: tg.InputFile | string,
1777
+ video: tg.InputFile | string,
1778
+ extra?: tt.ExtraSendLivePhoto
1779
+ ) {
1780
+ return this.callApi('sendLivePhoto' as never, {
1781
+ chat_id: chatId,
1782
+ photo,
1783
+ video,
1784
+ ...extra,
1785
+ } as never)
1786
+ }
1787
+
1788
+ /**
1789
+ * Edit an ephemeral message text.
1790
+ * @see https://core.telegram.org/bots/api#editephemeralmessagetext
1791
+ */
1792
+ editEphemeralMessageText(
1793
+ chatId: number | string,
1794
+ messageId: number,
1795
+ text: string,
1796
+ extra?: tt.ExtraEditEphemeralMessageText
1797
+ ) {
1798
+ return this.callApi('editEphemeralMessageText' as never, {
1799
+ chat_id: chatId,
1800
+ message_id: messageId,
1801
+ text,
1802
+ ...extra,
1803
+ } as never)
1804
+ }
1805
+
1806
+ /**
1807
+ * Edit an ephemeral message media.
1808
+ * @see https://core.telegram.org/bots/api#editephemeralmessagemedia
1809
+ */
1810
+ editEphemeralMessageMedia(
1811
+ chatId: number | string,
1812
+ messageId: number,
1813
+ media: tg.InputMedia,
1814
+ extra?: tt.ExtraEditEphemeralMessageMedia
1815
+ ) {
1816
+ return this.callApi('editEphemeralMessageMedia' as never, {
1817
+ chat_id: chatId,
1818
+ message_id: messageId,
1819
+ media,
1820
+ ...extra,
1821
+ } as never)
1822
+ }
1823
+
1824
+ /**
1825
+ * Edit an ephemeral message caption.
1826
+ * @see https://core.telegram.org/bots/api#editephemeralmessagecaption
1827
+ */
1828
+ editEphemeralMessageCaption(
1829
+ chatId: number | string,
1830
+ messageId: number,
1831
+ extra?: tt.ExtraEditEphemeralMessageCaption
1832
+ ) {
1833
+ return this.callApi('editEphemeralMessageCaption' as never, {
1834
+ chat_id: chatId,
1835
+ message_id: messageId,
1836
+ ...extra,
1837
+ } as never)
1838
+ }
1839
+
1840
+ /**
1841
+ * Edit an ephemeral message reply markup.
1842
+ * @see https://core.telegram.org/bots/api#editephemeralmessagereplymarkup
1843
+ */
1844
+ editEphemeralMessageReplyMarkup(
1845
+ chatId: number | string,
1846
+ messageId: number,
1847
+ replyMarkup?: tg.InlineKeyboardMarkup
1848
+ ) {
1849
+ return this.callApi('editEphemeralMessageReplyMarkup' as never, {
1850
+ chat_id: chatId,
1851
+ message_id: messageId,
1852
+ reply_markup: replyMarkup,
1853
+ } as never)
1854
+ }
1855
+
1856
+ /**
1857
+ * Delete an ephemeral message.
1858
+ * @see https://core.telegram.org/bots/api#deleteephemeralmessage
1859
+ */
1860
+ deleteEphemeralMessage(chatId: number | string, messageId: number) {
1861
+ return this.callApi('deleteEphemeralMessage' as never, {
1862
+ chat_id: chatId,
1863
+ message_id: messageId,
1864
+ } as never)
1865
+ }
1866
+
1867
+ /**
1868
+ * Send a streaming message draft (private chats only).
1869
+ * @see https://core.telegram.org/bots/api#sendmessagedraft
1870
+ */
1871
+ sendMessageDraft(
1872
+ chatId: number,
1873
+ draftId: number,
1874
+ text: string,
1875
+ extra?: tt.ExtraSendMessageDraft
1876
+ ) {
1877
+ return this.callApi('sendMessageDraft' as never, {
1878
+ chat_id: chatId,
1879
+ draft_id: draftId,
1880
+ text,
1881
+ ...extra,
1882
+ } as never)
1883
+ }
1884
+
1885
+ /**
1886
+ * Answer a guest query.
1887
+ * @see https://core.telegram.org/bots/api#answerguestquery
1888
+ */
1889
+ answerGuestQuery(
1890
+ guestQueryId: string,
1891
+ result: any,
1892
+ extra?: tt.ExtraAnswerGuestQuery
1893
+ ) {
1894
+ return this.callApi('answerGuestQuery' as never, {
1895
+ guest_query_id: guestQueryId,
1896
+ result,
1897
+ ...extra,
1898
+ } as never)
1899
+ }
1900
+
1901
+ /**
1902
+ * Answer a chat join request query.
1903
+ * @see https://core.telegram.org/bots/api#answerchatjoinrequestquery
1904
+ */
1905
+ answerChatJoinRequestQuery(
1906
+ queryId: string,
1907
+ isApproved: boolean,
1908
+ extra?: tt.ExtraAnswerChatJoinRequestQuery
1909
+ ) {
1910
+ return this.callApi('answerChatJoinRequestQuery' as never, {
1911
+ query_id: queryId,
1912
+ is_approved: isApproved,
1913
+ ...extra,
1914
+ } as never)
1915
+ }
1916
+
1917
+ /**
1918
+ * Send a Web App to verify or complete a chat join request.
1919
+ * @see https://core.telegram.org/bots/api#sendchatjoinrequestwebapp
1920
+ */
1921
+ sendChatJoinRequestWebApp(
1922
+ queryId: string,
1923
+ webAppUrl: string,
1924
+ extra?: tt.ExtraSendChatJoinRequestWebApp
1925
+ ) {
1926
+ return this.callApi('sendChatJoinRequestWebApp' as never, {
1927
+ query_id: queryId,
1928
+ web_app_url: webAppUrl,
1929
+ ...extra,
1930
+ } as never)
1931
+ }
1932
+
1933
+ /**
1934
+ * Delete all reactions from a message.
1935
+ * @see https://core.telegram.org/bots/api#deleteallmessagereactions
1936
+ */
1937
+ deleteAllMessageReactions(chatId: number | string, messageId: number) {
1938
+ return this.callApi('deleteAllMessageReactions' as never, {
1939
+ chat_id: chatId,
1940
+ message_id: messageId,
1941
+ } as never)
1942
+ }
1943
+
1944
+ /**
1945
+ * Delete a specific reaction on a message.
1946
+ * @see https://core.telegram.org/bots/api#deletemessagereaction
1947
+ */
1948
+ deleteMessageReaction(
1949
+ chatId: number | string,
1950
+ messageId: number,
1951
+ extra?: tt.ExtraDeleteMessageReaction
1952
+ ) {
1953
+ return this.callApi('deleteMessageReaction' as never, {
1954
+ chat_id: chatId,
1955
+ message_id: messageId,
1956
+ ...extra,
1957
+ } as never)
1958
+ }
1959
+
1960
+ /**
1961
+ * Get access settings for a managed secretary bot.
1962
+ * @see https://core.telegram.org/bots/api#getmanagedbotaccesssettings
1963
+ */
1964
+ getManagedBotAccessSettings(userId: number) {
1965
+ return this.callApi('getManagedBotAccessSettings' as never, {
1966
+ user_id: userId,
1967
+ } as never)
1968
+ }
1969
+
1970
+ /**
1971
+ * Set access settings for a managed secretary bot.
1972
+ * @see https://core.telegram.org/bots/api#setmanagedbotaccesssettings
1973
+ */
1974
+ setManagedBotAccessSettings(userId: number, settings: tg.BotAccessSettings) {
1975
+ return this.callApi('setManagedBotAccessSettings' as never, {
1976
+ user_id: userId,
1977
+ ...settings,
1978
+ } as never)
1979
+ }
1980
+
1981
+ /**
1982
+ * Get personal chat messages managed by a secretary bot.
1983
+ * @see https://core.telegram.org/bots/api#getuserpersonalchatmessages
1984
+ */
1985
+ getUserPersonalChatMessages(
1986
+ userId: number,
1987
+ chatId: number | string,
1988
+ messageIds: number[]
1989
+ ) {
1990
+ return this.callApi('getUserPersonalChatMessages' as never, {
1991
+ user_id: userId,
1992
+ chat_id: chatId,
1993
+ message_ids: messageIds,
1994
+ } as never)
1995
+ }
1765
1996
  }
1766
1997
 
1767
1998
  export default Telegram