grammy 1.28.0 → 1.29.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 +4 -1
- package/out/context.d.ts +48 -14
- package/out/context.js +85 -36
- package/out/convenience/session.d.ts +13 -15
- package/out/convenience/session.js +5 -5
- package/out/core/api.d.ts +30 -7
- package/out/core/api.js +34 -7
- package/out/filter.d.ts +3 -0
- package/out/filter.js +1 -0
- package/out/web.mjs +50 -20
- package/package.json +2 -2
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-)
|
|
@@ -306,6 +306,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
306
306
|
<td align="center" valign="top" width="11.11%"><a href="https://consortiumkey.com/"><img src="https://avatars.githubusercontent.com/u/95214604?v=4?s=100" width="100px;" alt="lexomis"/><br /><sub><b>lexomis</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Alexomis" title="Reviewed Pull Requests">👀</a></td>
|
|
307
307
|
<td align="center" valign="top" width="11.11%"><a href="https://github.com/asologor"><img src="https://avatars.githubusercontent.com/u/97506048?v=4?s=100" width="100px;" alt="Andrew Sologor"/><br /><sub><b>Andrew Sologor</b></sub></a><br /><a href="https://github.com/grammyjs/grammY/pulls?q=is%3Apr+reviewed-by%3Aandrew-sol" title="Reviewed Pull Requests">👀</a></td>
|
|
308
308
|
</tr>
|
|
309
|
+
<tr>
|
|
310
|
+
<td align="center" valign="top" width="11.11%"><a href="https://github.com/rayz1065"><img src="https://avatars.githubusercontent.com/u/37779815?v=4?s=100" width="100px;" alt="rayz"/><br /><sub><b>rayz</b></sub></a><br /><a href="#question-rayz1065" title="Answering Questions">💬</a></td>
|
|
311
|
+
</tr>
|
|
309
312
|
</tbody>
|
|
310
313
|
</table>
|
|
311
314
|
|
package/out/context.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type Filter, type FilterCore, type FilterQuery } from "./filter.js";
|
|
|
4
4
|
import { type Chat, type ChatPermissions, type InlineQueryResult, type InputFile, type InputMedia, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputPaidMedia, type InputPollOption, type LabeledPrice, type Message, type MessageEntity, type PassportElementError, type ReactionType, type ReactionTypeEmoji, type Update, type User, type UserFromGetMe } from "./types.js";
|
|
5
5
|
export type MaybeArray<T> = T | T[];
|
|
6
6
|
/** permits `string` but gives hints */
|
|
7
|
-
export type StringWithCommandSuggestions = (string & Record<never, never>) | "start" | "help" | "settings" | "privacy";
|
|
7
|
+
export type StringWithCommandSuggestions = (string & Record<never, never>) | "start" | "help" | "settings" | "privacy" | "developer_info";
|
|
8
8
|
type Other<M extends Methods<RawApi>, X extends string = never> = OtherApi<RawApi, M, X>;
|
|
9
9
|
type SnakeToCamelCase<S extends string> = S extends `${infer L}_${infer R}` ? `${L}${Capitalize<SnakeToCamelCase<R>>}` : S;
|
|
10
10
|
type AliasProps<U> = {
|
|
@@ -308,15 +308,18 @@ export declare class Context implements RenamedUpdate {
|
|
|
308
308
|
* customEmojiAdded: [],
|
|
309
309
|
* customEmojiKept: [],
|
|
310
310
|
* customEmojiRemoved: ['id0123'],
|
|
311
|
+
* paid: true,
|
|
312
|
+
* paidAdded: false,
|
|
313
|
+
* paidRemoved: false,
|
|
311
314
|
* }
|
|
312
315
|
* ```
|
|
313
316
|
* In the above example, a tada reaction was added by the user, and a custom
|
|
314
317
|
* emoji reaction with the custom emoji 'id0123' was removed in the same
|
|
315
|
-
* update. The user had already reacted with a thumbs up reaction
|
|
316
|
-
* they left unchanged. As a result, the current
|
|
317
|
-
* thumbs up
|
|
318
|
-
* emoji in one list)
|
|
319
|
-
* `ctx.messageReaction.new_reaction`.
|
|
318
|
+
* update. The user had already reacted with a thumbs up reaction and a paid
|
|
319
|
+
* star reaction, which they left both unchanged. As a result, the current
|
|
320
|
+
* reaction by the user is thumbs up, tada, and a paid reaction. Note that
|
|
321
|
+
* the current reaction (all emoji reactions regardless of type in one list)
|
|
322
|
+
* can also be obtained from `ctx.messageReaction.new_reaction`.
|
|
320
323
|
*
|
|
321
324
|
* Remember that reaction updates only include information about the
|
|
322
325
|
* reaction of a specific user. The respective message may have many more
|
|
@@ -341,6 +344,16 @@ export declare class Context implements RenamedUpdate {
|
|
|
341
344
|
customEmojiKept: string[];
|
|
342
345
|
/** Custom emoji removed from this user's reaction */
|
|
343
346
|
customEmojiRemoved: string[];
|
|
347
|
+
/**
|
|
348
|
+
* `true` if a paid reaction is currently present in this user's
|
|
349
|
+
* reaction, and `false` otherwise
|
|
350
|
+
*/
|
|
351
|
+
paid: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* `true` if a paid reaction was newly added to this user's reaction,
|
|
354
|
+
* and `false` otherwise
|
|
355
|
+
*/
|
|
356
|
+
paidAdded: boolean;
|
|
344
357
|
};
|
|
345
358
|
/**
|
|
346
359
|
* `Context.has` is an object that contains a number of useful functions for
|
|
@@ -617,7 +630,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
617
630
|
location: import("@grammyjs/types/message.js").Location;
|
|
618
631
|
})>;
|
|
619
632
|
/**
|
|
620
|
-
* Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media
|
|
633
|
+
* Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned.
|
|
621
634
|
*
|
|
622
635
|
* @param star_count The number of Telegram Stars that must be paid to buy access to the media
|
|
623
636
|
* @param media An array describing the media to be sent; up to 10 items
|
|
@@ -687,9 +700,9 @@ export declare class Context implements RenamedUpdate {
|
|
|
687
700
|
*/
|
|
688
701
|
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>;
|
|
689
702
|
/**
|
|
690
|
-
* Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel.
|
|
703
|
+
* Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
691
704
|
*
|
|
692
|
-
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
|
|
705
|
+
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
|
|
693
706
|
* @param other Optional remaining parameters, confer the official reference below
|
|
694
707
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
695
708
|
*
|
|
@@ -716,7 +729,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
716
729
|
*/
|
|
717
730
|
getUserChatBoosts(chat_id: number | string, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").UserChatBoosts>;
|
|
718
731
|
/**
|
|
719
|
-
*
|
|
732
|
+
* Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
|
720
733
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
721
734
|
*
|
|
722
735
|
* **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection
|
|
@@ -872,7 +885,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
872
885
|
*/
|
|
873
886
|
createChatInviteLink(other?: Other<"createChatInviteLink", "chat_id">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
874
887
|
/**
|
|
875
|
-
*
|
|
888
|
+
* Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
876
889
|
*
|
|
877
890
|
* @param invite_link The invite link to edit
|
|
878
891
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -882,7 +895,28 @@ export declare class Context implements RenamedUpdate {
|
|
|
882
895
|
*/
|
|
883
896
|
editChatInviteLink(invite_link: string, other?: Other<"editChatInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
884
897
|
/**
|
|
885
|
-
*
|
|
898
|
+
* Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
899
|
+
*
|
|
900
|
+
* @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
901
|
+
* @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
|
|
902
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
903
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
904
|
+
*
|
|
905
|
+
* **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
906
|
+
*/
|
|
907
|
+
createChatSubscriptionInviteLink(subscription_period: number, subscription_price: number, other?: Other<"createChatSubscriptionInviteLink", "chat_id" | "subscription_period" | "subscription_price">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
908
|
+
/**
|
|
909
|
+
* Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
910
|
+
*
|
|
911
|
+
* @param invite_link The invite link to edit
|
|
912
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
913
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
914
|
+
*
|
|
915
|
+
* **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
916
|
+
*/
|
|
917
|
+
editChatSubscriptionInviteLink(invite_link: string, other?: Other<"editChatSubscriptionInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
918
|
+
/**
|
|
919
|
+
* Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
886
920
|
*
|
|
887
921
|
* @param invite_link The invite link to revoke
|
|
888
922
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -1049,7 +1083,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
1049
1083
|
*/
|
|
1050
1084
|
createForumTopic(name: string, other?: Other<"createForumTopic", "chat_id" | "name">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ForumTopic>;
|
|
1051
1085
|
/**
|
|
1052
|
-
* 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.
|
|
1086
|
+
* 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 the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
1053
1087
|
*
|
|
1054
1088
|
* @param other Optional remaining parameters, confer the official reference below
|
|
1055
1089
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -1090,7 +1124,7 @@ export declare class Context implements RenamedUpdate {
|
|
|
1090
1124
|
*/
|
|
1091
1125
|
unpinAllForumTopicMessages(signal?: AbortSignal): Promise<true>;
|
|
1092
1126
|
/**
|
|
1093
|
-
* 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.
|
|
1127
|
+
* 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 the can_manage_topics administrator rights. Returns True on success.
|
|
1094
1128
|
*
|
|
1095
1129
|
* @param name New topic name, 1-128 characters
|
|
1096
1130
|
* @param signal Optional `AbortSignal` to cancel the request
|
package/out/context.js
CHANGED
|
@@ -67,11 +67,18 @@ const checker = {
|
|
|
67
67
|
const normalized = typeof reaction === "string"
|
|
68
68
|
? [{ type: "emoji", emoji: reaction }]
|
|
69
69
|
: (Array.isArray(reaction) ? reaction : [reaction]).map((emoji) => typeof emoji === "string" ? { type: "emoji", emoji } : emoji);
|
|
70
|
+
const emoji = new Set(normalized.filter((r) => r.type === "emoji")
|
|
71
|
+
.map((r) => r.emoji));
|
|
72
|
+
const customEmoji = new Set(normalized.filter((r) => r.type === "custom_emoji")
|
|
73
|
+
.map((r) => r.custom_emoji_id));
|
|
74
|
+
const paid = normalized.some((r) => r.type === "paid");
|
|
70
75
|
return (ctx) => {
|
|
71
76
|
if (!hasMessageReaction(ctx))
|
|
72
77
|
return false;
|
|
73
78
|
const { old_reaction, new_reaction } = ctx.messageReaction;
|
|
79
|
+
// try to find a wanted reaction that is new and not old
|
|
74
80
|
for (const reaction of new_reaction) {
|
|
81
|
+
// first check if the reaction existed previously
|
|
75
82
|
let isOld = false;
|
|
76
83
|
if (reaction.type === "emoji") {
|
|
77
84
|
for (const old of old_reaction) {
|
|
@@ -93,34 +100,38 @@ const checker = {
|
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
}
|
|
103
|
+
else if (reaction.type === "paid") {
|
|
104
|
+
for (const old of old_reaction) {
|
|
105
|
+
if (old.type !== "paid")
|
|
106
|
+
continue;
|
|
107
|
+
isOld = true;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
96
111
|
else {
|
|
97
112
|
// always regard unsupported emoji types as new
|
|
98
113
|
}
|
|
99
|
-
if
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else if (reaction.type === "custom_emoji") {
|
|
110
|
-
for (const wanted of normalized) {
|
|
111
|
-
if (wanted.type !== "custom_emoji")
|
|
112
|
-
continue;
|
|
113
|
-
if (wanted.custom_emoji_id ===
|
|
114
|
-
reaction.custom_emoji_id) {
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
// always regard unsupported emoji types as new
|
|
114
|
+
// disregard reaction if it is not new
|
|
115
|
+
if (isOld)
|
|
116
|
+
continue;
|
|
117
|
+
// check if the new reaction is wanted and short-circuit
|
|
118
|
+
if (reaction.type === "emoji") {
|
|
119
|
+
if (emoji.has(reaction.emoji))
|
|
121
120
|
return true;
|
|
122
|
-
}
|
|
123
121
|
}
|
|
122
|
+
else if (reaction.type === "custom_emoji") {
|
|
123
|
+
if (customEmoji.has(reaction.custom_emoji_id))
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
else if (reaction.type === "paid") {
|
|
127
|
+
if (paid)
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
// always regard unsupported emoji types as new
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
// new reaction not wanted, check next one
|
|
124
135
|
}
|
|
125
136
|
return false;
|
|
126
137
|
};
|
|
@@ -427,15 +438,18 @@ class Context {
|
|
|
427
438
|
* customEmojiAdded: [],
|
|
428
439
|
* customEmojiKept: [],
|
|
429
440
|
* customEmojiRemoved: ['id0123'],
|
|
441
|
+
* paid: true,
|
|
442
|
+
* paidAdded: false,
|
|
443
|
+
* paidRemoved: false,
|
|
430
444
|
* }
|
|
431
445
|
* ```
|
|
432
446
|
* In the above example, a tada reaction was added by the user, and a custom
|
|
433
447
|
* emoji reaction with the custom emoji 'id0123' was removed in the same
|
|
434
|
-
* update. The user had already reacted with a thumbs up reaction
|
|
435
|
-
* they left unchanged. As a result, the current
|
|
436
|
-
* thumbs up
|
|
437
|
-
* emoji in one list)
|
|
438
|
-
* `ctx.messageReaction.new_reaction`.
|
|
448
|
+
* update. The user had already reacted with a thumbs up reaction and a paid
|
|
449
|
+
* star reaction, which they left both unchanged. As a result, the current
|
|
450
|
+
* reaction by the user is thumbs up, tada, and a paid reaction. Note that
|
|
451
|
+
* the current reaction (all emoji reactions regardless of type in one list)
|
|
452
|
+
* can also be obtained from `ctx.messageReaction.new_reaction`.
|
|
439
453
|
*
|
|
440
454
|
* Remember that reaction updates only include information about the
|
|
441
455
|
* reaction of a specific user. The respective message may have many more
|
|
@@ -452,6 +466,8 @@ class Context {
|
|
|
452
466
|
const customEmojiAdded = [];
|
|
453
467
|
const customEmojiKept = [];
|
|
454
468
|
const customEmojiRemoved = [];
|
|
469
|
+
let paid = false;
|
|
470
|
+
let paidAdded = false;
|
|
455
471
|
const r = this.messageReaction;
|
|
456
472
|
if (r !== undefined) {
|
|
457
473
|
const { old_reaction, new_reaction } = r;
|
|
@@ -463,6 +479,9 @@ class Context {
|
|
|
463
479
|
else if (reaction.type === "custom_emoji") {
|
|
464
480
|
customEmoji.push(reaction.custom_emoji_id);
|
|
465
481
|
}
|
|
482
|
+
else if (reaction.type === "paid") {
|
|
483
|
+
paid = paidAdded = true;
|
|
484
|
+
}
|
|
466
485
|
}
|
|
467
486
|
// temporarily move all old emoji to the *Removed arrays
|
|
468
487
|
for (const reaction of old_reaction) {
|
|
@@ -472,6 +491,9 @@ class Context {
|
|
|
472
491
|
else if (reaction.type === "custom_emoji") {
|
|
473
492
|
customEmojiRemoved.push(reaction.custom_emoji_id);
|
|
474
493
|
}
|
|
494
|
+
else if (reaction.type === "paid") {
|
|
495
|
+
paidAdded = false;
|
|
496
|
+
}
|
|
475
497
|
}
|
|
476
498
|
// temporarily move all new emoji to the *Added arrays
|
|
477
499
|
emojiAdded.push(...emoji);
|
|
@@ -518,6 +540,8 @@ class Context {
|
|
|
518
540
|
customEmojiAdded,
|
|
519
541
|
customEmojiKept,
|
|
520
542
|
customEmojiRemoved,
|
|
543
|
+
paid,
|
|
544
|
+
paidAdded,
|
|
521
545
|
};
|
|
522
546
|
}
|
|
523
547
|
/**
|
|
@@ -831,7 +855,7 @@ class Context {
|
|
|
831
855
|
: this.api.stopMessageLiveLocation(orThrow(this.chatId, "stopMessageLiveLocation"), orThrow(this.msgId, "stopMessageLiveLocation"), other, signal);
|
|
832
856
|
}
|
|
833
857
|
/**
|
|
834
|
-
* Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media
|
|
858
|
+
* Context-aware alias for `api.sendPaidMedia`. Use this method to send paid media. On success, the sent Message is returned.
|
|
835
859
|
*
|
|
836
860
|
* @param star_count The number of Telegram Stars that must be paid to buy access to the media
|
|
837
861
|
* @param media An array describing the media to be sent; up to 10 items
|
|
@@ -913,9 +937,9 @@ class Context {
|
|
|
913
937
|
return this.api.sendChatAction(orThrow(this.chatId, "sendChatAction"), action, { business_connection_id: this.businessConnectionId, ...other }, signal);
|
|
914
938
|
}
|
|
915
939
|
/**
|
|
916
|
-
* Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel.
|
|
940
|
+
* Context-aware alias for `api.setMessageReaction`. Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
917
941
|
*
|
|
918
|
-
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
|
|
942
|
+
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
|
|
919
943
|
* @param other Optional remaining parameters, confer the official reference below
|
|
920
944
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
921
945
|
*
|
|
@@ -953,7 +977,7 @@ class Context {
|
|
|
953
977
|
return this.api.getUserChatBoosts(chat_id, orThrow(this.from, "getUserChatBoosts").id, signal);
|
|
954
978
|
}
|
|
955
979
|
/**
|
|
956
|
-
*
|
|
980
|
+
* Context-aware alias for `api.getBusinessConnection`. Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.
|
|
957
981
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
958
982
|
*
|
|
959
983
|
* **Official reference:** https://core.telegram.org/bots/api#getbusinessconnection
|
|
@@ -1150,7 +1174,7 @@ class Context {
|
|
|
1150
1174
|
return this.api.createChatInviteLink(orThrow(this.chatId, "createChatInviteLink"), other, signal);
|
|
1151
1175
|
}
|
|
1152
1176
|
/**
|
|
1153
|
-
*
|
|
1177
|
+
* Context-aware alias for `api.editChatInviteLink`. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
1154
1178
|
*
|
|
1155
1179
|
* @param invite_link The invite link to edit
|
|
1156
1180
|
* @param other Optional remaining parameters, confer the official reference below
|
|
@@ -1162,7 +1186,32 @@ class Context {
|
|
|
1162
1186
|
return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal);
|
|
1163
1187
|
}
|
|
1164
1188
|
/**
|
|
1165
|
-
*
|
|
1189
|
+
* Context-aware alias for `api.createChatSubscriptionInviteLink`. Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
1190
|
+
*
|
|
1191
|
+
* @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
1192
|
+
* @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
|
|
1193
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
1194
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1195
|
+
*
|
|
1196
|
+
* **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
1197
|
+
*/
|
|
1198
|
+
createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) {
|
|
1199
|
+
return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal);
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Context-aware alias for `api.editChatSubscriptionInviteLink`. Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
1203
|
+
*
|
|
1204
|
+
* @param invite_link The invite link to edit
|
|
1205
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
1206
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
1207
|
+
*
|
|
1208
|
+
* **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
1209
|
+
*/
|
|
1210
|
+
editChatSubscriptionInviteLink(invite_link, other, signal) {
|
|
1211
|
+
return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal);
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Context-aware alias for `api.revokeChatInviteLink`. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
1166
1215
|
*
|
|
1167
1216
|
* @param invite_link The invite link to revoke
|
|
1168
1217
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -1369,7 +1418,7 @@ class Context {
|
|
|
1369
1418
|
return this.api.createForumTopic(orThrow(this.chatId, "createForumTopic"), name, other, signal);
|
|
1370
1419
|
}
|
|
1371
1420
|
/**
|
|
1372
|
-
* 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.
|
|
1421
|
+
* 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 the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
1373
1422
|
*
|
|
1374
1423
|
* @param other Optional remaining parameters, confer the official reference below
|
|
1375
1424
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -1430,7 +1479,7 @@ class Context {
|
|
|
1430
1479
|
return this.api.unpinAllForumTopicMessages(message.chat.id, thread, signal);
|
|
1431
1480
|
}
|
|
1432
1481
|
/**
|
|
1433
|
-
* 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.
|
|
1482
|
+
* 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 the can_manage_topics administrator rights. Returns True on success.
|
|
1434
1483
|
*
|
|
1435
1484
|
* @param name New topic name, 1-128 characters
|
|
1436
1485
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
@@ -7,22 +7,21 @@ type MaybePromise<T> = Promise<T> | T;
|
|
|
7
7
|
*
|
|
8
8
|
* Session middleware will load the session data of a specific chat from your
|
|
9
9
|
* storage solution, and make it available to you on the context object. Check
|
|
10
|
-
* out the
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* the [website](https://grammy.dev/plugins/session).
|
|
10
|
+
* out the [documentation](https://grammy.dev/ref/core/session) on session
|
|
11
|
+
* middleware to know more, and read the section about sessions on the
|
|
12
|
+
* [website](https://grammy.dev/plugins/session).
|
|
14
13
|
*/
|
|
15
14
|
export interface SessionFlavor<S> {
|
|
16
15
|
/**
|
|
17
16
|
* Session data on the context object.
|
|
18
17
|
*
|
|
19
18
|
* **WARNING:** You have to make sure that your session data is not
|
|
20
|
-
* undefined by _providing an initial value to the session middleware_, or
|
|
21
|
-
* making sure that `ctx.session` is assigned if it is empty! The type
|
|
19
|
+
* undefined by _providing an initial value to the session middleware_, or
|
|
20
|
+
* by making sure that `ctx.session` is assigned if it is empty! The type
|
|
22
21
|
* system does not include `| undefined` because this is really annoying to
|
|
23
22
|
* work with.
|
|
24
23
|
*
|
|
25
|
-
*
|
|
24
|
+
* Accessing `ctx.session` by reading or writing will throw if
|
|
26
25
|
* `getSessionKey(ctx) === undefined` for the respective context object
|
|
27
26
|
* `ctx`.
|
|
28
27
|
*/
|
|
@@ -37,9 +36,8 @@ export interface SessionFlavor<S> {
|
|
|
37
36
|
* object. Once you access `ctx.session`, the storage will be queried and the
|
|
38
37
|
* session data becomes available. If you access `ctx.session` again for the
|
|
39
38
|
* same context object, the cached value will be used. Check out the
|
|
40
|
-
* [documentation](https://grammy.dev/ref/core/lazysession)
|
|
41
|
-
*
|
|
42
|
-
* sessions on the
|
|
39
|
+
* [documentation](https://grammy.dev/ref/core/lazysession) on lazy session
|
|
40
|
+
* middleware to know more, and read the section about lazy sessions on the
|
|
43
41
|
* [website](https://grammy.dev/plugins/session#lazy-sessions).
|
|
44
42
|
*/
|
|
45
43
|
export interface LazySessionFlavor<S> {
|
|
@@ -301,11 +299,11 @@ export declare function enhanceStorage<T>(options: MigrationOptions<T>): Storage
|
|
|
301
299
|
* This class is used as default if you do not provide a storage adapter, e.g.
|
|
302
300
|
* to your database.
|
|
303
301
|
*
|
|
304
|
-
* This storage adapter features expiring sessions. When instantiating this
|
|
305
|
-
* yourself, you can pass a time to live in milliseconds that will be used
|
|
306
|
-
* each session object. If a session for a user expired, the session data
|
|
307
|
-
* be discarded on its first read, and a fresh session object as returned
|
|
308
|
-
* `initial` option (or undefined) will be put into place.
|
|
302
|
+
* This storage adapter features expiring sessions. When instantiating this
|
|
303
|
+
* class yourself, you can pass a time to live in milliseconds that will be used
|
|
304
|
+
* for each session object. If a session for a user expired, the session data
|
|
305
|
+
* will be discarded on its first read, and a fresh session object as returned
|
|
306
|
+
* by the `initial` option (or undefined) will be put into place.
|
|
309
307
|
*/
|
|
310
308
|
export declare class MemorySessionStorage<S> implements StorageAdapter<S> {
|
|
311
309
|
private readonly timeToLive?;
|
|
@@ -375,11 +375,11 @@ function wrapStorage(storage) {
|
|
|
375
375
|
* This class is used as default if you do not provide a storage adapter, e.g.
|
|
376
376
|
* to your database.
|
|
377
377
|
*
|
|
378
|
-
* This storage adapter features expiring sessions. When instantiating this
|
|
379
|
-
* yourself, you can pass a time to live in milliseconds that will be used
|
|
380
|
-
* each session object. If a session for a user expired, the session data
|
|
381
|
-
* be discarded on its first read, and a fresh session object as returned
|
|
382
|
-
* `initial` option (or undefined) will be put into place.
|
|
378
|
+
* This storage adapter features expiring sessions. When instantiating this
|
|
379
|
+
* class yourself, you can pass a time to live in milliseconds that will be used
|
|
380
|
+
* for each session object. If a session for a user expired, the session data
|
|
381
|
+
* will be discarded on its first read, and a fresh session object as returned
|
|
382
|
+
* by the `initial` option (or undefined) will be put into place.
|
|
383
383
|
*/
|
|
384
384
|
class MemorySessionStorage {
|
|
385
385
|
/**
|
package/out/core/api.d.ts
CHANGED
|
@@ -360,7 +360,7 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
360
360
|
location: import("@grammyjs/types/message.js").Location;
|
|
361
361
|
})>;
|
|
362
362
|
/**
|
|
363
|
-
* Use this method to send paid media
|
|
363
|
+
* Use this method to send paid media. On success, the sent Message is returned.
|
|
364
364
|
*
|
|
365
365
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
366
366
|
* @param star_count The number of Telegram Stars that must be paid to buy access to the media
|
|
@@ -421,11 +421,11 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
421
421
|
*/
|
|
422
422
|
sendDice(chat_id: number | string, emoji: string, other?: Other<R, "sendDice", "chat_id" | "emoji">, signal?: AbortSignal): Promise<import("@grammyjs/types/message.js").Message.DiceMessage>;
|
|
423
423
|
/**
|
|
424
|
-
* Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel.
|
|
424
|
+
* Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
425
425
|
*
|
|
426
426
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
427
427
|
* @param message_id Identifier of the target message
|
|
428
|
-
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
|
|
428
|
+
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
|
|
429
429
|
* @param other Optional remaining parameters, confer the official reference below
|
|
430
430
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
431
431
|
*
|
|
@@ -598,7 +598,7 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
598
598
|
*/
|
|
599
599
|
createChatInviteLink(chat_id: number | string, other?: Other<R, "createChatInviteLink", "chat_id">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
600
600
|
/**
|
|
601
|
-
*
|
|
601
|
+
* Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
602
602
|
*
|
|
603
603
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
604
604
|
* @param invite_link The invite link to edit
|
|
@@ -609,7 +609,30 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
609
609
|
*/
|
|
610
610
|
editChatInviteLink(chat_id: number | string, invite_link: string, other?: Other<R, "editChatInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
611
611
|
/**
|
|
612
|
-
*
|
|
612
|
+
* Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
613
|
+
*
|
|
614
|
+
* @param chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
|
|
615
|
+
* @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
616
|
+
* @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
|
|
617
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
618
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
619
|
+
*
|
|
620
|
+
* **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
621
|
+
*/
|
|
622
|
+
createChatSubscriptionInviteLink(chat_id: number | string, subscription_period: number, subscription_price: number, other?: Other<R, "createChatSubscriptionInviteLink", "chat_id" | "subscription_period" | "subscription_price">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
623
|
+
/**
|
|
624
|
+
* Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
625
|
+
*
|
|
626
|
+
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
627
|
+
* @param invite_link The invite link to edit
|
|
628
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
629
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
630
|
+
*
|
|
631
|
+
* **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
632
|
+
*/
|
|
633
|
+
editChatSubscriptionInviteLink(chat_id: number | string, invite_link: string, other?: Other<R, "editChatSubscriptionInviteLink", "chat_id" | "invite_link">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ChatInviteLink>;
|
|
634
|
+
/**
|
|
635
|
+
* Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
613
636
|
*
|
|
614
637
|
* @param chat_id Unique identifier of the target chat or username of the target channel (in the format @channelusername)
|
|
615
638
|
* @param invite_link The invite link to revoke
|
|
@@ -795,7 +818,7 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
795
818
|
*/
|
|
796
819
|
createForumTopic(chat_id: number | string, name: string, other?: Other<R, "createForumTopic", "chat_id" | "name">, signal?: AbortSignal): Promise<import("@grammyjs/types/manage.js").ForumTopic>;
|
|
797
820
|
/**
|
|
798
|
-
* 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.
|
|
821
|
+
* 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 the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
799
822
|
*
|
|
800
823
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
801
824
|
* @param message_thread_id Unique identifier for the target message thread of the forum topic
|
|
@@ -846,7 +869,7 @@ export declare class Api<R extends RawApi = RawApi> {
|
|
|
846
869
|
*/
|
|
847
870
|
unpinAllForumTopicMessages(chat_id: number | string, message_thread_id: number, signal?: AbortSignal): Promise<true>;
|
|
848
871
|
/**
|
|
849
|
-
* 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.
|
|
872
|
+
* 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 the can_manage_topics administrator rights. Returns True on success.
|
|
850
873
|
*
|
|
851
874
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
852
875
|
* @param name New topic name, 1-128 characters
|
package/out/core/api.js
CHANGED
|
@@ -381,7 +381,7 @@ class Api {
|
|
|
381
381
|
return this.raw.stopMessageLiveLocation({ inline_message_id, ...other }, signal);
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
|
-
* Use this method to send paid media
|
|
384
|
+
* Use this method to send paid media. On success, the sent Message is returned.
|
|
385
385
|
*
|
|
386
386
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
387
387
|
* @param star_count The number of Telegram Stars that must be paid to buy access to the media
|
|
@@ -452,11 +452,11 @@ class Api {
|
|
|
452
452
|
return this.raw.sendDice({ chat_id, emoji, ...other }, signal);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
|
-
* Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel.
|
|
455
|
+
* Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
|
|
456
456
|
*
|
|
457
457
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
458
458
|
* @param message_id Identifier of the target message
|
|
459
|
-
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
|
|
459
|
+
* @param reaction A list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
|
|
460
460
|
* @param other Optional remaining parameters, confer the official reference below
|
|
461
461
|
* @param signal Optional `AbortSignal` to cancel the request
|
|
462
462
|
*
|
|
@@ -668,7 +668,7 @@ class Api {
|
|
|
668
668
|
return this.raw.createChatInviteLink({ chat_id, ...other }, signal);
|
|
669
669
|
}
|
|
670
670
|
/**
|
|
671
|
-
*
|
|
671
|
+
* Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
672
672
|
*
|
|
673
673
|
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
674
674
|
* @param invite_link The invite link to edit
|
|
@@ -681,7 +681,34 @@ class Api {
|
|
|
681
681
|
return this.raw.editChatInviteLink({ chat_id, invite_link, ...other }, signal);
|
|
682
682
|
}
|
|
683
683
|
/**
|
|
684
|
-
*
|
|
684
|
+
* Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.
|
|
685
|
+
*
|
|
686
|
+
* @param chat_id Unique identifier for the target channel chat or username of the target channel (in the format @channelusername)
|
|
687
|
+
* @param subscription_period The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
|
|
688
|
+
* @param subscription_price The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
|
|
689
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
690
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
691
|
+
*
|
|
692
|
+
* **Official reference:** https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
|
|
693
|
+
*/
|
|
694
|
+
createChatSubscriptionInviteLink(chat_id, subscription_period, subscription_price, other, signal) {
|
|
695
|
+
return this.raw.createChatSubscriptionInviteLink({ chat_id, subscription_period, subscription_price, ...other }, signal);
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.
|
|
699
|
+
*
|
|
700
|
+
* @param chat_id Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
|
701
|
+
* @param invite_link The invite link to edit
|
|
702
|
+
* @param other Optional remaining parameters, confer the official reference below
|
|
703
|
+
* @param signal Optional `AbortSignal` to cancel the request
|
|
704
|
+
*
|
|
705
|
+
* **Official reference:** https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
|
|
706
|
+
*/
|
|
707
|
+
editChatSubscriptionInviteLink(chat_id, invite_link, other, signal) {
|
|
708
|
+
return this.raw.editChatSubscriptionInviteLink({ chat_id, invite_link, ...other }, signal);
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.
|
|
685
712
|
*
|
|
686
713
|
* @param chat_id Unique identifier of the target chat or username of the target channel (in the format @channelusername)
|
|
687
714
|
* @param invite_link The invite link to revoke
|
|
@@ -907,7 +934,7 @@ class Api {
|
|
|
907
934
|
return this.raw.createForumTopic({ chat_id, name, ...other }, signal);
|
|
908
935
|
}
|
|
909
936
|
/**
|
|
910
|
-
* 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.
|
|
937
|
+
* 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 the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
|
|
911
938
|
*
|
|
912
939
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
913
940
|
* @param message_thread_id Unique identifier for the target message thread of the forum topic
|
|
@@ -968,7 +995,7 @@ class Api {
|
|
|
968
995
|
return this.raw.unpinAllForumTopicMessages({ chat_id, message_thread_id }, signal);
|
|
969
996
|
}
|
|
970
997
|
/**
|
|
971
|
-
* 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.
|
|
998
|
+
* 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 the can_manage_topics administrator rights. Returns True on success.
|
|
972
999
|
*
|
|
973
1000
|
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
|
|
974
1001
|
* @param name New topic name, 1-128 characters
|
package/out/filter.d.ts
CHANGED
|
@@ -742,16 +742,19 @@ declare const UPDATE_KEYS: {
|
|
|
742
742
|
readonly old_reaction: {
|
|
743
743
|
readonly emoji: {};
|
|
744
744
|
readonly custom_emoji: {};
|
|
745
|
+
readonly paid: {};
|
|
745
746
|
};
|
|
746
747
|
readonly new_reaction: {
|
|
747
748
|
readonly emoji: {};
|
|
748
749
|
readonly custom_emoji: {};
|
|
750
|
+
readonly paid: {};
|
|
749
751
|
};
|
|
750
752
|
};
|
|
751
753
|
readonly message_reaction_count: {
|
|
752
754
|
readonly reactions: {
|
|
753
755
|
readonly emoji: {};
|
|
754
756
|
readonly custom_emoji: {};
|
|
757
|
+
readonly paid: {};
|
|
755
758
|
};
|
|
756
759
|
};
|
|
757
760
|
readonly chat_boost: {};
|
package/out/filter.js
CHANGED
package/out/web.mjs
CHANGED
|
@@ -187,7 +187,8 @@ const STICKER_KEYS = {
|
|
|
187
187
|
};
|
|
188
188
|
const REACTION_KEYS = {
|
|
189
189
|
emoji: {},
|
|
190
|
-
custom_emoji: {}
|
|
190
|
+
custom_emoji: {},
|
|
191
|
+
paid: {}
|
|
191
192
|
};
|
|
192
193
|
const COMMON_MESSAGE_KEYS = {
|
|
193
194
|
forward_origin: FORWARD_ORIGIN_KEYS,
|
|
@@ -405,6 +406,9 @@ const checker = {
|
|
|
405
406
|
type: "emoji",
|
|
406
407
|
emoji
|
|
407
408
|
} : emoji);
|
|
409
|
+
const emoji = new Set(normalized.filter((r)=>r.type === "emoji").map((r)=>r.emoji));
|
|
410
|
+
const customEmoji = new Set(normalized.filter((r)=>r.type === "custom_emoji").map((r)=>r.custom_emoji_id));
|
|
411
|
+
const paid = normalized.some((r)=>r.type === "paid");
|
|
408
412
|
return (ctx)=>{
|
|
409
413
|
if (!hasMessageReaction(ctx)) return false;
|
|
410
414
|
const { old_reaction, new_reaction } = ctx.messageReaction;
|
|
@@ -426,25 +430,22 @@ const checker = {
|
|
|
426
430
|
break;
|
|
427
431
|
}
|
|
428
432
|
}
|
|
429
|
-
} else {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
if (wanted.emoji === reaction.emoji) {
|
|
435
|
-
return true;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
} else if (reaction.type === "custom_emoji") {
|
|
439
|
-
for (const wanted of normalized){
|
|
440
|
-
if (wanted.type !== "custom_emoji") continue;
|
|
441
|
-
if (wanted.custom_emoji_id === reaction.custom_emoji_id) {
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
} else {
|
|
446
|
-
return true;
|
|
433
|
+
} else if (reaction.type === "paid") {
|
|
434
|
+
for (const old of old_reaction){
|
|
435
|
+
if (old.type !== "paid") continue;
|
|
436
|
+
isOld = true;
|
|
437
|
+
break;
|
|
447
438
|
}
|
|
439
|
+
} else {}
|
|
440
|
+
if (isOld) continue;
|
|
441
|
+
if (reaction.type === "emoji") {
|
|
442
|
+
if (emoji.has(reaction.emoji)) return true;
|
|
443
|
+
} else if (reaction.type === "custom_emoji") {
|
|
444
|
+
if (customEmoji.has(reaction.custom_emoji_id)) return true;
|
|
445
|
+
} else if (reaction.type === "paid") {
|
|
446
|
+
if (paid) return true;
|
|
447
|
+
} else {
|
|
448
|
+
return true;
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
return false;
|
|
@@ -610,6 +611,8 @@ class Context {
|
|
|
610
611
|
const customEmojiAdded = [];
|
|
611
612
|
const customEmojiKept = [];
|
|
612
613
|
const customEmojiRemoved = [];
|
|
614
|
+
let paid = false;
|
|
615
|
+
let paidAdded = false;
|
|
613
616
|
const r = this.messageReaction;
|
|
614
617
|
if (r !== undefined) {
|
|
615
618
|
const { old_reaction, new_reaction } = r;
|
|
@@ -618,6 +621,8 @@ class Context {
|
|
|
618
621
|
emoji.push(reaction.emoji);
|
|
619
622
|
} else if (reaction.type === "custom_emoji") {
|
|
620
623
|
customEmoji.push(reaction.custom_emoji_id);
|
|
624
|
+
} else if (reaction.type === "paid") {
|
|
625
|
+
paid = paidAdded = true;
|
|
621
626
|
}
|
|
622
627
|
}
|
|
623
628
|
for (const reaction of old_reaction){
|
|
@@ -625,6 +630,8 @@ class Context {
|
|
|
625
630
|
emojiRemoved.push(reaction.emoji);
|
|
626
631
|
} else if (reaction.type === "custom_emoji") {
|
|
627
632
|
customEmojiRemoved.push(reaction.custom_emoji_id);
|
|
633
|
+
} else if (reaction.type === "paid") {
|
|
634
|
+
paidAdded = false;
|
|
628
635
|
}
|
|
629
636
|
}
|
|
630
637
|
emojiAdded.push(...emoji);
|
|
@@ -666,7 +673,9 @@ class Context {
|
|
|
666
673
|
customEmoji,
|
|
667
674
|
customEmojiAdded,
|
|
668
675
|
customEmojiKept,
|
|
669
|
-
customEmojiRemoved
|
|
676
|
+
customEmojiRemoved,
|
|
677
|
+
paid,
|
|
678
|
+
paidAdded
|
|
670
679
|
};
|
|
671
680
|
}
|
|
672
681
|
static has = checker;
|
|
@@ -894,6 +903,12 @@ class Context {
|
|
|
894
903
|
editChatInviteLink(invite_link, other, signal) {
|
|
895
904
|
return this.api.editChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, other, signal);
|
|
896
905
|
}
|
|
906
|
+
createChatSubscriptionInviteLink(subscription_period, subscription_price, other, signal) {
|
|
907
|
+
return this.api.createChatSubscriptionInviteLink(orThrow(this.chatId, "createChatSubscriptionInviteLink"), subscription_period, subscription_price, other, signal);
|
|
908
|
+
}
|
|
909
|
+
editChatSubscriptionInviteLink(invite_link, other, signal) {
|
|
910
|
+
return this.api.editChatSubscriptionInviteLink(orThrow(this.chatId, "editChatSubscriptionInviteLink"), invite_link, other, signal);
|
|
911
|
+
}
|
|
897
912
|
revokeChatInviteLink(invite_link, signal) {
|
|
898
913
|
return this.api.revokeChatInviteLink(orThrow(this.chatId, "editChatInviteLink"), invite_link, signal);
|
|
899
914
|
}
|
|
@@ -2722,6 +2737,21 @@ class Api {
|
|
|
2722
2737
|
...other
|
|
2723
2738
|
}, signal);
|
|
2724
2739
|
}
|
|
2740
|
+
createChatSubscriptionInviteLink(chat_id, subscription_period, subscription_price, other, signal) {
|
|
2741
|
+
return this.raw.createChatSubscriptionInviteLink({
|
|
2742
|
+
chat_id,
|
|
2743
|
+
subscription_period,
|
|
2744
|
+
subscription_price,
|
|
2745
|
+
...other
|
|
2746
|
+
}, signal);
|
|
2747
|
+
}
|
|
2748
|
+
editChatSubscriptionInviteLink(chat_id, invite_link, other, signal) {
|
|
2749
|
+
return this.raw.editChatSubscriptionInviteLink({
|
|
2750
|
+
chat_id,
|
|
2751
|
+
invite_link,
|
|
2752
|
+
...other
|
|
2753
|
+
}, signal);
|
|
2754
|
+
}
|
|
2725
2755
|
revokeChatInviteLink(chat_id, invite_link, signal) {
|
|
2726
2756
|
return this.raw.revokeChatInviteLink({
|
|
2727
2757
|
chat_id,
|
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.29.0",
|
|
5
5
|
"author": "KnorpelSenf",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"engines": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"backport": "deno2node tsconfig.json"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@grammyjs/types": "3.
|
|
20
|
+
"@grammyjs/types": "3.13.0",
|
|
21
21
|
"abort-controller": "^3.0.0",
|
|
22
22
|
"debug": "^4.3.4",
|
|
23
23
|
"node-fetch": "^2.7.0"
|