@mtcute/core 0.31.0 → 0.32.0

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 (148) hide show
  1. package/client.cjs +12 -0
  2. package/client.js +12 -0
  3. package/highlevel/client.d.cts +74 -9
  4. package/highlevel/client.d.ts +74 -9
  5. package/highlevel/methods/chats/build-peers-index.cjs +45 -0
  6. package/highlevel/methods/chats/build-peers-index.d.cts +13 -0
  7. package/highlevel/methods/chats/build-peers-index.d.ts +13 -0
  8. package/highlevel/methods/chats/build-peers-index.js +40 -0
  9. package/highlevel/methods/ephemeral/delete-all-welcome-messages.cjs +17 -0
  10. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.cts +8 -0
  11. package/highlevel/methods/ephemeral/delete-all-welcome-messages.d.ts +8 -0
  12. package/highlevel/methods/ephemeral/delete-all-welcome-messages.js +12 -0
  13. package/highlevel/methods/ephemeral/delete-ephemeral-message.cjs +1 -1
  14. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.cts +2 -2
  15. package/highlevel/methods/ephemeral/delete-ephemeral-message.d.ts +2 -2
  16. package/highlevel/methods/ephemeral/delete-ephemeral-message.js +1 -1
  17. package/highlevel/methods/ephemeral/delete-welcome-message.cjs +18 -0
  18. package/highlevel/methods/ephemeral/delete-welcome-message.d.cts +9 -0
  19. package/highlevel/methods/ephemeral/delete-welcome-message.d.ts +9 -0
  20. package/highlevel/methods/ephemeral/delete-welcome-message.js +13 -0
  21. package/highlevel/methods/ephemeral/edit-ephemeral-message.cjs +11 -3
  22. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.cts +16 -2
  23. package/highlevel/methods/ephemeral/edit-ephemeral-message.d.ts +16 -2
  24. package/highlevel/methods/ephemeral/edit-ephemeral-message.js +11 -3
  25. package/highlevel/methods/ephemeral/get-welcome-messages.cjs +29 -0
  26. package/highlevel/methods/ephemeral/get-welcome-messages.d.cts +8 -0
  27. package/highlevel/methods/ephemeral/get-welcome-messages.d.ts +8 -0
  28. package/highlevel/methods/ephemeral/get-welcome-messages.js +24 -0
  29. package/highlevel/methods/ephemeral/send-ephemeral-message.cjs +13 -3
  30. package/highlevel/methods/ephemeral/send-ephemeral-message.d.cts +20 -2
  31. package/highlevel/methods/ephemeral/send-ephemeral-message.d.ts +20 -2
  32. package/highlevel/methods/ephemeral/send-ephemeral-message.js +13 -3
  33. package/highlevel/methods/files/download-iterable.cjs +3 -0
  34. package/highlevel/methods/files/download-iterable.js +3 -0
  35. package/highlevel/methods/files/normalize-input-media.cjs +25 -4
  36. package/highlevel/methods/files/normalize-input-media.js +25 -4
  37. package/highlevel/methods/forums/edit-forum-topic.cjs +1 -1
  38. package/highlevel/methods/forums/edit-forum-topic.js +1 -1
  39. package/highlevel/methods/forums/toggle-forum-topic-closed.cjs +1 -1
  40. package/highlevel/methods/forums/toggle-forum-topic-closed.js +1 -1
  41. package/highlevel/methods/forums/toggle-general-topic-hidden.cjs +1 -1
  42. package/highlevel/methods/forums/toggle-general-topic-hidden.js +1 -1
  43. package/highlevel/methods/gifts/buy-resale-gift.cjs +5 -2
  44. package/highlevel/methods/gifts/buy-resale-gift.d.cts +11 -1
  45. package/highlevel/methods/gifts/buy-resale-gift.d.ts +11 -1
  46. package/highlevel/methods/gifts/buy-resale-gift.js +5 -2
  47. package/highlevel/methods/messages/forward-messages.cjs +1 -0
  48. package/highlevel/methods/messages/forward-messages.d.cts +2 -0
  49. package/highlevel/methods/messages/forward-messages.d.ts +2 -0
  50. package/highlevel/methods/messages/forward-messages.js +1 -0
  51. package/highlevel/methods/messages/normalize-rich-message.cjs +3 -0
  52. package/highlevel/methods/messages/normalize-rich-message.js +3 -0
  53. package/highlevel/methods/messages/send-text.cjs +2 -33
  54. package/highlevel/methods/messages/send-text.js +2 -33
  55. package/highlevel/methods/messages/send-typing.d.cts +3 -3
  56. package/highlevel/methods/messages/send-typing.d.ts +3 -3
  57. package/highlevel/methods/messages/set-typing.cjs +1 -1
  58. package/highlevel/methods/messages/set-typing.d.cts +2 -2
  59. package/highlevel/methods/messages/set-typing.d.ts +2 -2
  60. package/highlevel/methods/messages/set-typing.js +1 -1
  61. package/highlevel/methods.d.cts +3 -0
  62. package/highlevel/methods.d.ts +3 -0
  63. package/highlevel/types/bots/keyboards/builder.cjs +5 -5
  64. package/highlevel/types/bots/keyboards/builder.d.cts +8 -9
  65. package/highlevel/types/bots/keyboards/builder.d.ts +8 -9
  66. package/highlevel/types/bots/keyboards/builder.js +5 -5
  67. package/highlevel/types/bots/keyboards/factories.cjs +51 -103
  68. package/highlevel/types/bots/keyboards/factories.d.cts +58 -89
  69. package/highlevel/types/bots/keyboards/factories.d.ts +58 -89
  70. package/highlevel/types/bots/keyboards/factories.js +51 -103
  71. package/highlevel/types/bots/keyboards/index.d.cts +3 -3
  72. package/highlevel/types/bots/keyboards/index.d.ts +3 -3
  73. package/highlevel/types/bots/keyboards/normalize.cjs +131 -0
  74. package/highlevel/types/bots/keyboards/normalize.d.cts +10 -0
  75. package/highlevel/types/bots/keyboards/normalize.d.ts +10 -0
  76. package/highlevel/types/bots/keyboards/normalize.js +126 -0
  77. package/highlevel/types/bots/keyboards/types.d.cts +160 -4
  78. package/highlevel/types/bots/keyboards/types.d.ts +160 -4
  79. package/highlevel/types/messages/dialog.cjs +8 -1
  80. package/highlevel/types/messages/dialog.d.cts +3 -0
  81. package/highlevel/types/messages/dialog.d.ts +3 -0
  82. package/highlevel/types/messages/dialog.js +8 -1
  83. package/highlevel/types/messages/dialog.test.d.cts +1 -0
  84. package/highlevel/types/messages/dialog.test.d.ts +1 -0
  85. package/highlevel/types/messages/ephemeral-message.cjs +35 -3
  86. package/highlevel/types/messages/ephemeral-message.d.cts +22 -2
  87. package/highlevel/types/messages/ephemeral-message.d.ts +22 -2
  88. package/highlevel/types/messages/ephemeral-message.js +35 -3
  89. package/highlevel/types/messages/message-action.cjs +8 -1
  90. package/highlevel/types/messages/message-action.d.cts +11 -1
  91. package/highlevel/types/messages/message-action.d.ts +11 -1
  92. package/highlevel/types/messages/message-action.js +8 -1
  93. package/highlevel/types/messages/message.cjs +7 -2
  94. package/highlevel/types/messages/message.d.cts +2 -2
  95. package/highlevel/types/messages/message.d.ts +2 -2
  96. package/highlevel/types/messages/message.js +8 -3
  97. package/highlevel/types/messages/rich/inner.cjs +37 -0
  98. package/highlevel/types/messages/rich/inner.d.cts +19 -0
  99. package/highlevel/types/messages/rich/inner.d.ts +19 -0
  100. package/highlevel/types/messages/rich/inner.js +37 -0
  101. package/highlevel/types/peers/full-chat.cjs +4 -0
  102. package/highlevel/types/peers/full-chat.d.cts +2 -0
  103. package/highlevel/types/peers/full-chat.d.ts +2 -0
  104. package/highlevel/types/peers/full-chat.js +4 -0
  105. package/highlevel/types/peers/typing-status.d.cts +4 -1
  106. package/highlevel/types/peers/typing-status.d.ts +4 -1
  107. package/highlevel/types/updates/ephemeral-callback-query.cjs +10 -2
  108. package/highlevel/types/updates/ephemeral-callback-query.d.cts +8 -2
  109. package/highlevel/types/updates/ephemeral-callback-query.d.ts +8 -2
  110. package/highlevel/types/updates/ephemeral-callback-query.js +10 -2
  111. package/highlevel/types/updates/user-typing-update.cjs +18 -0
  112. package/highlevel/types/updates/user-typing-update.d.cts +9 -0
  113. package/highlevel/types/updates/user-typing-update.d.ts +9 -0
  114. package/highlevel/types/updates/user-typing-update.js +18 -0
  115. package/highlevel/updates/manager.cjs +40 -28
  116. package/highlevel/updates/manager.js +40 -28
  117. package/highlevel/utils/walk-page-blocks.cjs +5 -0
  118. package/highlevel/utils/walk-page-blocks.js +5 -0
  119. package/methods.cjs +6 -0
  120. package/methods.js +6 -0
  121. package/network/mtproto-session.cjs +9 -2
  122. package/network/mtproto-session.d.cts +3 -1
  123. package/network/mtproto-session.d.ts +3 -1
  124. package/network/mtproto-session.js +9 -2
  125. package/network/network-manager.cjs +1 -1
  126. package/network/network-manager.js +1 -1
  127. package/network/session-connection.cjs +12 -6
  128. package/network/session-connection.js +12 -6
  129. package/network/session-connection.test.d.cts +1 -0
  130. package/network/session-connection.test.d.ts +1 -0
  131. package/package.json +3 -3
  132. package/tl/api-schema.json +1 -1
  133. package/tl/binary/reader.cjs +136 -93
  134. package/tl/binary/reader.js +136 -93
  135. package/tl/binary/writer.cjs +318 -207
  136. package/tl/binary/writer.js +318 -207
  137. package/tl/compat/reader.cjs +82 -0
  138. package/tl/compat/reader.js +82 -0
  139. package/tl/index.d.cts +377 -718
  140. package/tl/index.d.ts +377 -718
  141. package/tl/inner-tl.cjs +23 -7
  142. package/tl/inner-tl.js +23 -7
  143. package/tl/rpc-error.test.d.cts +1 -0
  144. package/tl/rpc-error.test.d.ts +1 -0
  145. package/utils/binary/compat.cjs +175 -29
  146. package/utils/binary/compat.js +175 -29
  147. package/utils/links/bots.cjs +9 -4
  148. package/utils/links/bots.js +9 -4
