grammy 1.12.4 → 1.13.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.
- package/README.md +1 -1
- package/out/context.d.ts +75 -11
- package/out/context.js +79 -8
- package/out/convenience/keyboard.d.ts +18 -0
- package/out/convenience/keyboard.js +15 -0
- package/out/convenience/session.js +3 -0
- package/out/core/api.d.ts +51 -5
- package/out/core/api.js +63 -12
- package/out/filter.d.ts +24 -12
- package/out/filter.js +8 -3
- package/out/web.mjs +86 -13
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<!-- deno-fmt-ignore-start -->
|
|
12
12
|
|
|
13
|
-
[](https://core.telegram.org/bots/api)
|
|
14
14
|
[](https://deno.land/x/grammy)
|
|
15
15
|
[](https://www.npmjs.org/package/grammy)
|
|
16
16
|
[](#contributors-)
|
package/out/context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Api, type Other as OtherApi } from "./core/api.js";
|
|
2
2
|
import { type Methods, type RawApi } from "./core/client.js";
|
|
3
3
|
import { type Filter, type FilterCore, type FilterQuery } from "./filter.js";
|
|
4
|
-
import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type LabeledPrice, type Message, type PassportElementError, type Update, type User, type UserFromGetMe } from "./types.js";
|
|
4
|
+
import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type Update, type User, type UserFromGetMe } from "./types.js";
|
|
5
5
|
export type MaybeArray<T> = T | T[];
|
|
6
6
|
export type StringWithSuggestions<S extends string> = (string & {}) | S;
|
|
7
7
|
type Other<M extends Methods<RawApi>, X extends string = never> = OtherApi<RawApi, M, X>;
|
|
@@ -138,13 +138,13 @@ export declare class Context implements RenamedUpdate {
|
|
|
138
138
|
*/
|
|
139
139
|
me: UserFromGetMe);
|
|
140
140
|
/** Alias for `ctx.update.message` */
|
|
141
|
-
get message(): Message | undefined;
|
|
141
|
+
get message(): (Message & Update.New & Update.NonChannel) | undefined;
|
|
142
142
|
/** Alias for `ctx.update.edited_message` */
|
|
143
|
-
get editedMessage(): Message | undefined;
|
|
143
|
+
get editedMessage(): (Message & Update.Edited & Update.NonChannel) | undefined;
|
|
144
144
|
/** Alias for `ctx.update.channel_post` */
|
|
145
|
-
get channelPost(): Message | undefined;
|
|
145
|
+
get channelPost(): (Message & Update.New & Update.Channel) | undefined;
|
|
146
146
|
/** Alias for `ctx.update.edited_channel_post` */
|
|
147
|
-
get editedChannelPost(): Message | undefined;
|
|
147
|
+
get editedChannelPost(): (Message & Update.Edited & Update.Channel) | undefined;
|
|
148
148
|
/** Alias for `ctx.update.inline_query` */
|
|
149
149
|
get inlineQuery(): import("@grammyjs/types/inline.js").InlineQuery | undefined;
|
|
150
150
|
/** Alias for `ctx.update.chosen_inline_result` */
|
|
@@ -193,6 +193,29 @@ export declare class Context implements RenamedUpdate {
|
|
|
193
193
|
* `(ctx.callbackQuery ?? ctx.chosenInlineResult)?.inline_message_id`
|
|
194
194
|
*/
|
|
195
195
|
get inlineMessageId(): string | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* Get entities and their text. Extracts the text from `ctx.msg.text` or `ctx.msg.caption`.
|
|
198
|
+
* Returns an empty array if one of `ctx.msg`, `ctx.msg.text`
|
|
199
|
+
* or `ctx.msg.entities` is undefined.
|
|
200
|
+
*
|
|
201
|
+
* You can filter specific entity types by passing the `types` parameter. Example:
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* ctx.entities() // Returns all entity types
|
|
205
|
+
* ctx.entities('url') // Returns only url entities
|
|
206
|
+
* ctx.enttities(['url', 'email']) // Returns url and email entities
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @param types Types of entities to return. Omit to get all entities.
|
|
210
|
+
* @returns Array of entities and their texts, or empty array when there's no text
|
|
211
|
+
*/
|
|
212
|
+
entities(): Array<MessageEntity & {
|
|
213
|
+
text: string;
|
|
214
|
+
}>;
|
|
215
|
+
entities<T extends MessageEntity["type"]>(types: MaybeArray<T>): Array<MessageEntity & {
|
|
216
|
+
type: T;
|
|
217
|
+
text: string;
|
|
218
|
+
}>;
|
|
196
219
|
/**
|
|
197
220
|
* `Context.has` is an object that contains a number of useful functions for
|
|
198
221
|
* probing context objects. Each of these functions can generate a predicate
|
|
@@ -466,11 +489,12 @@ export declare class Context implements RenamedUpdate {
|
|
|
466
489
|
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
467
490
|
*
|
|
468
491
|
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
492
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
469
493
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
470
494
|
*
|
|
471
495
|
* **Official reference:** https://core.telegram.org/bots/api#sendchataction
|
|
472
496
|
*/
|
|
473
|
-
replyWithChatAction(action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", signal?: AbortSignal): Promise<true>;
|
|
497
|
+
replyWithChatAction(action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", other?: Other<"sendChatAction", "chat_id" | "action">, signal?: AbortSignal): Promise<true>;
|
|
474
498
|
/**
|
|
475
499
|
* Context-aware alias for `api.getUserProfilePhotos`. Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
476
500
|
*
|
|
@@ -762,7 +786,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
762
786
|
*/
|
|
763
787
|
getChatMemberCount(signal?: AbortSignal): Promise<number>;
|
|
764
788
|
/**
|
|
765
|
-
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
789
|
+
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
766
790
|
*
|
|
767
791
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
768
792
|
*
|
|
@@ -770,7 +794,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
770
794
|
*/
|
|
771
795
|
getAuthor(signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatMember>;
|
|
772
796
|
/**
|
|
773
|
-
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
797
|
+
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
774
798
|
*
|
|
775
799
|
* @param user_id Unique identifier of the target user
|
|
776
800
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -808,13 +832,12 @@ export declare class Context implements RenamedUpdate {
|
|
|
808
832
|
/**
|
|
809
833
|
* Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
810
834
|
*
|
|
811
|
-
* @param
|
|
812
|
-
* @param icon_custom_emoji_id New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
835
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
813
836
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
814
837
|
*
|
|
815
838
|
* **Official reference:** https://core.telegram.org/bots/api#editforumtopic
|
|
816
839
|
*/
|
|
817
|
-
editForumTopic(
|
|
840
|
+
editForumTopic(other?: Other<"editForumTopic", "chat_id" | "message_thread_id">, signal?: AbortSignal): Promise<true>;
|
|
818
841
|
/**
|
|
819
842
|
* Context-aware alias for `api.closeForumTopic`. Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
820
843
|
*
|
|
@@ -847,6 +870,47 @@ export declare class Context implements RenamedUpdate {
|
|
|
847
870
|
* **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages
|
|
848
871
|
*/
|
|
849
872
|
unpinAllForumTopicMessages(signal?: AbortSignal): Promise<true>;
|
|
873
|
+
/**
|
|
874
|
+
* Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
|
|
875
|
+
*
|
|
876
|
+
* @param name New topic name, 1-128 characters
|
|
877
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
878
|
+
*
|
|
879
|
+
* **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic
|
|
880
|
+
*/
|
|
881
|
+
editGeneralForumTopic(name: string, signal?: AbortSignal): Promise<true>;
|
|
882
|
+
/**
|
|
883
|
+
* Context-aware alias for `api.closeGeneralForumTopic`. Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
884
|
+
*
|
|
885
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
886
|
+
*
|
|
887
|
+
* **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic
|
|
888
|
+
*/
|
|
889
|
+
closeGeneralForumTopic(signal?: AbortSignal): Promise<true>;
|
|
890
|
+
/**
|
|
891
|
+
* Context-aware alias for `api.reopenGeneralForumTopic`. Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. *
|
|
892
|
+
*
|
|
893
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
894
|
+
*
|
|
895
|
+
* **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic
|
|
896
|
+
*/
|
|
897
|
+
reopenGeneralForumTopic(signal?: AbortSignal): Promise<true>;
|
|
898
|
+
/**
|
|
899
|
+
* Context-aware alias for `api.hideGeneralForumTopic`. Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
900
|
+
*
|
|
901
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
902
|
+
*
|
|
903
|
+
* **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic
|
|
904
|
+
*/
|
|
905
|
+
hideGeneralForumTopic(signal?: AbortSignal): Promise<true>;
|
|
906
|
+
/**
|
|
907
|
+
* Context-aware alias for `api.unhideGeneralForumTopic`. Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
908
|
+
*
|
|
909
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
910
|
+
*
|
|
911
|
+
* **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
|
912
|
+
*/
|
|
913
|
+
unhideGeneralForumTopic(signal?: AbortSignal): Promise<true>;
|
|
850
914
|
/**
|
|
851
915
|
* Context-aware alias for `api.answerCallbackQuery`. Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
852
916
|
*
|
package/out/context.js
CHANGED
|
@@ -243,6 +243,26 @@ class Context {
|
|
|
243
243
|
var _a, _b, _c;
|
|
244
244
|
return ((_b = (_a = this.callbackQuery) === null || _a === void 0 ? void 0 : _a.inline_message_id) !== null && _b !== void 0 ? _b : (_c = this.chosenInlineResult) === null || _c === void 0 ? void 0 : _c.inline_message_id);
|
|
245
245
|
}
|
|
246
|
+
entities(types) {
|
|
247
|
+
var _a, _b;
|
|
248
|
+
const message = this.msg;
|
|
249
|
+
if (message === undefined)
|
|
250
|
+
return [];
|
|
251
|
+
const text = (_a = message.text) !== null && _a !== void 0 ? _a : message.caption;
|
|
252
|
+
if (text === undefined)
|
|
253
|
+
return [];
|
|
254
|
+
let entities = (_b = message.entities) !== null && _b !== void 0 ? _b : message.caption_entities;
|
|
255
|
+
if (entities === undefined)
|
|
256
|
+
return [];
|
|
257
|
+
if (types !== undefined) {
|
|
258
|
+
const filters = new Set(toArray(types));
|
|
259
|
+
entities = entities.filter((entity) => filters.has(entity.type));
|
|
260
|
+
}
|
|
261
|
+
return entities.map((entity) => ({
|
|
262
|
+
...entity,
|
|
263
|
+
text: text.substring(entity.offset, entity.offset + entity.length),
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
246
266
|
/**
|
|
247
267
|
* Returns `true` if this context object matches the given filter query, and
|
|
248
268
|
* `false` otherwise. This uses the same logic as `bot.on`.
|
|
@@ -552,12 +572,13 @@ class Context {
|
|
|
552
572
|
* We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
|
|
553
573
|
*
|
|
554
574
|
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
575
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
555
576
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
556
577
|
*
|
|
557
578
|
* **Official reference:** https://core.telegram.org/bots/api#sendchataction
|
|
558
579
|
*/
|
|
559
|
-
replyWithChatAction(action, signal) {
|
|
560
|
-
return this.api.sendChatAction(orThrow(this.chat, "sendChatAction").id, action, signal);
|
|
580
|
+
replyWithChatAction(action, other, signal) {
|
|
581
|
+
return this.api.sendChatAction(orThrow(this.chat, "sendChatAction").id, action, other, signal);
|
|
561
582
|
}
|
|
562
583
|
/**
|
|
563
584
|
* Context-aware alias for `api.getUserProfilePhotos`. Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
@@ -923,7 +944,7 @@ class Context {
|
|
|
923
944
|
return this.api.getChatMemberCount(orThrow(this.chat, "getChatMemberCount").id, signal);
|
|
924
945
|
}
|
|
925
946
|
/**
|
|
926
|
-
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
947
|
+
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
927
948
|
*
|
|
928
949
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
929
950
|
*
|
|
@@ -933,7 +954,7 @@ class Context {
|
|
|
933
954
|
return this.api.getChatMember(orThrow(this.chat, "getAuthor").id, orThrow(this.from, "getAuthor").id, signal);
|
|
934
955
|
}
|
|
935
956
|
/**
|
|
936
|
-
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
957
|
+
* Context-aware alias for `api.getChatMember`. Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
937
958
|
*
|
|
938
959
|
* @param user_id Unique identifier of the target user
|
|
939
960
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -979,16 +1000,15 @@ class Context {
|
|
|
979
1000
|
/**
|
|
980
1001
|
* Context-aware alias for `api.editForumTopic`. Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
981
1002
|
*
|
|
982
|
-
* @param
|
|
983
|
-
* @param icon_custom_emoji_id New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
1003
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
984
1004
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
985
1005
|
*
|
|
986
1006
|
* **Official reference:** https://core.telegram.org/bots/api#editforumtopic
|
|
987
1007
|
*/
|
|
988
|
-
editForumTopic(
|
|
1008
|
+
editForumTopic(other, signal) {
|
|
989
1009
|
const message = orThrow(this.msg, "editForumTopic");
|
|
990
1010
|
const thread = orThrow(message.message_thread_id, "editForumTopic");
|
|
991
|
-
return this.api.editForumTopic(message.chat.id, thread,
|
|
1011
|
+
return this.api.editForumTopic(message.chat.id, thread, other, signal);
|
|
992
1012
|
}
|
|
993
1013
|
/**
|
|
994
1014
|
* Context-aware alias for `api.closeForumTopic`. Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
@@ -1038,6 +1058,57 @@ class Context {
|
|
|
1038
1058
|
const thread = orThrow(message.message_thread_id, "unpinAllForumTopicMessages");
|
|
1039
1059
|
return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal);
|
|
1040
1060
|
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Context-aware alias for `api.editGeneralForumTopic`. Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
|
|
1063
|
+
*
|
|
1064
|
+
* @param name New topic name, 1-128 characters
|
|
1065
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1066
|
+
*
|
|
1067
|
+
* **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic
|
|
1068
|
+
*/
|
|
1069
|
+
editGeneralForumTopic(name, signal) {
|
|
1070
|
+
return this.api.editGeneralForumTopic(orThrow(this.chat, "editGeneralForumTopic").id, name, signal);
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Context-aware alias for `api.closeGeneralForumTopic`. Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
1074
|
+
*
|
|
1075
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1076
|
+
*
|
|
1077
|
+
* **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic
|
|
1078
|
+
*/
|
|
1079
|
+
closeGeneralForumTopic(signal) {
|
|
1080
|
+
return this.api.closeGeneralForumTopic(orThrow(this.chat, "closeGeneralForumTopic").id, signal);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Context-aware alias for `api.reopenGeneralForumTopic`. Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. *
|
|
1084
|
+
*
|
|
1085
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1086
|
+
*
|
|
1087
|
+
* **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic
|
|
1088
|
+
*/
|
|
1089
|
+
reopenGeneralForumTopic(signal) {
|
|
1090
|
+
return this.api.reopenGeneralForumTopic(orThrow(this.chat, "reopenGeneralForumTopic").id, signal);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Context-aware alias for `api.hideGeneralForumTopic`. Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
1094
|
+
*
|
|
1095
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1096
|
+
*
|
|
1097
|
+
* **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic
|
|
1098
|
+
*/
|
|
1099
|
+
hideGeneralForumTopic(signal) {
|
|
1100
|
+
return this.api.hideGeneralForumTopic(orThrow(this.chat, "hideGeneralForumTopic").id, signal);
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* Context-aware alias for `api.unhideGeneralForumTopic`. Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
1104
|
+
*
|
|
1105
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1106
|
+
*
|
|
1107
|
+
* **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
|
1108
|
+
*/
|
|
1109
|
+
unhideGeneralForumTopic(signal) {
|
|
1110
|
+
return this.api.unhideGeneralForumTopic(orThrow(this.chat, "unhideGeneralForumTopic").id, signal);
|
|
1111
|
+
}
|
|
1041
1112
|
/**
|
|
1042
1113
|
* Context-aware alias for `api.answerCallbackQuery`. Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
1043
1114
|
*
|
|
@@ -28,6 +28,12 @@ import { type InlineKeyboardButton, type KeyboardButton, type LoginUrl } from ".
|
|
|
28
28
|
*/
|
|
29
29
|
export declare class Keyboard {
|
|
30
30
|
readonly keyboard: KeyboardButton[][];
|
|
31
|
+
/**
|
|
32
|
+
* Requests clients to always show the keyboard when the regular keyboard is
|
|
33
|
+
* hidden. Defaults to false, in which case the custom keyboard can be
|
|
34
|
+
* hidden and opened with a keyboard icon.
|
|
35
|
+
*/
|
|
36
|
+
is_persistent?: boolean;
|
|
31
37
|
/**
|
|
32
38
|
* Show the current keyboard only to those users that are mentioned in the
|
|
33
39
|
* text of the message object.
|
|
@@ -113,6 +119,18 @@ export declare class Keyboard {
|
|
|
113
119
|
* @param url An HTTPS URL of a Web App to be opened with additional data
|
|
114
120
|
*/
|
|
115
121
|
webApp(text: string, url: string): this;
|
|
122
|
+
/**
|
|
123
|
+
* Make the current keyboard persistent. See
|
|
124
|
+
* https://grammy.dev/plugins/keyboard.html#persistent-keyboards for more
|
|
125
|
+
* details.
|
|
126
|
+
*
|
|
127
|
+
* Keyboards are not persistent by default, use this function to enable it
|
|
128
|
+
* (without any parameters or pass `true`). Pass `false` to force the
|
|
129
|
+
* keyboard to not persist.
|
|
130
|
+
*
|
|
131
|
+
* @param isEnabled `true` if the keyboard should persist, and `false` otherwise
|
|
132
|
+
*/
|
|
133
|
+
persistent(isEnabled?: boolean): this;
|
|
116
134
|
/**
|
|
117
135
|
* Make the current keyboard selective. See
|
|
118
136
|
* https://grammy.dev/plugins/keyboard.html#selectively-send-custom-keyboards
|
|
@@ -115,6 +115,21 @@ class Keyboard {
|
|
|
115
115
|
webApp(text, url) {
|
|
116
116
|
return this.add({ text, web_app: { url } });
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Make the current keyboard persistent. See
|
|
120
|
+
* https://grammy.dev/plugins/keyboard.html#persistent-keyboards for more
|
|
121
|
+
* details.
|
|
122
|
+
*
|
|
123
|
+
* Keyboards are not persistent by default, use this function to enable it
|
|
124
|
+
* (without any parameters or pass `true`). Pass `false` to force the
|
|
125
|
+
* keyboard to not persist.
|
|
126
|
+
*
|
|
127
|
+
* @param isEnabled `true` if the keyboard should persist, and `false` otherwise
|
|
128
|
+
*/
|
|
129
|
+
persistent(isEnabled = true) {
|
|
130
|
+
this.is_persistent = isEnabled;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
118
133
|
/**
|
|
119
134
|
* Make the current keyboard selective. See
|
|
120
135
|
* https://grammy.dev/plugins/keyboard.html#selectively-send-custom-keyboards
|
|
@@ -119,6 +119,9 @@ function strictMultiSession(options) {
|
|
|
119
119
|
* @param options Optional configuration to pass to the session middleware
|
|
120
120
|
*/
|
|
121
121
|
function lazySession(options = {}) {
|
|
122
|
+
if (options.type !== undefined && options.type !== "single") {
|
|
123
|
+
throw new Error("Cannot use lazy multi sessions!");
|
|
124
|
+
}
|
|
122
125
|
const { initial, storage, getSessionKey, custom } = fillDefaults(options);
|
|
123
126
|
return async (ctx, next) => {
|
|
124
127
|
const propSession = new PropertySession(
|
package/out/core/api.d.ts
CHANGED
|
@@ -374,11 +374,12 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
374
374
|
*
|
|
375
375
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
376
376
|
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
377
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
377
378
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
378
379
|
*
|
|
379
380
|
* **Official reference:** https://core.telegram.org/bots/api#sendchataction
|
|
380
381
|
*/
|
|
381
|
-
sendChatAction(chat_id: number | string, action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", signal?: AbortSignal): Promise<true>;
|
|
382
|
+
sendChatAction(chat_id: number | string, action: "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_voice" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note", other?: Other<R, "sendChatAction", "chat_id" | "action">, signal?: AbortSignal): Promise<true>;
|
|
382
383
|
/**
|
|
383
384
|
* Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
384
385
|
*
|
|
@@ -659,7 +660,7 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
659
660
|
*/
|
|
660
661
|
getChatMemberCount(chat_id: number | string, signal?: AbortSignal): Promise<number>;
|
|
661
662
|
/**
|
|
662
|
-
* Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
663
|
+
* Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
663
664
|
*
|
|
664
665
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
|
|
665
666
|
* @param user_id Unique identifier of the target user
|
|
@@ -711,13 +712,12 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
711
712
|
*
|
|
712
713
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
713
714
|
* @param message_thread_id Unique identifier for the target message thread of the forum topic
|
|
714
|
-
* @param
|
|
715
|
-
* @param icon_custom_emoji_id New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
715
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
716
716
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
717
717
|
*
|
|
718
718
|
* **Official reference:** https://core.telegram.org/bots/api#editforumtopic
|
|
719
719
|
*/
|
|
720
|
-
editForumTopic(chat_id: number | string, message_thread_id: number,
|
|
720
|
+
editForumTopic(chat_id: number | string, message_thread_id: number, other?: Other<R, "editForumTopic", "chat_id" | "message_thread_id">, signal?: AbortSignal): Promise<true>;
|
|
721
721
|
/**
|
|
722
722
|
* Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
723
723
|
*
|
|
@@ -758,6 +758,52 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
758
758
|
* **Official reference:** https://core.telegram.org/bots/api#unpinallforumtopicmessages
|
|
759
759
|
*/
|
|
760
760
|
unpinAllForumTopicMessages(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise<true>;
|
|
761
|
+
/**
|
|
762
|
+
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
|
|
763
|
+
*
|
|
764
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
765
|
+
* @param name New topic name, 1-128 characters
|
|
766
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
767
|
+
*
|
|
768
|
+
* **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic
|
|
769
|
+
*/
|
|
770
|
+
editGeneralForumTopic(chat_id: number | string, name: string, signal?: AbortSignal): Promise<true>;
|
|
771
|
+
/**
|
|
772
|
+
* Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
773
|
+
*
|
|
774
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
775
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
776
|
+
*
|
|
777
|
+
* **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic
|
|
778
|
+
*/
|
|
779
|
+
closeGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise<true>;
|
|
780
|
+
/**
|
|
781
|
+
* Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. *
|
|
782
|
+
*
|
|
783
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
784
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
785
|
+
*
|
|
786
|
+
* **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic
|
|
787
|
+
*/
|
|
788
|
+
reopenGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise<true>;
|
|
789
|
+
/**
|
|
790
|
+
* Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
791
|
+
*
|
|
792
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
793
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
794
|
+
*
|
|
795
|
+
* **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic
|
|
796
|
+
*/
|
|
797
|
+
hideGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise<true>;
|
|
798
|
+
/**
|
|
799
|
+
* Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
800
|
+
*
|
|
801
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
802
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
803
|
+
*
|
|
804
|
+
* **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
|
805
|
+
*/
|
|
806
|
+
unhideGeneralForumTopic(chat_id: number | string, signal?: AbortSignal): Promise<true>;
|
|
761
807
|
/**
|
|
762
808
|
* Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
763
809
|
*
|
package/out/core/api.js
CHANGED
|
@@ -397,12 +397,13 @@ class Api {
|
|
|
397
397
|
*
|
|
398
398
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
399
399
|
* @param action Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.
|
|
400
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
400
401
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
401
402
|
*
|
|
402
403
|
* **Official reference:** https://core.telegram.org/bots/api#sendchataction
|
|
403
404
|
*/
|
|
404
|
-
sendChatAction(chat_id, action, signal) {
|
|
405
|
-
return this.raw.sendChatAction({ chat_id, action }, signal);
|
|
405
|
+
sendChatAction(chat_id, action, other, signal) {
|
|
406
|
+
return this.raw.sendChatAction({ chat_id, action, ...other }, signal);
|
|
406
407
|
}
|
|
407
408
|
/**
|
|
408
409
|
* Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
|
|
@@ -742,7 +743,7 @@ class Api {
|
|
|
742
743
|
return this.raw.getChatMemberCount({ chat_id }, signal);
|
|
743
744
|
}
|
|
744
745
|
/**
|
|
745
|
-
* Use this method to get information about a member of a chat. Returns a ChatMember object on success.
|
|
746
|
+
* Use this method to get information about a member of a chat. The method is guaranteed to work only if the bot is an administrator in the chat. Returns a ChatMember object on success.
|
|
746
747
|
*
|
|
747
748
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
|
|
748
749
|
* @param user_id Unique identifier of the target user
|
|
@@ -804,19 +805,13 @@ class Api {
|
|
|
804
805
|
*
|
|
805
806
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
806
807
|
* @param message_thread_id Unique identifier for the target message thread of the forum topic
|
|
807
|
-
* @param
|
|
808
|
-
* @param icon_custom_emoji_id New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
|
|
808
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
809
809
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
810
810
|
*
|
|
811
811
|
* **Official reference:** https://core.telegram.org/bots/api#editforumtopic
|
|
812
812
|
*/
|
|
813
|
-
editForumTopic(chat_id, message_thread_id,
|
|
814
|
-
return this.raw.editForumTopic({
|
|
815
|
-
chat_id,
|
|
816
|
-
message_thread_id,
|
|
817
|
-
name,
|
|
818
|
-
icon_custom_emoji_id,
|
|
819
|
-
}, signal);
|
|
813
|
+
editForumTopic(chat_id, message_thread_id, other, signal) {
|
|
814
|
+
return this.raw.editForumTopic({ chat_id, message_thread_id, ...other }, signal);
|
|
820
815
|
}
|
|
821
816
|
/**
|
|
822
817
|
* Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
@@ -866,6 +861,62 @@ class Api {
|
|
|
866
861
|
unpinAllForumTopicMessages(chat_id, message_thread_id, signal) {
|
|
867
862
|
return this.raw.unpinAllForumTopicMessages({ chat_id, message_thread_id }, signal);
|
|
868
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
|
|
866
|
+
*
|
|
867
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
868
|
+
* @param name New topic name, 1-128 characters
|
|
869
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
870
|
+
*
|
|
871
|
+
* **Official reference:** https://core.telegram.org/bots/api#editgeneralforumtopic
|
|
872
|
+
*/
|
|
873
|
+
editGeneralForumTopic(chat_id, name, signal) {
|
|
874
|
+
return this.raw.editGeneralForumTopic({ chat_id, name }, signal);
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
878
|
+
*
|
|
879
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
880
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
881
|
+
*
|
|
882
|
+
* **Official reference:** https://core.telegram.org/bots/api#closegeneralforumtopic
|
|
883
|
+
*/
|
|
884
|
+
closeGeneralForumTopic(chat_id, signal) {
|
|
885
|
+
return this.raw.closeGeneralForumTopic({ chat_id }, signal);
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success. *
|
|
889
|
+
*
|
|
890
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
891
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
892
|
+
*
|
|
893
|
+
* **Official reference:** https://core.telegram.org/bots/api#reopengeneralforumtopic
|
|
894
|
+
*/
|
|
895
|
+
reopenGeneralForumTopic(chat_id, signal) {
|
|
896
|
+
return this.raw.reopenGeneralForumTopic({ chat_id }, signal);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
|
|
900
|
+
*
|
|
901
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
902
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
903
|
+
*
|
|
904
|
+
* **Official reference:** https://core.telegram.org/bots/api#hidegeneralforumtopic
|
|
905
|
+
*/
|
|
906
|
+
hideGeneralForumTopic(chat_id, signal) {
|
|
907
|
+
return this.raw.hideGeneralForumTopic({ chat_id }, signal);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
|
|
911
|
+
*
|
|
912
|
+
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
913
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
914
|
+
*
|
|
915
|
+
* **Official reference:** https://core.telegram.org/bots/api#unhidegeneralforumtopic
|
|
916
|
+
*/
|
|
917
|
+
unhideGeneralForumTopic(chat_id, signal) {
|
|
918
|
+
return this.raw.unhideGeneralForumTopic({ chat_id }, signal);
|
|
919
|
+
}
|
|
869
920
|
/**
|
|
870
921
|
* Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
|
|
871
922
|
*
|
package/out/filter.d.ts
CHANGED
|
@@ -45,7 +45,17 @@ declare const UPDATE_KEYS: {
|
|
|
45
45
|
readonly migrate_from_chat_id: {};
|
|
46
46
|
readonly successful_payment: {};
|
|
47
47
|
readonly connected_website: {};
|
|
48
|
+
readonly write_access_allowed: {};
|
|
48
49
|
readonly passport_data: {};
|
|
50
|
+
readonly forum_topic_created: {};
|
|
51
|
+
readonly forum_topic_edited: {
|
|
52
|
+
readonly name: {};
|
|
53
|
+
readonly icon_custom_emoji_id: {};
|
|
54
|
+
};
|
|
55
|
+
readonly forum_topic_closed: {};
|
|
56
|
+
readonly forum_topic_reopened: {};
|
|
57
|
+
readonly general_forum_topic_hidden: {};
|
|
58
|
+
readonly general_forum_topic_unhidden: {};
|
|
49
59
|
readonly sticker: {
|
|
50
60
|
readonly is_video: {};
|
|
51
61
|
readonly is_animated: {};
|
|
@@ -64,9 +74,6 @@ declare const UPDATE_KEYS: {
|
|
|
64
74
|
readonly pinned_message: {};
|
|
65
75
|
readonly invoice: {};
|
|
66
76
|
readonly proximity_alert_triggered: {};
|
|
67
|
-
readonly forum_topic_created: {};
|
|
68
|
-
readonly forum_topic_closed: {};
|
|
69
|
-
readonly forum_topic_reopened: {};
|
|
70
77
|
readonly video_chat_scheduled: {};
|
|
71
78
|
readonly video_chat_started: {};
|
|
72
79
|
readonly video_chat_ended: {};
|
|
@@ -121,6 +128,7 @@ declare const UPDATE_KEYS: {
|
|
|
121
128
|
readonly text_mention: {};
|
|
122
129
|
readonly custom_emoji: {};
|
|
123
130
|
};
|
|
131
|
+
readonly has_media_spoiler: {};
|
|
124
132
|
readonly caption: {};
|
|
125
133
|
};
|
|
126
134
|
readonly edited_message: {
|
|
@@ -142,7 +150,17 @@ declare const UPDATE_KEYS: {
|
|
|
142
150
|
readonly migrate_from_chat_id: {};
|
|
143
151
|
readonly successful_payment: {};
|
|
144
152
|
readonly connected_website: {};
|
|
153
|
+
readonly write_access_allowed: {};
|
|
145
154
|
readonly passport_data: {};
|
|
155
|
+
readonly forum_topic_created: {};
|
|
156
|
+
readonly forum_topic_edited: {
|
|
157
|
+
readonly name: {};
|
|
158
|
+
readonly icon_custom_emoji_id: {};
|
|
159
|
+
};
|
|
160
|
+
readonly forum_topic_closed: {};
|
|
161
|
+
readonly forum_topic_reopened: {};
|
|
162
|
+
readonly general_forum_topic_hidden: {};
|
|
163
|
+
readonly general_forum_topic_unhidden: {};
|
|
146
164
|
readonly sticker: {
|
|
147
165
|
readonly is_video: {};
|
|
148
166
|
readonly is_animated: {};
|
|
@@ -161,9 +179,6 @@ declare const UPDATE_KEYS: {
|
|
|
161
179
|
readonly pinned_message: {};
|
|
162
180
|
readonly invoice: {};
|
|
163
181
|
readonly proximity_alert_triggered: {};
|
|
164
|
-
readonly forum_topic_created: {};
|
|
165
|
-
readonly forum_topic_closed: {};
|
|
166
|
-
readonly forum_topic_reopened: {};
|
|
167
182
|
readonly video_chat_scheduled: {};
|
|
168
183
|
readonly video_chat_started: {};
|
|
169
184
|
readonly video_chat_ended: {};
|
|
@@ -218,6 +233,7 @@ declare const UPDATE_KEYS: {
|
|
|
218
233
|
readonly text_mention: {};
|
|
219
234
|
readonly custom_emoji: {};
|
|
220
235
|
};
|
|
236
|
+
readonly has_media_spoiler: {};
|
|
221
237
|
readonly caption: {};
|
|
222
238
|
};
|
|
223
239
|
readonly channel_post: {
|
|
@@ -240,9 +256,6 @@ declare const UPDATE_KEYS: {
|
|
|
240
256
|
readonly pinned_message: {};
|
|
241
257
|
readonly invoice: {};
|
|
242
258
|
readonly proximity_alert_triggered: {};
|
|
243
|
-
readonly forum_topic_created: {};
|
|
244
|
-
readonly forum_topic_closed: {};
|
|
245
|
-
readonly forum_topic_reopened: {};
|
|
246
259
|
readonly video_chat_scheduled: {};
|
|
247
260
|
readonly video_chat_started: {};
|
|
248
261
|
readonly video_chat_ended: {};
|
|
@@ -297,6 +310,7 @@ declare const UPDATE_KEYS: {
|
|
|
297
310
|
readonly text_mention: {};
|
|
298
311
|
readonly custom_emoji: {};
|
|
299
312
|
};
|
|
313
|
+
readonly has_media_spoiler: {};
|
|
300
314
|
readonly caption: {};
|
|
301
315
|
};
|
|
302
316
|
readonly edited_channel_post: {
|
|
@@ -319,9 +333,6 @@ declare const UPDATE_KEYS: {
|
|
|
319
333
|
readonly pinned_message: {};
|
|
320
334
|
readonly invoice: {};
|
|
321
335
|
readonly proximity_alert_triggered: {};
|
|
322
|
-
readonly forum_topic_created: {};
|
|
323
|
-
readonly forum_topic_closed: {};
|
|
324
|
-
readonly forum_topic_reopened: {};
|
|
325
336
|
readonly video_chat_scheduled: {};
|
|
326
337
|
readonly video_chat_started: {};
|
|
327
338
|
readonly video_chat_ended: {};
|
|
@@ -376,6 +387,7 @@ declare const UPDATE_KEYS: {
|
|
|
376
387
|
readonly text_mention: {};
|
|
377
388
|
readonly custom_emoji: {};
|
|
378
389
|
};
|
|
390
|
+
readonly has_media_spoiler: {};
|
|
379
391
|
readonly caption: {};
|
|
380
392
|
};
|
|
381
393
|
readonly inline_query: {};
|
package/out/filter.js
CHANGED
|
@@ -233,6 +233,7 @@ const EDITABLE_MESSAGE_KEYS = {
|
|
|
233
233
|
location: {},
|
|
234
234
|
entities: ENTITY_KEYS,
|
|
235
235
|
caption_entities: ENTITY_KEYS,
|
|
236
|
+
has_media_spoiler: {},
|
|
236
237
|
caption: {},
|
|
237
238
|
};
|
|
238
239
|
const COMMON_MESSAGE_KEYS = {
|
|
@@ -251,9 +252,6 @@ const COMMON_MESSAGE_KEYS = {
|
|
|
251
252
|
pinned_message: {},
|
|
252
253
|
invoice: {},
|
|
253
254
|
proximity_alert_triggered: {},
|
|
254
|
-
forum_topic_created: {},
|
|
255
|
-
forum_topic_closed: {},
|
|
256
|
-
forum_topic_reopened: {},
|
|
257
255
|
video_chat_scheduled: {},
|
|
258
256
|
video_chat_started: {},
|
|
259
257
|
video_chat_ended: {},
|
|
@@ -273,7 +271,14 @@ const MESSAGE_KEYS = {
|
|
|
273
271
|
migrate_from_chat_id: {},
|
|
274
272
|
successful_payment: {},
|
|
275
273
|
connected_website: {},
|
|
274
|
+
write_access_allowed: {},
|
|
276
275
|
passport_data: {},
|
|
276
|
+
forum_topic_created: {},
|
|
277
|
+
forum_topic_edited: { name: {}, icon_custom_emoji_id: {} },
|
|
278
|
+
forum_topic_closed: {},
|
|
279
|
+
forum_topic_reopened: {},
|
|
280
|
+
general_forum_topic_hidden: {},
|
|
281
|
+
general_forum_topic_unhidden: {},
|
|
277
282
|
};
|
|
278
283
|
const CHANNEL_POST_KEYS = {
|
|
279
284
|
...COMMON_MESSAGE_KEYS,
|
package/out/web.mjs
CHANGED
|
@@ -179,6 +179,7 @@ const EDITABLE_MESSAGE_KEYS = {
|
|
|
179
179
|
location: {},
|
|
180
180
|
entities: ENTITY_KEYS,
|
|
181
181
|
caption_entities: ENTITY_KEYS,
|
|
182
|
+
has_media_spoiler: {},
|
|
182
183
|
caption: {}
|
|
183
184
|
};
|
|
184
185
|
const COMMON_MESSAGE_KEYS = {
|
|
@@ -197,9 +198,6 @@ const COMMON_MESSAGE_KEYS = {
|
|
|
197
198
|
pinned_message: {},
|
|
198
199
|
invoice: {},
|
|
199
200
|
proximity_alert_triggered: {},
|
|
200
|
-
forum_topic_created: {},
|
|
201
|
-
forum_topic_closed: {},
|
|
202
|
-
forum_topic_reopened: {},
|
|
203
201
|
video_chat_scheduled: {},
|
|
204
202
|
video_chat_started: {},
|
|
205
203
|
video_chat_ended: {},
|
|
@@ -219,7 +217,17 @@ const MESSAGE_KEYS = {
|
|
|
219
217
|
migrate_from_chat_id: {},
|
|
220
218
|
successful_payment: {},
|
|
221
219
|
connected_website: {},
|
|
222
|
-
|
|
220
|
+
write_access_allowed: {},
|
|
221
|
+
passport_data: {},
|
|
222
|
+
forum_topic_created: {},
|
|
223
|
+
forum_topic_edited: {
|
|
224
|
+
name: {},
|
|
225
|
+
icon_custom_emoji_id: {}
|
|
226
|
+
},
|
|
227
|
+
forum_topic_closed: {},
|
|
228
|
+
forum_topic_reopened: {},
|
|
229
|
+
general_forum_topic_hidden: {},
|
|
230
|
+
general_forum_topic_unhidden: {}
|
|
223
231
|
};
|
|
224
232
|
const CHANNEL_POST_KEYS = {
|
|
225
233
|
...COMMON_MESSAGE_KEYS,
|
|
@@ -420,6 +428,22 @@ class Context {
|
|
|
420
428
|
get inlineMessageId() {
|
|
421
429
|
return this.callbackQuery?.inline_message_id ?? this.chosenInlineResult?.inline_message_id;
|
|
422
430
|
}
|
|
431
|
+
entities(types) {
|
|
432
|
+
const message = this.msg;
|
|
433
|
+
if (message === undefined) return [];
|
|
434
|
+
const text = message.text ?? message.caption;
|
|
435
|
+
if (text === undefined) return [];
|
|
436
|
+
let entities = message.entities ?? message.caption_entities;
|
|
437
|
+
if (entities === undefined) return [];
|
|
438
|
+
if (types !== undefined) {
|
|
439
|
+
const filters = new Set(toArray(types));
|
|
440
|
+
entities = entities.filter((entity)=>filters.has(entity.type));
|
|
441
|
+
}
|
|
442
|
+
return entities.map((entity)=>({
|
|
443
|
+
...entity,
|
|
444
|
+
text: text.substring(entity.offset, entity.offset + entity.length)
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
423
447
|
static has = checker;
|
|
424
448
|
has(filter) {
|
|
425
449
|
return Context.has.filterQuery(filter)(this);
|
|
@@ -498,8 +522,8 @@ class Context {
|
|
|
498
522
|
replyWithDice(emoji, other, signal) {
|
|
499
523
|
return this.api.sendDice(orThrow(this.chat, "sendDice").id, emoji, other, signal);
|
|
500
524
|
}
|
|
501
|
-
replyWithChatAction(action, signal) {
|
|
502
|
-
return this.api.sendChatAction(orThrow(this.chat, "sendChatAction").id, action, signal);
|
|
525
|
+
replyWithChatAction(action, other, signal) {
|
|
526
|
+
return this.api.sendChatAction(orThrow(this.chat, "sendChatAction").id, action, other, signal);
|
|
503
527
|
}
|
|
504
528
|
getUserProfilePhotos(other, signal) {
|
|
505
529
|
return this.api.getUserProfilePhotos(orThrow(this.from, "getUserProfilePhotos").id, other, signal);
|
|
@@ -620,10 +644,10 @@ class Context {
|
|
|
620
644
|
createForumTopic(name, other, signal) {
|
|
621
645
|
return this.api.createForumTopic(orThrow(this.chat, "createForumTopic").id, name, other, signal);
|
|
622
646
|
}
|
|
623
|
-
editForumTopic(
|
|
647
|
+
editForumTopic(other, signal) {
|
|
624
648
|
const message = orThrow(this.msg, "editForumTopic");
|
|
625
649
|
const thread = orThrow(message.message_thread_id, "editForumTopic");
|
|
626
|
-
return this.api.editForumTopic(message.chat.id, thread,
|
|
650
|
+
return this.api.editForumTopic(message.chat.id, thread, other, signal);
|
|
627
651
|
}
|
|
628
652
|
closeForumTopic(signal) {
|
|
629
653
|
const message = orThrow(this.msg, "closeForumTopic");
|
|
@@ -645,6 +669,21 @@ class Context {
|
|
|
645
669
|
const thread = orThrow(message.message_thread_id, "unpinAllForumTopicMessages");
|
|
646
670
|
return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal);
|
|
647
671
|
}
|
|
672
|
+
editGeneralForumTopic(name, signal) {
|
|
673
|
+
return this.api.editGeneralForumTopic(orThrow(this.chat, "editGeneralForumTopic").id, name, signal);
|
|
674
|
+
}
|
|
675
|
+
closeGeneralForumTopic(signal) {
|
|
676
|
+
return this.api.closeGeneralForumTopic(orThrow(this.chat, "closeGeneralForumTopic").id, signal);
|
|
677
|
+
}
|
|
678
|
+
reopenGeneralForumTopic(signal) {
|
|
679
|
+
return this.api.reopenGeneralForumTopic(orThrow(this.chat, "reopenGeneralForumTopic").id, signal);
|
|
680
|
+
}
|
|
681
|
+
hideGeneralForumTopic(signal) {
|
|
682
|
+
return this.api.hideGeneralForumTopic(orThrow(this.chat, "hideGeneralForumTopic").id, signal);
|
|
683
|
+
}
|
|
684
|
+
unhideGeneralForumTopic(signal) {
|
|
685
|
+
return this.api.unhideGeneralForumTopic(orThrow(this.chat, "unhideGeneralForumTopic").id, signal);
|
|
686
|
+
}
|
|
648
687
|
answerCallbackQuery(other, signal) {
|
|
649
688
|
return this.api.answerCallbackQuery(orThrow(this.callbackQuery, "answerCallbackQuery").id, typeof other === "string" ? {
|
|
650
689
|
text: other
|
|
@@ -3487,10 +3526,11 @@ class Api {
|
|
|
3487
3526
|
...other
|
|
3488
3527
|
}, signal);
|
|
3489
3528
|
}
|
|
3490
|
-
sendChatAction(chat_id, action, signal) {
|
|
3529
|
+
sendChatAction(chat_id, action, other, signal) {
|
|
3491
3530
|
return this.raw.sendChatAction({
|
|
3492
3531
|
chat_id,
|
|
3493
|
-
action
|
|
3532
|
+
action,
|
|
3533
|
+
...other
|
|
3494
3534
|
}, signal);
|
|
3495
3535
|
}
|
|
3496
3536
|
getUserProfilePhotos(user_id, other, signal) {
|
|
@@ -3688,12 +3728,11 @@ class Api {
|
|
|
3688
3728
|
...other
|
|
3689
3729
|
}, signal);
|
|
3690
3730
|
}
|
|
3691
|
-
editForumTopic(chat_id, message_thread_id,
|
|
3731
|
+
editForumTopic(chat_id, message_thread_id, other, signal) {
|
|
3692
3732
|
return this.raw.editForumTopic({
|
|
3693
3733
|
chat_id,
|
|
3694
3734
|
message_thread_id,
|
|
3695
|
-
|
|
3696
|
-
icon_custom_emoji_id
|
|
3735
|
+
...other
|
|
3697
3736
|
}, signal);
|
|
3698
3737
|
}
|
|
3699
3738
|
closeForumTopic(chat_id, message_thread_id, signal) {
|
|
@@ -3720,6 +3759,32 @@ class Api {
|
|
|
3720
3759
|
message_thread_id
|
|
3721
3760
|
}, signal);
|
|
3722
3761
|
}
|
|
3762
|
+
editGeneralForumTopic(chat_id, name, signal) {
|
|
3763
|
+
return this.raw.editGeneralForumTopic({
|
|
3764
|
+
chat_id,
|
|
3765
|
+
name
|
|
3766
|
+
}, signal);
|
|
3767
|
+
}
|
|
3768
|
+
closeGeneralForumTopic(chat_id, signal) {
|
|
3769
|
+
return this.raw.closeGeneralForumTopic({
|
|
3770
|
+
chat_id
|
|
3771
|
+
}, signal);
|
|
3772
|
+
}
|
|
3773
|
+
reopenGeneralForumTopic(chat_id, signal) {
|
|
3774
|
+
return this.raw.reopenGeneralForumTopic({
|
|
3775
|
+
chat_id
|
|
3776
|
+
}, signal);
|
|
3777
|
+
}
|
|
3778
|
+
hideGeneralForumTopic(chat_id, signal) {
|
|
3779
|
+
return this.raw.hideGeneralForumTopic({
|
|
3780
|
+
chat_id
|
|
3781
|
+
}, signal);
|
|
3782
|
+
}
|
|
3783
|
+
unhideGeneralForumTopic(chat_id, signal) {
|
|
3784
|
+
return this.raw.unhideGeneralForumTopic({
|
|
3785
|
+
chat_id
|
|
3786
|
+
}, signal);
|
|
3787
|
+
}
|
|
3723
3788
|
answerCallbackQuery(callback_query_id, other, signal) {
|
|
3724
3789
|
return this.raw.answerCallbackQuery({
|
|
3725
3790
|
callback_query_id,
|
|
@@ -4208,6 +4273,7 @@ function sleep(seconds) {
|
|
|
4208
4273
|
return new Promise((r)=>setTimeout(r, 1000 * seconds));
|
|
4209
4274
|
}
|
|
4210
4275
|
class Keyboard {
|
|
4276
|
+
is_persistent;
|
|
4211
4277
|
selective;
|
|
4212
4278
|
one_time_keyboard;
|
|
4213
4279
|
resize_keyboard;
|
|
@@ -4258,6 +4324,10 @@ class Keyboard {
|
|
|
4258
4324
|
}
|
|
4259
4325
|
});
|
|
4260
4326
|
}
|
|
4327
|
+
persistent(isEnabled = true) {
|
|
4328
|
+
this.is_persistent = isEnabled;
|
|
4329
|
+
return this;
|
|
4330
|
+
}
|
|
4261
4331
|
selected(isEnabled = true) {
|
|
4262
4332
|
this.selective = isEnabled;
|
|
4263
4333
|
return this;
|
|
@@ -4390,6 +4460,9 @@ function strictMultiSession(options) {
|
|
|
4390
4460
|
};
|
|
4391
4461
|
}
|
|
4392
4462
|
function lazySession(options = {}) {
|
|
4463
|
+
if (options.type !== undefined && options.type !== "single") {
|
|
4464
|
+
throw new Error("Cannot use lazy multi sessions!");
|
|
4465
|
+
}
|
|
4393
4466
|
const { initial , storage , getSessionKey , custom } = fillDefaults(options);
|
|
4394
4467
|
return async (ctx, next)=>{
|
|
4395
4468
|
const propSession = new PropertySession(storage, ctx, "session", initial);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grammy",
|
|
3
3
|
"description": "The Telegram Bot Framework.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.13.0",
|
|
5
5
|
"author": "KnorpelSenf",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
@@ -15,11 +15,10 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"prepare": "npm run backport",
|
|
17
17
|
"backport": "deno2node tsconfig.json",
|
|
18
|
-
"contribs": "all-contributors"
|
|
19
|
-
"bundle-web": "mkdir -p out deno_cache && cd bundling && DENO_DIR=$PWD/../deno_cache deno run --unstable --quiet --allow-net --allow-read --allow-env=DENO_DIR,XDG_CACHE_HOME,HOME,DENO_AUTH_TOKENS --allow-write=../out,$PWD/../deno_cache bundle-web.ts dev ../src/mod.ts"
|
|
18
|
+
"contribs": "all-contributors"
|
|
20
19
|
},
|
|
21
20
|
"dependencies": {
|
|
22
|
-
"@grammyjs/types": "^2.
|
|
21
|
+
"@grammyjs/types": "^2.11.0",
|
|
23
22
|
"abort-controller": "^3.0.0",
|
|
24
23
|
"debug": "^4.3.4",
|
|
25
24
|
"node-fetch": "^2.6.7"
|