@@ -9,15 +9,19 @@ const utils = require("@fuman/utils");
9
9
  const utils$1 = require("../../../../types/utils.cjs");
10
10
  const peerUtils = require("../../../utils/peer-utils.cjs");
11
11
  const builder$1 = require("./builder.cjs");
12
+ const normalize = require("./normalize.cjs");
12
13
  const innerTl = require("../../../../tl/inner-tl.cjs");
13
14
  function builder(maxRowWidth) {
14
15
  return new builder$1.BotKeyboardBuilder(maxRowWidth);
15
16
  }
16
- function inline(buttons) {
17
- return {
18
- type: "inline",
19
- buttons
20
- };
17
+ function replyBuilder(maxRowWidth) {
18
+ return new builder$1.BotKeyboardBuilder(maxRowWidth);
19
+ }
20
+ function inline(buttons, params = {}) {
21
+ const ret = params;
22
+ ret.type = "inline";
23
+ ret.buttons = buttons;
24
+ return ret;
21
25
  }
22
26
  function reply(buttons, params = {}) {
23
27
  const ret = params;
@@ -36,116 +40,61 @@ function forceReply(params = {}) {
36
40
  ret.type = "force_reply";
37
41
  return ret;
38
42
  }
39
- function text(text2) {
40
- return {
41
- _: "keyboardButton",
42
- text: text2
43
- };
43
+ function text(text2, options) {
44
+ return { type: "text", text: text2, style: options?.style };
44
45
  }
45
- function requestContact(text2) {
46
- return {
47
- _: "keyboardButtonRequestPhone",
48
- text: text2
49
- };
46
+ function requestContact(text2, options) {
47
+ return { type: "request_contact", text: text2, style: options?.style };
50
48
  }
51
- function requestGeo(text2) {
52
- return {
53
- _: "keyboardButtonRequestGeoLocation",
54
- text: text2
55
- };
49
+ function requestGeo(text2, options) {
50
+ return { type: "request_geo", text: text2, style: options?.style };
56
51
  }
57
- function requestPoll(text2, quiz) {
58
- return {
59
- _: "keyboardButtonRequestPoll",
60
- text: text2,
61
- quiz
62
- };
52
+ function requestPoll(text2, quiz, options) {
53
+ return { type: "request_poll", text: text2, quiz, style: options?.style };
54
+ }
55
+ function requestPeer(text2, buttonId, params) {
56
+ return { ...params, type: "request_peer", text: text2, buttonId, style: params.style };
63
57
  }
64
58
  function url(text2, url2, options) {
65
- return {
66
- _: "keyboardButtonUrl",
67
- text: text2,
68
- url: url2,
69
- style: options?.style
70
- };
59
+ return { type: "url", text: text2, url: url2, style: options?.style };
71
60
  }
72
61
  function callback(text2, data, options) {
73
62
  return {
74
- _: "keyboardButtonCallback",
63
+ type: "callback",
75
64
  text: text2,
65
+ data: typeof data === "string" ? utils.utf8.encoder.encode(data) : data,
76
66
  requiresPassword: options?.requiresPassword,
77
- style: options?.style,
78
- data: typeof data === "string" ? utils.utf8.encoder.encode(data) : data
67
+ style: options?.style
79
68
  };
80
69
  }
81
70
  function switchInline(text2, options) {
82
- return {
83
- _: "keyboardButtonSwitchInline",
84
- samePeer: options?.currentChat,
85
- style: options?.style,
86
- text: text2,
87
- query: options?.query ?? ""
88
- };
71
+ return { ...options, type: "switch_inline", text: text2, style: options?.style };
89
72
  }
90
73
  function game(text2, options) {
91
- return { _: "keyboardButtonGame", text: text2, style: options?.style };
74
+ return { type: "game", text: text2, style: options?.style };
92
75
  }
93
76
  function pay(text2, options) {
94
- return { _: "keyboardButtonBuy", text: text2, style: options?.style };
77
+ return { type: "pay", text: text2, style: options?.style };
95
78
  }
96
79
  function urlAuth(text2, url2, params = {}) {
97
- return {
98
- _: "inputKeyboardButtonUrlAuth",
99
- text: text2,
100
- url: url2,
101
- bot: params.bot ?? {
102
- _: "inputUserSelf"
103
- },
104
- fwdText: params.fwdText,
105
- requestWriteAccess: params.requestWriteAccess,
106
- style: params.style
107
- };
80
+ return { ...params, type: "url_auth", text: text2, url: url2, style: params.style };
108
81
  }
109
82
  function webView(text2, url2, options) {
110
- return {
111
- _: "keyboardButtonWebView",
112
- text: text2,
113
- url: url2,
114
- style: options?.style
115
- };
83
+ return { type: "webview", text: text2, url: url2, style: options?.style };
116
84
  }
117
85
  function userProfile(text2, user, options) {
118
- return {
119
- _: "inputKeyboardButtonUserProfile",
120
- text: text2,
121
- userId: peerUtils.toInputUser(user),
122
- style: options?.style
123
- };
124
- }
125
- function requestPeer(text2, buttonId, params) {
126
- return {
127
- _: "keyboardButtonRequestPeer",
128
- text: text2,
129
- buttonId,
130
- peerType: params.peerType,
131
- maxQuantity: params.count ?? 1,
132
- style: params.style
133
- };
86
+ return { type: "user_profile", text: text2, user: peerUtils.toInputUser(user), style: options?.style };
134
87
  }
135
88
  function copy(params) {
136
- return {
137
- _: "keyboardButtonCopy",
138
- text: params.text,
139
- copyText: params?.copyText ?? params.text,
140
- style: params.style
141
- };
89
+ return { ...params, type: "copy", style: params.style };
90
+ }
91
+ function disabled(text2, options) {
92
+ return { type: "disabled", text: text2, style: options?.style };
142
93
  }
143
94
  function findButton(buttons, predicate) {
144
95
  if (typeof predicate === "string") {
145
96
  const text2 = predicate;
146
- predicate = (btn) => {
147
- return "text" in btn && btn.text === text2;
148
- };
97
+ predicate = (btn) => btn.text === text2;
149
98
  }
150
99
  for (const row of buttons) {
151
100
  for (const btn of row) {
@@ -159,21 +108,14 @@ function findButton(buttons, predicate) {
159
108
  function _rowsTo2d(rows) {
160
109
  return rows.map((it) => it.buttons);
161
110
  }
162
- function _2dToRows(arr, inline2) {
163
- return arr.map((row) => {
164
- if (!inline2) {
165
- row = row.map(
166
- (btn) => btn._ === "keyboardButtonWebView" ? {
167
- ...btn,
168
- _: "keyboardButtonSimpleWebView"
169
- } : btn
170
- );
171
- }
172
- return {
173
- _: "keyboardButtonRow",
174
- buttons: row
175
- };
176
- });
111
+ function _inlineRowsTo2d(rows) {
112
+ return rows.map((it) => it.buttons);
113
+ }
114
+ function _2dToRows(arr) {
115
+ return arr.map((row) => ({ _: "keyboardButtonRow", buttons: row.map(normalize._toReplyButton) }));
116
+ }
117
+ function _2dToInlineRows(arr) {
118
+ return arr.map((row) => ({ _: "keyboardInlineButtonRow", buttons: row.map(normalize._toInlineButton) }));
177
119
  }
178
120
  function _convertToTl(obj) {
179
121
  if (!obj) return obj;
@@ -186,8 +128,9 @@ function _convertToTl(obj) {
186
128
  singleUse: obj.singleUse,
187
129
  selective: obj.selective,
188
130
  persistent: obj.persistent,
131
+ forceReply: obj.forceReply,
189
132
  placeholder: obj.placeholder,
190
- rows: _2dToRows(obj.buttons, false)
133
+ rows: _2dToRows(obj.buttons)
191
134
  };
192
135
  case "reply_hide":
193
136
  return {
@@ -204,18 +147,22 @@ function _convertToTl(obj) {
204
147
  case "inline":
205
148
  return {
206
149
  _: "replyInlineMarkup",
207
- rows: _2dToRows(obj.buttons, true)
150
+ forceReply: obj.forceReply,
151
+ rows: _2dToInlineRows(obj.buttons)
208
152
  };
209
153
  default:
210
154
  utils$1.assertNever();
211
155
  }
212
156
  }
157
+ exports._2dToInlineRows = _2dToInlineRows;
213
158
  exports._2dToRows = _2dToRows;
214
159
  exports._convertToTl = _convertToTl;
160
+ exports._inlineRowsTo2d = _inlineRowsTo2d;
215
161
  exports._rowsTo2d = _rowsTo2d;
216
162
  exports.builder = builder;
217
163
  exports.callback = callback;
218
164
  exports.copy = copy;
165
+ exports.disabled = disabled;
219
166
  exports.findButton = findButton;
220
167
  exports.forceReply = forceReply;
221
168
  exports.game = game;
@@ -223,6 +170,7 @@ exports.hideReply = hideReply;
223
170
  exports.inline = inline;
224
171
  exports.pay = pay;
225
172
  exports.reply = reply;
173
+ exports.replyBuilder = replyBuilder;
226
174
  exports.requestContact = requestContact;
227
175
  exports.requestGeo = requestGeo;
228
176
  exports.requestPeer = requestPeer;
@@ -1,21 +1,24 @@
1
- import { InlineKeyboardMarkup, ReplyKeyboardForceReply, ReplyKeyboardHide, ReplyKeyboardMarkup, ReplyMarkup } from './types.js';
1
+ import { BotKeyboardButtonStyle, CallbackButton, CopyButton, DisabledButton, GameButton, InlineKeyboardMarkup, InputInlineKeyboardButton, InputReplyKeyboardButton, PayButton, ReplyKeyboardForceReply, ReplyKeyboardHide, ReplyKeyboardMarkup, ReplyMarkup, RequestContactButton, RequestGeoButton, RequestPeerButton, RequestPollButton, SwitchInlineButton, TextButton, UrlAuthButton, UrlButton, UserProfileButton, WebViewButton } from './types.js';
2
2
  import { tl } from '../../../../tl/index.js';
3
3
  import { BotKeyboardBuilder } from './builder.js';
4
- /** Create a keyboard builder */
5
- export declare function builder(maxRowWidth?: number | null): BotKeyboardBuilder;
4
+ /** Create a builder for an inline keyboard */
5
+ export declare function builder(maxRowWidth?: number | null): BotKeyboardBuilder<InputInlineKeyboardButton>;
6
+ /** Create a builder for a reply keyboard */
7
+ export declare function replyBuilder(maxRowWidth?: number | null): BotKeyboardBuilder<InputReplyKeyboardButton>;
6
8
  /**
7
9
  * Create an inline keyboard markup
8
10
  *
9
11
  * @param buttons Two-dimensional array of buttons
12
+ * @param params Additional parameters for the keyboard
10
13
  */
11
- export declare function inline(buttons: tl.TypeKeyboardButton[][]): InlineKeyboardMarkup;
14
+ export declare function inline(buttons: InputInlineKeyboardButton[][], params?: Omit<InlineKeyboardMarkup, 'type' | 'buttons'>): InlineKeyboardMarkup;
12
15
  /**
13
16
  * Create a reply keyboard markup
14
17
  *
15
18
  * @param buttons Two-dimensional array of buttons
16
19
  * @param params Additional parameters for the keyboard
17
20
  */
18
- export declare function reply(buttons: tl.TypeKeyboardButton[][], params?: Omit<ReplyKeyboardMarkup, 'type' | 'buttons'>): ReplyKeyboardMarkup;
21
+ export declare function reply(buttons: InputReplyKeyboardButton[][], params?: Omit<ReplyKeyboardMarkup, 'type' | 'buttons'>): ReplyKeyboardMarkup;
19
22
  /**
20
23
  * Hide the previously sent reply keyboard
21
24
  *
@@ -29,6 +32,9 @@ export declare function hideReply(selective?: boolean): ReplyKeyboardHide;
29
32
  * Force the user to send a reply
30
33
  */
31
34
  export declare function forceReply(params?: Omit<ReplyKeyboardForceReply, 'type'>): ReplyKeyboardForceReply;
35
+ interface ButtonOptions {
36
+ style?: BotKeyboardButtonStyle;
37
+ }
32
38
  /**
33
39
  * Create a text-only keyboard button.
34
40
  *
@@ -36,7 +42,7 @@ export declare function forceReply(params?: Omit<ReplyKeyboardForceReply, 'type'
36
42
  *
37
43
  * @param text Button text
38
44
  */
39
- export declare function text(text: string): tl.RawKeyboardButton;
45
+ export declare function text(text: string, options?: ButtonOptions): TextButton;
40
46
  /**
41
47
  * Create a keyboard button requesting for user's contact.
42
48
  * Available only for private chats.
@@ -45,7 +51,7 @@ export declare function text(text: string): tl.RawKeyboardButton;
45
51
  *
46
52
  * @param text Button text
47
53
  */
48
- export declare function requestContact(text: string): tl.RawKeyboardButtonRequestPhone;
54
+ export declare function requestContact(text: string, options?: ButtonOptions): RequestContactButton;
49
55
  /**
50
56
  * Create a keyboard button requesting for user's geo location.
51
57
  * Available only for private chats.
@@ -54,7 +60,7 @@ export declare function requestContact(text: string): tl.RawKeyboardButtonReques
54
60
  *
55
61
  * @param text Button text
56
62
  */
57
- export declare function requestGeo(text: string): tl.RawKeyboardButtonRequestGeoLocation;
63
+ export declare function requestGeo(text: string, options?: ButtonOptions): RequestGeoButton;
58
64
  /**
59
65
  * Create a keyboard button requesting the user to create and send a poll.
60
66
  * Available only for private chats.
@@ -64,7 +70,16 @@ export declare function requestGeo(text: string): tl.RawKeyboardButtonRequestGeo
64
70
  * @param text Button text
65
71
  * @param quiz If set, only quiz polls can be sent
66
72
  */
67
- export declare function requestPoll(text: string, quiz?: boolean): tl.RawKeyboardButtonRequestPoll;
73
+ export declare function requestPoll(text: string, quiz?: boolean, options?: ButtonOptions): RequestPollButton;
74
+ /**
75
+ * Button to request a peer from the user
76
+ *
77
+ * Used for reply keyboards, not inline!
78
+ *
79
+ * @param text Text of the button
80
+ * @param buttonId ID of the button that will later be passed to the service message
81
+ */
82
+ export declare function requestPeer(text: string, buttonId: number, params: ButtonOptions & Omit<RequestPeerButton, 'type' | 'text' | 'buttonId' | 'style'>): RequestPeerButton;
68
83
  /**
69
84
  * Create a keyboard button with a link.
70
85
  *
@@ -73,24 +88,22 @@ export declare function requestPoll(text: string, quiz?: boolean): tl.RawKeyboar
73
88
  * @param text Button text
74
89
  * @param url URL
75
90
  */
76
- export declare function url(text: string, url: string, options?: {
77
- style?: tl.RawKeyboardButtonStyle;
78
- }): tl.RawKeyboardButtonUrl;
91
+ export declare function url(text: string, url: string, options?: ButtonOptions): UrlButton;
79
92
  /**
80
- * Create a keyboard button with a link.
93
+ * Create a keyboard button with callback data.
81
94
  *
82
95
  * Used for inline keyboards, not reply!
83
96
  *
84
97
  * @param text Button text
85
98
  * @param data Callback data (1-64 bytes). String will be converted to `Buffer`
86
- * @param requiresPassword
87
- * Whether the user should verify their identity by entering 2FA password.
88
- * See more: {@link tl.RawKeyboardButtonCallback#requiresPassword}
89
99
  */
90
- export declare function callback(text: string, data: string | Uint8Array, options?: {
100
+ export declare function callback(text: string, data: string | Uint8Array, options?: ButtonOptions & {
101
+ /**
102
+ * Whether the user should verify their identity by entering 2FA password.
103
+ * See more: {@link tl.RawInlineButtonTypeCallback#requiresPassword}
104
+ */
91
105
  requiresPassword?: boolean;
92
- style?: tl.RawKeyboardButtonStyle;
93
- }): tl.RawKeyboardButtonCallback;
106
+ }): CallbackButton;
94
107
  /**
95
108
  * Button to force a user to switch to inline mode.
96
109
  *
@@ -101,20 +114,8 @@ export declare function callback(text: string, data: string | Uint8Array, option
101
114
  * Used for inline keyboards, not reply!
102
115
  *
103
116
  * @param text Button text
104
- * @param query Inline query (can be empty or omitted)
105
117
  */
106
- export declare function switchInline(text: string, options?: {
107
- /**
108
- * Inline query (can be empty or omitted)
109
- */
110
- query?: string;
111
- /**
112
- * If set, pressing the button will insert the bot's username
113
- * and the specified inline query in the current chat's input field
114
- */
115
- currentChat?: boolean;
116
- style?: tl.RawKeyboardButtonStyle;
117
- }): tl.RawKeyboardButtonSwitchInline;
118
+ export declare function switchInline(text: string, options?: ButtonOptions & Omit<SwitchInlineButton, 'type' | 'text' | 'style'>): SwitchInlineButton;
118
119
  /**
119
120
  * Button to start a game
120
121
  *
@@ -125,9 +126,7 @@ export declare function switchInline(text: string, options?: {
125
126
  * game is inferred from {@link InputMedia.game},
126
127
  * thus this button should only be used with it.
127
128
  */
128
- export declare function game(text: string, options?: {
129
- style?: tl.RawKeyboardButtonStyle;
130
- }): tl.RawKeyboardButtonGame;
129
+ export declare function game(text: string, options?: ButtonOptions): GameButton;
131
130
  /**
132
131
  * Button to pay for a product.
133
132
  *
@@ -138,95 +137,65 @@ export declare function game(text: string, options?: {
138
137
  * invoice is inferred from {@link InputMedia.invoice},
139
138
  * thus this button should only be used with it.
140
139
  */
141
- export declare function pay(text: string, options?: {
142
- style?: tl.RawKeyboardButtonStyle;
143
- }): tl.RawKeyboardButtonBuy;
140
+ export declare function pay(text: string, options?: ButtonOptions): PayButton;
144
141
  /**
145
142
  * Button to authorize a user
146
143
  *
147
144
  * Used for inline keyboards, not reply!
148
145
  *
149
146
  * @param text Button label
150
- * @param url Authorization URL (see {@link tl.RawInputKeyboardButtonUrlAuth})
147
+ * @param url Authorization URL (see {@link tl.RawInputInlineButtonTypeUrlAuth})
151
148
  * @param params
152
149
  */
153
- export declare function urlAuth(text: string, url: string, params?: {
154
- /**
155
- * Button label when forwarded
156
- */
157
- fwdText?: string;
158
- /**
159
- * Whether to request the permission for
160
- * your bot to send messages to the user
161
- */
162
- requestWriteAccess?: boolean;
163
- style?: tl.RawKeyboardButtonStyle;
164
- /**
165
- * Bot, which will be used for user authorization.
166
- * `url` domain must be the same as the domain linked
167
- * with the bot.
168
- *
169
- * @default current bot
170
- */
171
- bot?: tl.TypeInputUser;
172
- }): tl.RawInputKeyboardButtonUrlAuth;
150
+ export declare function urlAuth(text: string, url: string, params?: ButtonOptions & Omit<UrlAuthButton, 'type' | 'text' | 'url' | 'style'>): UrlAuthButton;
173
151
  /**
174
152
  * Button to open webview
175
153
  *
176
154
  * Used for both inline keyboards and reply ones
155
+ * (in the latter case it is sent as a simple webview button)
177
156
  *
178
157
  * @param text Button label
179
158
  * @param url WebView URL
180
159
  */
181
- export declare function webView(text: string, url: string, options?: {
182
- style?: tl.RawKeyboardButtonStyle;
183
- }): tl.RawKeyboardButtonWebView;
160
+ export declare function webView(text: string, url: string, options?: ButtonOptions): WebViewButton;
184
161
  /**
185
162
  * Button to open user profile
186
163
  *
164
+ * Used for inline keyboards, not reply!
165
+ *
187
166
  * @param text Text of the button
188
167
  * @param user User to be opened (use {@link TelegramClient.resolvePeer})
189
168
  */
190
- export declare function userProfile(text: string, user: tl.TypeInputPeer, options?: {
191
- style?: tl.RawKeyboardButtonStyle;
192
- }): tl.RawInputKeyboardButtonUserProfile;
169
+ export declare function userProfile(text: string, user: tl.TypeInputPeer, options?: ButtonOptions): UserProfileButton;
193
170
  /**
194
- * Button to request a peer from the user
171
+ * Button to copy text to the user's clipboard
195
172
  *
196
- * @param text Text of the button
197
- * @param buttonId ID of the button that will later be passed to the service message
173
+ * Used for inline keyboards, not reply!
198
174
  */
199
- export declare function requestPeer(text: string, buttonId: number, params: {
200
- /**
201
- * Peer type, along with filters
202
- */
203
- peerType: tl.TypeRequestPeerType;
204
- /**
205
- * Maximum number of peers to be selected
206
- *
207
- * @default 1
208
- */
209
- count?: number;
210
- style?: tl.RawKeyboardButtonStyle;
211
- }): tl.RawKeyboardButtonRequestPeer;
175
+ export declare function copy(params: ButtonOptions & Omit<CopyButton, 'type' | 'style'>): CopyButton;
212
176
  /**
213
- * Button to copy text to the user's clipboard
177
+ * Button that does nothing when pressed
178
+ *
179
+ * Used for inline keyboards, not reply!
214
180
  */
215
- export declare function copy(params: {
216
- text: string;
217
- copyText?: string;
218
- style?: tl.RawKeyboardButtonStyle;
219
- }): tl.RawKeyboardButtonCopy;
181
+ export declare function disabled(text: string, options?: ButtonOptions): DisabledButton;
220
182
  /**
221
183
  * Find a button in the keyboard by its text or by predicate
222
184
  *
223
185
  * @param buttons Two-dimensional array of buttons
224
186
  * @param predicate Button text or predicate function
225
187
  */
226
- export declare function findButton(buttons: tl.TypeKeyboardButton[][], predicate: string | ((btn: tl.TypeKeyboardButton) => boolean)): tl.TypeKeyboardButton | null;
188
+ export declare function findButton<T extends {
189
+ text: string;
190
+ }>(buttons: T[][], predicate: string | ((btn: T) => boolean)): T | null;
227
191
  /** @internal */
228
192
  export declare function _rowsTo2d(rows: tl.RawKeyboardButtonRow[]): tl.TypeKeyboardButton[][];
229
193
  /** @internal */
230
- export declare function _2dToRows(arr: tl.TypeKeyboardButton[][], inline: boolean): tl.RawKeyboardButtonRow[];
194
+ export declare function _inlineRowsTo2d(rows: tl.RawKeyboardInlineButtonRow[]): tl.TypeKeyboardInlineButton[][];
195
+ /** @internal */
196
+ export declare function _2dToRows(arr: InputReplyKeyboardButton[][]): tl.RawKeyboardButtonRow[];
197
+ /** @internal */
198
+ export declare function _2dToInlineRows(arr: InputInlineKeyboardButton[][]): tl.RawKeyboardInlineButtonRow[];
231
199
  /** @internal */
232
200
  export declare function _convertToTl(obj?: ReplyMarkup): tl.TypeReplyMarkup | undefined;
201
+ export {};