@yaebal/contexts 0.0.3 → 0.0.5
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/lib/generated/business-connection.d.ts +48 -0
- package/lib/generated/business-connection.d.ts.map +1 -1
- package/lib/generated/business-connection.js +96 -0
- package/lib/generated/business-connection.js.map +1 -1
- package/lib/generated/business-message.d.ts +83 -41
- package/lib/generated/business-message.d.ts.map +1 -1
- package/lib/generated/business-message.js +125 -41
- package/lib/generated/business-message.js.map +1 -1
- package/lib/generated/callback-query.d.ts +40 -40
- package/lib/generated/callback-query.d.ts.map +1 -1
- package/lib/generated/callback-query.js +40 -40
- package/lib/generated/callback-query.js.map +1 -1
- package/lib/generated/channel-post.d.ts +33 -35
- package/lib/generated/channel-post.d.ts.map +1 -1
- package/lib/generated/channel-post.js +37 -41
- package/lib/generated/channel-post.js.map +1 -1
- package/lib/generated/chat-boost.d.ts +0 -12
- package/lib/generated/chat-boost.d.ts.map +1 -1
- package/lib/generated/chat-boost.js +0 -24
- package/lib/generated/chat-boost.js.map +1 -1
- package/lib/generated/chat-join-request.d.ts +0 -12
- package/lib/generated/chat-join-request.d.ts.map +1 -1
- package/lib/generated/chat-join-request.js +0 -24
- package/lib/generated/chat-join-request.js.map +1 -1
- package/lib/generated/chat-member.d.ts +0 -12
- package/lib/generated/chat-member.d.ts.map +1 -1
- package/lib/generated/chat-member.js +0 -24
- package/lib/generated/chat-member.js.map +1 -1
- package/lib/generated/deleted-business-messages.d.ts +68 -38
- package/lib/generated/deleted-business-messages.d.ts.map +1 -1
- package/lib/generated/deleted-business-messages.js +108 -48
- package/lib/generated/deleted-business-messages.js.map +1 -1
- package/lib/generated/edited-business-message.d.ts +83 -41
- package/lib/generated/edited-business-message.d.ts.map +1 -1
- package/lib/generated/edited-business-message.js +125 -41
- package/lib/generated/edited-business-message.js.map +1 -1
- package/lib/generated/edited-channel-post.d.ts +33 -35
- package/lib/generated/edited-channel-post.d.ts.map +1 -1
- package/lib/generated/edited-channel-post.js +37 -41
- package/lib/generated/edited-channel-post.js.map +1 -1
- package/lib/generated/edited-message.d.ts +33 -35
- package/lib/generated/edited-message.d.ts.map +1 -1
- package/lib/generated/edited-message.js +37 -41
- package/lib/generated/edited-message.js.map +1 -1
- package/lib/generated/guest-message.d.ts +37 -37
- package/lib/generated/guest-message.d.ts.map +1 -1
- package/lib/generated/guest-message.js +42 -42
- package/lib/generated/guest-message.js.map +1 -1
- package/lib/generated/index.d.ts +3 -2
- package/lib/generated/index.d.ts.map +1 -1
- package/lib/generated/index.js +3 -2
- package/lib/generated/index.js.map +1 -1
- package/lib/generated/message-reaction-count.d.ts +0 -16
- package/lib/generated/message-reaction-count.d.ts.map +1 -1
- package/lib/generated/message-reaction-count.js +0 -32
- package/lib/generated/message-reaction-count.js.map +1 -1
- package/lib/generated/message-reaction.d.ts +0 -16
- package/lib/generated/message-reaction.d.ts.map +1 -1
- package/lib/generated/message-reaction.js +0 -32
- package/lib/generated/message-reaction.js.map +1 -1
- package/lib/generated/message.d.ts +33 -35
- package/lib/generated/message.d.ts.map +1 -1
- package/lib/generated/message.js +37 -41
- package/lib/generated/message.js.map +1 -1
- package/lib/generated/my-chat-member.d.ts +0 -12
- package/lib/generated/my-chat-member.d.ts.map +1 -1
- package/lib/generated/my-chat-member.js +0 -24
- package/lib/generated/my-chat-member.js.map +1 -1
- package/lib/generated/removed-chat-boost.d.ts +0 -12
- package/lib/generated/removed-chat-boost.d.ts.map +1 -1
- package/lib/generated/removed-chat-boost.js +0 -24
- package/lib/generated/removed-chat-boost.js.map +1 -1
- package/lib/index.test.js +203 -1
- package/lib/index.test.js.map +1 -1
- package/lib/sugar/business-message.d.ts +12 -3
- package/lib/sugar/business-message.d.ts.map +1 -1
- package/lib/sugar/business-message.js +12 -1
- package/lib/sugar/business-message.js.map +1 -1
- package/lib/sugar/channel-post.d.ts +5 -2
- package/lib/sugar/channel-post.d.ts.map +1 -1
- package/lib/sugar/edited-business-message.d.ts +12 -3
- package/lib/sugar/edited-business-message.d.ts.map +1 -1
- package/lib/sugar/edited-business-message.js +12 -1
- package/lib/sugar/edited-business-message.js.map +1 -1
- package/lib/sugar/edited-channel-post.d.ts +5 -2
- package/lib/sugar/edited-channel-post.d.ts.map +1 -1
- package/lib/sugar/edited-message.d.ts +5 -2
- package/lib/sugar/edited-message.d.ts.map +1 -1
- package/lib/sugar/guest-message.d.ts +13 -0
- package/lib/sugar/guest-message.d.ts.map +1 -0
- package/lib/sugar/guest-message.js +13 -0
- package/lib/sugar/guest-message.js.map +1 -0
- package/lib/sugar/message-mixin.d.ts +6 -0
- package/lib/sugar/message-mixin.d.ts.map +1 -1
- package/lib/sugar/message-mixin.js +32 -1
- package/lib/sugar/message-mixin.js.map +1 -1
- package/lib/sugar/message.d.ts +5 -2
- package/lib/sugar/message.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/generated/business-connection.ts +96 -0
- package/src/generated/business-message.ts +166 -82
- package/src/generated/callback-query.ts +80 -80
- package/src/generated/channel-post.ts +66 -70
- package/src/generated/chat-boost.ts +0 -24
- package/src/generated/chat-join-request.ts +0 -24
- package/src/generated/chat-member.ts +0 -24
- package/src/generated/deleted-business-messages.ts +136 -76
- package/src/generated/edited-business-message.ts +166 -82
- package/src/generated/edited-channel-post.ts +66 -70
- package/src/generated/edited-message.ts +66 -70
- package/src/generated/guest-message.ts +72 -72
- package/src/generated/index.ts +3 -2
- package/src/generated/message-reaction-count.ts +0 -32
- package/src/generated/message-reaction.ts +0 -32
- package/src/generated/message.ts +66 -70
- package/src/generated/my-chat-member.ts +0 -24
- package/src/generated/removed-chat-boost.ts +0 -24
- package/src/index.test.ts +227 -0
- package/src/sugar/business-message.ts +14 -2
- package/src/sugar/edited-business-message.ts +14 -2
- package/src/sugar/guest-message.ts +20 -0
- package/src/sugar/message-mixin.ts +41 -1
package/src/generated/message.ts
CHANGED
|
@@ -35,85 +35,89 @@ export class MessageContextBase {
|
|
|
35
35
|
get messageId(): number {
|
|
36
36
|
return this.message_id;
|
|
37
37
|
}
|
|
38
|
+
/** camel-case alias for `business_connection_id`. */
|
|
39
|
+
get businessConnectionId(): string | undefined {
|
|
40
|
+
return this.business_connection_id;
|
|
41
|
+
}
|
|
42
|
+
/** camel-case alias for `message_thread_id` (the forum topic this message is in, if any). */
|
|
43
|
+
get messageThreadId(): number | undefined {
|
|
44
|
+
return this.message_thread_id;
|
|
45
|
+
}
|
|
38
46
|
/** reply to this message. */
|
|
39
|
-
reply(params: Omit<t.SendMessageParams, "chat_id">) {
|
|
40
|
-
return this.api.call<t.Message>("sendMessage", { chat_id: this.chat.id, reply_parameters: { message_id: this.message_id }, ...params });
|
|
47
|
+
reply(params: Omit<t.SendMessageParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
48
|
+
return this.api.call<t.Message>("sendMessage", { chat_id: this.chat.id, reply_parameters: { message_id: this.message_id }, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
41
49
|
}
|
|
42
50
|
/** Use this method to send text messages. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
43
|
-
send(params: Omit<t.SendMessageParams, "chat_id">) {
|
|
44
|
-
return this.api.call<t.Message>("sendMessage", { chat_id: this.chat.id, ...params });
|
|
51
|
+
send(params: Omit<t.SendMessageParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
52
|
+
return this.api.call<t.Message>("sendMessage", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
45
53
|
}
|
|
46
54
|
/** Use this method to send photos. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
47
|
-
sendPhoto(params: Omit<t.SendPhotoParams, "chat_id">) {
|
|
48
|
-
return this.api.call<t.Message>("sendPhoto", { chat_id: this.chat.id, ...params });
|
|
55
|
+
sendPhoto(params: Omit<t.SendPhotoParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
56
|
+
return this.api.call<t.Message>("sendPhoto", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
49
57
|
}
|
|
50
58
|
/** Use this method to send live photos. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
51
|
-
sendLivePhoto(params: Omit<t.SendLivePhotoParams, "chat_id">) {
|
|
52
|
-
return this.api.call<t.Message>("sendLivePhoto", { chat_id: this.chat.id, ...params });
|
|
59
|
+
sendLivePhoto(params: Omit<t.SendLivePhotoParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
60
|
+
return this.api.call<t.Message>("sendLivePhoto", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
53
61
|
}
|
|
54
62
|
/** Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the [sendVoice](https://core.telegram.org/bots/api/#sendvoice) method instead. */
|
|
55
|
-
sendAudio(params: Omit<t.SendAudioParams, "chat_id">) {
|
|
56
|
-
return this.api.call<t.Message>("sendAudio", { chat_id: this.chat.id, ...params });
|
|
63
|
+
sendAudio(params: Omit<t.SendAudioParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
64
|
+
return this.api.call<t.Message>("sendAudio", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
57
65
|
}
|
|
58
66
|
/** Use this method to send general files. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future. */
|
|
59
|
-
sendDocument(params: Omit<t.SendDocumentParams, "chat_id">) {
|
|
60
|
-
return this.api.call<t.Message>("sendDocument", { chat_id: this.chat.id, ...params });
|
|
67
|
+
sendDocument(params: Omit<t.SendDocumentParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
68
|
+
return this.api.call<t.Message>("sendDocument", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
61
69
|
}
|
|
62
70
|
/** Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as [Document](https://core.telegram.org/bots/api/#document)). On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future. */
|
|
63
|
-
sendVideo(params: Omit<t.SendVideoParams, "chat_id">) {
|
|
64
|
-
return this.api.call<t.Message>("sendVideo", { chat_id: this.chat.id, ...params });
|
|
71
|
+
sendVideo(params: Omit<t.SendVideoParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
72
|
+
return this.api.call<t.Message>("sendVideo", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
65
73
|
}
|
|
66
74
|
/** Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future. */
|
|
67
|
-
sendAnimation(params: Omit<t.SendAnimationParams, "chat_id">) {
|
|
68
|
-
return this.api.call<t.Message>("sendAnimation", { chat_id: this.chat.id, ...params });
|
|
75
|
+
sendAnimation(params: Omit<t.SendAnimationParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
76
|
+
return this.api.call<t.Message>("sendAnimation", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
69
77
|
}
|
|
70
78
|
/** Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as [Audio](https://core.telegram.org/bots/api/#audio) or [Document](https://core.telegram.org/bots/api/#document)). On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. */
|
|
71
|
-
sendVoice(params: Omit<t.SendVoiceParams, "chat_id">) {
|
|
72
|
-
return this.api.call<t.Message>("sendVoice", { chat_id: this.chat.id, ...params });
|
|
79
|
+
sendVoice(params: Omit<t.SendVoiceParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
80
|
+
return this.api.call<t.Message>("sendVoice", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
73
81
|
}
|
|
74
82
|
/** As of [v.4.0](https://telegram.org/blog/video-messages-and-telescope), Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
75
|
-
sendVideoNote(params: Omit<t.SendVideoNoteParams, "chat_id">) {
|
|
76
|
-
return this.api.call<t.Message>("sendVideoNote", { chat_id: this.chat.id, ...params });
|
|
83
|
+
sendVideoNote(params: Omit<t.SendVideoNoteParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
84
|
+
return this.api.call<t.Message>("sendVideoNote", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
77
85
|
}
|
|
78
86
|
/** Use this method to send paid media. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
79
|
-
sendPaidMedia(params: Omit<t.SendPaidMediaParams, "chat_id">) {
|
|
80
|
-
return this.api.call<t.Message>("sendPaidMedia", { chat_id: this.chat.id, ...params });
|
|
87
|
+
sendPaidMedia(params: Omit<t.SendPaidMediaParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
88
|
+
return this.api.call<t.Message>("sendPaidMedia", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
81
89
|
}
|
|
82
90
|
/** Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of [Message](https://core.telegram.org/bots/api/#message) objects that were sent is returned. */
|
|
83
|
-
sendMediaGroup(params: Omit<t.SendMediaGroupParams, "chat_id">) {
|
|
84
|
-
return this.api.call<t.Message[]>("sendMediaGroup", { chat_id: this.chat.id, ...params });
|
|
91
|
+
sendMediaGroup(params: Omit<t.SendMediaGroupParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
92
|
+
return this.api.call<t.Message[]>("sendMediaGroup", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
85
93
|
}
|
|
86
94
|
/** Use this method to send point on the map. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
87
|
-
sendLocation(params: Omit<t.SendLocationParams, "chat_id">) {
|
|
88
|
-
return this.api.call<t.Message>("sendLocation", { chat_id: this.chat.id, ...params });
|
|
95
|
+
sendLocation(params: Omit<t.SendLocationParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
96
|
+
return this.api.call<t.Message>("sendLocation", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
89
97
|
}
|
|
90
98
|
/** Use this method to send information about a venue. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
91
|
-
sendVenue(params: Omit<t.SendVenueParams, "chat_id">) {
|
|
92
|
-
return this.api.call<t.Message>("sendVenue", { chat_id: this.chat.id, ...params });
|
|
99
|
+
sendVenue(params: Omit<t.SendVenueParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
100
|
+
return this.api.call<t.Message>("sendVenue", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
93
101
|
}
|
|
94
102
|
/** Use this method to send phone contacts. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
95
|
-
sendContact(params: Omit<t.SendContactParams, "chat_id">) {
|
|
96
|
-
return this.api.call<t.Message>("sendContact", { chat_id: this.chat.id, ...params });
|
|
103
|
+
sendContact(params: Omit<t.SendContactParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
104
|
+
return this.api.call<t.Message>("sendContact", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
97
105
|
}
|
|
98
106
|
/** Use this method to send a native poll. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
99
|
-
sendPoll(params: Omit<t.SendPollParams, "chat_id">) {
|
|
100
|
-
return this.api.call<t.Message>("sendPoll", { chat_id: this.chat.id, ...params });
|
|
101
|
-
}
|
|
102
|
-
/** Use this method to send a checklist on behalf of a connected business account. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
103
|
-
sendChecklist(params: Omit<t.SendChecklistParams, "chat_id">) {
|
|
104
|
-
return this.api.call<t.Message>("sendChecklist", { chat_id: this.chat.id, ...params });
|
|
107
|
+
sendPoll(params: Omit<t.SendPollParams, "chat_id" | "message_thread_id">) {
|
|
108
|
+
return this.api.call<t.Message>("sendPoll", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
105
109
|
}
|
|
106
110
|
/** Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
107
|
-
sendDice(params: Omit<t.SendDiceParams, "chat_id">) {
|
|
108
|
-
return this.api.call<t.Message>("sendDice", { chat_id: this.chat.id, ...params });
|
|
111
|
+
sendDice(params: Omit<t.SendDiceParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
112
|
+
return this.api.call<t.Message>("sendDice", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
109
113
|
}
|
|
110
114
|
/** Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you **must** call [sendMessage](https://core.telegram.org/bots/api/#sendmessage) with the complete message to persist it in the user's chat. Returns *True* on success. */
|
|
111
|
-
sendMessageDraft(params: Omit<t.SendMessageDraftParams, "chat_id">) {
|
|
112
|
-
return this.api.call<boolean>("sendMessageDraft", { chat_id: this.chat.id, ...params });
|
|
115
|
+
sendMessageDraft(params: Omit<t.SendMessageDraftParams, "chat_id" | "message_thread_id">) {
|
|
116
|
+
return this.api.call<boolean>("sendMessageDraft", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
113
117
|
}
|
|
114
118
|
/** Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns *True* on success. Example: The [ImageBot](https://t.me/imagebot) needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use [sendChatAction](https://core.telegram.org/bots/api/#sendchataction) with *action* = *upload\_photo*. The user will see a “sending photo” status for the bot. We only recommend using this method when a response from the bot will take a **noticeable** amount of time to arrive. */
|
|
115
|
-
sendChatAction(params: Omit<t.SendChatActionParams, "chat_id">) {
|
|
116
|
-
return this.api.call<boolean>("sendChatAction", { chat_id: this.chat.id, ...params });
|
|
119
|
+
sendChatAction(params: Omit<t.SendChatActionParams, "chat_id" | "message_thread_id">) {
|
|
120
|
+
return this.api.call<boolean>("sendChatAction", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
117
121
|
}
|
|
118
122
|
/** Use this method to change the chosen reactions on a message. Service messages of some types 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. */
|
|
119
123
|
react(params: Omit<t.SetMessageReactionParams, "chat_id" | "message_id">) {
|
|
@@ -264,24 +268,24 @@ export class MessageContextBase {
|
|
|
264
268
|
return this.api.call<t.ForumTopic>("createForumTopic", { chat_id: this.chat.id, ...params });
|
|
265
269
|
}
|
|
266
270
|
/** Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a 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. */
|
|
267
|
-
editForumTopic(params: Omit<t.EditForumTopicParams, "chat_id">) {
|
|
268
|
-
return this.api.call<boolean>("editForumTopic", { chat_id: this.chat.id, ...params });
|
|
271
|
+
editForumTopic(params: Omit<t.EditForumTopicParams, "chat_id" | "message_thread_id">) {
|
|
272
|
+
return this.api.call<boolean>("editForumTopic", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
269
273
|
}
|
|
270
274
|
/** 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. */
|
|
271
|
-
closeForumTopic(params
|
|
272
|
-
return this.api.call<boolean>("closeForumTopic", { chat_id: this.chat.id, ...params });
|
|
275
|
+
closeForumTopic(params?: Omit<t.CloseForumTopicParams, "chat_id" | "message_thread_id">) {
|
|
276
|
+
return this.api.call<boolean>("closeForumTopic", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
273
277
|
}
|
|
274
278
|
/** Use this method to reopen a closed 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. */
|
|
275
|
-
reopenForumTopic(params
|
|
276
|
-
return this.api.call<boolean>("reopenForumTopic", { chat_id: this.chat.id, ...params });
|
|
279
|
+
reopenForumTopic(params?: Omit<t.ReopenForumTopicParams, "chat_id" | "message_thread_id">) {
|
|
280
|
+
return this.api.call<boolean>("reopenForumTopic", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
277
281
|
}
|
|
278
282
|
/** Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_delete\_messages* administrator rights. Returns *True* on success. */
|
|
279
|
-
deleteForumTopic(params
|
|
280
|
-
return this.api.call<boolean>("deleteForumTopic", { chat_id: this.chat.id, ...params });
|
|
283
|
+
deleteForumTopic(params?: Omit<t.DeleteForumTopicParams, "chat_id" | "message_thread_id">) {
|
|
284
|
+
return this.api.call<boolean>("deleteForumTopic", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
281
285
|
}
|
|
282
286
|
/** Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_pin\_messages* administrator right in the supergroup. Returns *True* on success. */
|
|
283
|
-
unpinAllForumTopicMessages(params
|
|
284
|
-
return this.api.call<boolean>("unpinAllForumTopicMessages", { chat_id: this.chat.id, ...params });
|
|
287
|
+
unpinAllForumTopicMessages(params?: Omit<t.UnpinAllForumTopicMessagesParams, "chat_id" | "message_thread_id">) {
|
|
288
|
+
return this.api.call<boolean>("unpinAllForumTopicMessages", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
285
289
|
}
|
|
286
290
|
/** 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. */
|
|
287
291
|
editGeneralForumTopic(params: Omit<t.EditGeneralForumTopicParams, "chat_id">) {
|
|
@@ -359,10 +363,6 @@ export class MessageContextBase {
|
|
|
359
363
|
removeChatVerification(params?: Omit<t.RemoveChatVerificationParams, "chat_id">) {
|
|
360
364
|
return this.api.call<boolean>("removeChatVerification", { chat_id: this.chat.id, ...params });
|
|
361
365
|
}
|
|
362
|
-
/** Marks incoming message as read on behalf of a business account. Requires the *can\_read\_messages* business bot right. Returns *True* on success. */
|
|
363
|
-
readBusinessMessage(params: Omit<t.ReadBusinessMessageParams, "chat_id" | "message_id">) {
|
|
364
|
-
return this.api.call<boolean>("readBusinessMessage", { chat_id: this.chat.id, message_id: this.message_id, ...params });
|
|
365
|
-
}
|
|
366
366
|
/** Returns the gifts owned and hosted by a user. Returns [OwnedGifts](https://core.telegram.org/bots/api/#ownedgifts) on success. */
|
|
367
367
|
getUserGifts(params: Omit<t.GetUserGiftsParams, "user_id">) {
|
|
368
368
|
return this.api.call<t.OwnedGifts>("getUserGifts", { user_id: this.from?.id, ...params });
|
|
@@ -399,10 +399,6 @@ export class MessageContextBase {
|
|
|
399
399
|
stopMessageLiveLocation(params: Omit<t.StopMessageLiveLocationParams, "chat_id" | "message_id">) {
|
|
400
400
|
return this.api.call<t.Message | boolean>("stopMessageLiveLocation", { chat_id: this.chat.id, message_id: this.message_id, ...params });
|
|
401
401
|
}
|
|
402
|
-
/** Use this method to edit a checklist on behalf of a connected business account. On success, the edited [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
403
|
-
editMessageChecklist(params: Omit<t.EditMessageChecklistParams, "chat_id" | "message_id">) {
|
|
404
|
-
return this.api.call<t.Message>("editMessageChecklist", { chat_id: this.chat.id, message_id: this.message_id, ...params });
|
|
405
|
-
}
|
|
406
402
|
/** Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within **48 hours** from the time they were sent. */
|
|
407
403
|
editReplyMarkup(params: Omit<t.EditMessageReplyMarkupParams, "chat_id" | "message_id">) {
|
|
408
404
|
return this.api.call<t.Message | boolean>("editMessageReplyMarkup", { chat_id: this.chat.id, message_id: this.message_id, ...params });
|
|
@@ -436,8 +432,8 @@ export class MessageContextBase {
|
|
|
436
432
|
return this.api.call<boolean>("deleteAllMessageReactions", { chat_id: this.chat.id, user_id: this.from?.id, ...params });
|
|
437
433
|
}
|
|
438
434
|
/** Use this method to send static .WEBP, [animated](https://telegram.org/blog/animated-stickers) .TGS, or [video](https://telegram.org/blog/video-stickers-better-reactions) .WEBM stickers. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
439
|
-
sendSticker(params: Omit<t.SendStickerParams, "chat_id">) {
|
|
440
|
-
return this.api.call<t.Message>("sendSticker", { chat_id: this.chat.id, ...params });
|
|
435
|
+
sendSticker(params: Omit<t.SendStickerParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
436
|
+
return this.api.call<t.Message>("sendSticker", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
441
437
|
}
|
|
442
438
|
/** Use this method to upload a file with a sticker for later use in the [createNewStickerSet](https://core.telegram.org/bots/api/#createnewstickerset), [addStickerToSet](https://core.telegram.org/bots/api/#addstickertoset), or [replaceStickerInSet](https://core.telegram.org/bots/api/#replacestickerinset) methods (the file can be used multiple times). Returns the uploaded [File](https://core.telegram.org/bots/api/#file) on success. */
|
|
443
439
|
uploadStickerFile(params: Omit<t.UploadStickerFileParams, "user_id">) {
|
|
@@ -460,16 +456,16 @@ export class MessageContextBase {
|
|
|
460
456
|
return this.api.call<boolean>("setStickerSetThumbnail", { user_id: this.from?.id, ...params });
|
|
461
457
|
}
|
|
462
458
|
/** Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
463
|
-
sendRichMessage(params: Omit<t.SendRichMessageParams, "chat_id">) {
|
|
464
|
-
return this.api.call<t.Message>("sendRichMessage", { chat_id: this.chat.id, ...params });
|
|
459
|
+
sendRichMessage(params: Omit<t.SendRichMessageParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
460
|
+
return this.api.call<t.Message>("sendRichMessage", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
465
461
|
}
|
|
466
462
|
/** Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you **must** call [sendRichMessage](https://core.telegram.org/bots/api/#sendrichmessage) with the complete message to persist it in the user's chat. Returns *True* on success. */
|
|
467
|
-
sendRichMessageDraft(params: Omit<t.SendRichMessageDraftParams, "chat_id">) {
|
|
468
|
-
return this.api.call<boolean>("sendRichMessageDraft", { chat_id: this.chat.id, ...params });
|
|
463
|
+
sendRichMessageDraft(params: Omit<t.SendRichMessageDraftParams, "chat_id" | "message_thread_id">) {
|
|
464
|
+
return this.api.call<boolean>("sendRichMessageDraft", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
469
465
|
}
|
|
470
466
|
/** Use this method to send invoices. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
471
|
-
sendInvoice(params: Omit<t.SendInvoiceParams, "chat_id">) {
|
|
472
|
-
return this.api.call<t.Message>("sendInvoice", { chat_id: this.chat.id, ...params });
|
|
467
|
+
sendInvoice(params: Omit<t.SendInvoiceParams, "chat_id" | "message_thread_id" | "direct_messages_topic_id">) {
|
|
468
|
+
return this.api.call<t.Message>("sendInvoice", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...((this.direct_messages_topic?.topic_id) === undefined ? {} : { direct_messages_topic_id: this.direct_messages_topic?.topic_id }), ...params });
|
|
473
469
|
}
|
|
474
470
|
/** Refunds a successful payment in [Telegram Stars](https://t.me/BotNews/90). Returns *True* on success. */
|
|
475
471
|
refundStarPayment(params: Omit<t.RefundStarPaymentParams, "user_id">) {
|
|
@@ -484,8 +480,8 @@ export class MessageContextBase {
|
|
|
484
480
|
return this.api.call<boolean>("setPassportDataErrors", { user_id: this.from?.id, ...params });
|
|
485
481
|
}
|
|
486
482
|
/** Use this method to send a game. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
487
|
-
sendGame(params: Omit<t.SendGameParams, "chat_id">) {
|
|
488
|
-
return this.api.call<t.Message>("sendGame", { chat_id: this.chat.id, ...params });
|
|
483
|
+
sendGame(params: Omit<t.SendGameParams, "chat_id" | "message_thread_id">) {
|
|
484
|
+
return this.api.call<t.Message>("sendGame", { chat_id: this.chat.id, ...((this.message_thread_id) === undefined ? {} : { message_thread_id: this.message_thread_id }), ...params });
|
|
489
485
|
}
|
|
490
486
|
/** Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the [Message](https://core.telegram.org/bots/api/#message) is returned, otherwise *True* is returned. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is *False*. */
|
|
491
487
|
setGameScore(params: Omit<t.SetGameScoreParams, "user_id" | "chat_id" | "message_id">) {
|
|
@@ -91,10 +91,6 @@ export class MyChatMemberContext {
|
|
|
91
91
|
sendPoll(params: Omit<t.SendPollParams, "chat_id">) {
|
|
92
92
|
return this.api.call<t.Message>("sendPoll", { chat_id: this.chat.id, ...params });
|
|
93
93
|
}
|
|
94
|
-
/** Use this method to send a checklist on behalf of a connected business account. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
95
|
-
sendChecklist(params: Omit<t.SendChecklistParams, "chat_id">) {
|
|
96
|
-
return this.api.call<t.Message>("sendChecklist", { chat_id: this.chat.id, ...params });
|
|
97
|
-
}
|
|
98
94
|
/** Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
99
95
|
sendDice(params: Omit<t.SendDiceParams, "chat_id">) {
|
|
100
96
|
return this.api.call<t.Message>("sendDice", { chat_id: this.chat.id, ...params });
|
|
@@ -247,26 +243,6 @@ export class MyChatMemberContext {
|
|
|
247
243
|
createForumTopic(params: Omit<t.CreateForumTopicParams, "chat_id">) {
|
|
248
244
|
return this.api.call<t.ForumTopic>("createForumTopic", { chat_id: this.chat.id, ...params });
|
|
249
245
|
}
|
|
250
|
-
/** Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a 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. */
|
|
251
|
-
editForumTopic(params: Omit<t.EditForumTopicParams, "chat_id">) {
|
|
252
|
-
return this.api.call<boolean>("editForumTopic", { chat_id: this.chat.id, ...params });
|
|
253
|
-
}
|
|
254
|
-
/** 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. */
|
|
255
|
-
closeForumTopic(params: Omit<t.CloseForumTopicParams, "chat_id">) {
|
|
256
|
-
return this.api.call<boolean>("closeForumTopic", { chat_id: this.chat.id, ...params });
|
|
257
|
-
}
|
|
258
|
-
/** Use this method to reopen a closed 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. */
|
|
259
|
-
reopenForumTopic(params: Omit<t.ReopenForumTopicParams, "chat_id">) {
|
|
260
|
-
return this.api.call<boolean>("reopenForumTopic", { chat_id: this.chat.id, ...params });
|
|
261
|
-
}
|
|
262
|
-
/** Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_delete\_messages* administrator rights. Returns *True* on success. */
|
|
263
|
-
deleteForumTopic(params: Omit<t.DeleteForumTopicParams, "chat_id">) {
|
|
264
|
-
return this.api.call<boolean>("deleteForumTopic", { chat_id: this.chat.id, ...params });
|
|
265
|
-
}
|
|
266
|
-
/** Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_pin\_messages* administrator right in the supergroup. Returns *True* on success. */
|
|
267
|
-
unpinAllForumTopicMessages(params: Omit<t.UnpinAllForumTopicMessagesParams, "chat_id">) {
|
|
268
|
-
return this.api.call<boolean>("unpinAllForumTopicMessages", { chat_id: this.chat.id, ...params });
|
|
269
|
-
}
|
|
270
246
|
/** 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. */
|
|
271
247
|
editGeneralForumTopic(params: Omit<t.EditGeneralForumTopicParams, "chat_id">) {
|
|
272
248
|
return this.api.call<boolean>("editGeneralForumTopic", { chat_id: this.chat.id, ...params });
|
|
@@ -83,10 +83,6 @@ export class RemovedChatBoostContext {
|
|
|
83
83
|
sendPoll(params: Omit<t.SendPollParams, "chat_id">) {
|
|
84
84
|
return this.api.call<t.Message>("sendPoll", { chat_id: this.chat.id, ...params });
|
|
85
85
|
}
|
|
86
|
-
/** Use this method to send a checklist on behalf of a connected business account. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
87
|
-
sendChecklist(params: Omit<t.SendChecklistParams, "chat_id">) {
|
|
88
|
-
return this.api.call<t.Message>("sendChecklist", { chat_id: this.chat.id, ...params });
|
|
89
|
-
}
|
|
90
86
|
/** Use this method to send an animated emoji that will display a random value. On success, the sent [Message](https://core.telegram.org/bots/api/#message) is returned. */
|
|
91
87
|
sendDice(params: Omit<t.SendDiceParams, "chat_id">) {
|
|
92
88
|
return this.api.call<t.Message>("sendDice", { chat_id: this.chat.id, ...params });
|
|
@@ -187,26 +183,6 @@ export class RemovedChatBoostContext {
|
|
|
187
183
|
createForumTopic(params: Omit<t.CreateForumTopicParams, "chat_id">) {
|
|
188
184
|
return this.api.call<t.ForumTopic>("createForumTopic", { chat_id: this.chat.id, ...params });
|
|
189
185
|
}
|
|
190
|
-
/** Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a 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. */
|
|
191
|
-
editForumTopic(params: Omit<t.EditForumTopicParams, "chat_id">) {
|
|
192
|
-
return this.api.call<boolean>("editForumTopic", { chat_id: this.chat.id, ...params });
|
|
193
|
-
}
|
|
194
|
-
/** 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. */
|
|
195
|
-
closeForumTopic(params: Omit<t.CloseForumTopicParams, "chat_id">) {
|
|
196
|
-
return this.api.call<boolean>("closeForumTopic", { chat_id: this.chat.id, ...params });
|
|
197
|
-
}
|
|
198
|
-
/** Use this method to reopen a closed 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. */
|
|
199
|
-
reopenForumTopic(params: Omit<t.ReopenForumTopicParams, "chat_id">) {
|
|
200
|
-
return this.api.call<boolean>("reopenForumTopic", { chat_id: this.chat.id, ...params });
|
|
201
|
-
}
|
|
202
|
-
/** Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_delete\_messages* administrator rights. Returns *True* on success. */
|
|
203
|
-
deleteForumTopic(params: Omit<t.DeleteForumTopicParams, "chat_id">) {
|
|
204
|
-
return this.api.call<boolean>("deleteForumTopic", { chat_id: this.chat.id, ...params });
|
|
205
|
-
}
|
|
206
|
-
/** Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the *can\_pin\_messages* administrator right in the supergroup. Returns *True* on success. */
|
|
207
|
-
unpinAllForumTopicMessages(params: Omit<t.UnpinAllForumTopicMessagesParams, "chat_id">) {
|
|
208
|
-
return this.api.call<boolean>("unpinAllForumTopicMessages", { chat_id: this.chat.id, ...params });
|
|
209
|
-
}
|
|
210
186
|
/** 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. */
|
|
211
187
|
editGeneralForumTopic(params: Omit<t.EditGeneralForumTopicParams, "chat_id">) {
|
|
212
188
|
return this.api.call<boolean>("editGeneralForumTopic", { chat_id: this.chat.id, ...params });
|
package/src/index.test.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import {
|
|
4
|
+
BusinessConnectionContext,
|
|
5
|
+
BusinessMessageContext,
|
|
4
6
|
CallbackQueryContext,
|
|
5
7
|
ChannelPostContext,
|
|
6
8
|
contextFor,
|
|
9
|
+
GuestMessageContext,
|
|
7
10
|
MessageContext,
|
|
8
11
|
ShippingQueryContext,
|
|
9
12
|
} from "./index.js";
|
|
@@ -226,6 +229,230 @@ test("shipping query answer takes a positional ok", () => {
|
|
|
226
229
|
});
|
|
227
230
|
});
|
|
228
231
|
|
|
232
|
+
test("guest message answer fills guest_query_id and accepts a bare result", () => {
|
|
233
|
+
const { api, calls } = recorder();
|
|
234
|
+
const ctx = new GuestMessageContext(api, {
|
|
235
|
+
update_id: 1,
|
|
236
|
+
guest_message: {
|
|
237
|
+
message_id: 5,
|
|
238
|
+
date: 0,
|
|
239
|
+
chat: { id: 42, type: "private" },
|
|
240
|
+
guest_query_id: "gq1",
|
|
241
|
+
},
|
|
242
|
+
} as never);
|
|
243
|
+
assert.equal(ctx.guest_query_id, "gq1");
|
|
244
|
+
|
|
245
|
+
ctx.answer({
|
|
246
|
+
type: "article",
|
|
247
|
+
id: "1",
|
|
248
|
+
title: "hi",
|
|
249
|
+
input_message_content: { message_text: "hi" },
|
|
250
|
+
});
|
|
251
|
+
assert.deepEqual(calls[0], {
|
|
252
|
+
m: "answerGuestQuery",
|
|
253
|
+
p: {
|
|
254
|
+
guest_query_id: "gq1",
|
|
255
|
+
result: {
|
|
256
|
+
type: "article",
|
|
257
|
+
id: "1",
|
|
258
|
+
title: "hi",
|
|
259
|
+
input_message_content: { message_text: "hi" },
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("business message: send/reply/edit thread business_connection_id", () => {
|
|
266
|
+
const { api, calls } = recorder();
|
|
267
|
+
const ctx = new BusinessMessageContext(api, {
|
|
268
|
+
update_id: 1,
|
|
269
|
+
business_message: {
|
|
270
|
+
message_id: 5,
|
|
271
|
+
date: 0,
|
|
272
|
+
chat: { id: 42, type: "private" },
|
|
273
|
+
business_connection_id: "bc1",
|
|
274
|
+
},
|
|
275
|
+
} as never);
|
|
276
|
+
assert.equal(ctx.businessConnectionId, "bc1");
|
|
277
|
+
|
|
278
|
+
ctx.reply("yo"); // sugar path
|
|
279
|
+
assert.deepEqual(calls[0], {
|
|
280
|
+
m: "sendMessage",
|
|
281
|
+
p: {
|
|
282
|
+
chat_id: 42,
|
|
283
|
+
reply_parameters: { message_id: 5 },
|
|
284
|
+
business_connection_id: "bc1",
|
|
285
|
+
text: "yo",
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
calls.length = 0;
|
|
290
|
+
ctx.editText("edited"); // sugar path
|
|
291
|
+
assert.deepEqual(calls[0], {
|
|
292
|
+
m: "editMessageText",
|
|
293
|
+
p: { chat_id: 42, message_id: 5, business_connection_id: "bc1", text: "edited" },
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
calls.length = 0;
|
|
297
|
+
ctx.delete(); // deleteMessage can't touch business chats → routed via deleteBusinessMessages
|
|
298
|
+
assert.deepEqual(calls[0], {
|
|
299
|
+
m: "deleteBusinessMessages",
|
|
300
|
+
p: { business_connection_id: "bc1", message_ids: [5] },
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
calls.length = 0;
|
|
304
|
+
ctx.readBusinessMessage(); // generated path, all three ids filled
|
|
305
|
+
assert.deepEqual(calls[0], {
|
|
306
|
+
m: "readBusinessMessage",
|
|
307
|
+
p: { business_connection_id: "bc1", chat_id: 42, message_id: 5 },
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("business connection context gets account-level shortcuts", () => {
|
|
312
|
+
const { api, calls } = recorder();
|
|
313
|
+
const ctx = new BusinessConnectionContext(api, {
|
|
314
|
+
update_id: 1,
|
|
315
|
+
business_connection: {
|
|
316
|
+
id: "bc1",
|
|
317
|
+
user: { id: 7, is_bot: false, first_name: "u" },
|
|
318
|
+
user_chat_id: 7,
|
|
319
|
+
date: 0,
|
|
320
|
+
is_enabled: true,
|
|
321
|
+
},
|
|
322
|
+
} as never);
|
|
323
|
+
|
|
324
|
+
ctx.setBusinessAccountName({ first_name: "Shop" });
|
|
325
|
+
assert.deepEqual(calls[0], {
|
|
326
|
+
m: "setBusinessAccountName",
|
|
327
|
+
p: { business_connection_id: "bc1", first_name: "Shop" },
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
calls.length = 0;
|
|
331
|
+
ctx.getBusinessConnection();
|
|
332
|
+
assert.deepEqual(calls[0], {
|
|
333
|
+
m: "getBusinessConnection",
|
|
334
|
+
p: { business_connection_id: "bc1" },
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
test("callback query on a business message threads business_connection_id", () => {
|
|
339
|
+
const { api, calls } = recorder();
|
|
340
|
+
const ctx = new CallbackQueryContext(api, {
|
|
341
|
+
update_id: 1,
|
|
342
|
+
callback_query: {
|
|
343
|
+
id: "q1",
|
|
344
|
+
from: { id: 7, is_bot: false, first_name: "u" },
|
|
345
|
+
message: {
|
|
346
|
+
message_id: 5,
|
|
347
|
+
date: 0,
|
|
348
|
+
chat: { id: 42, type: "private" },
|
|
349
|
+
business_connection_id: "bc1",
|
|
350
|
+
},
|
|
351
|
+
data: "x",
|
|
352
|
+
},
|
|
353
|
+
} as never);
|
|
354
|
+
|
|
355
|
+
ctx.editText("edited");
|
|
356
|
+
assert.deepEqual(calls[0], {
|
|
357
|
+
m: "editMessageText",
|
|
358
|
+
p: { business_connection_id: "bc1", chat_id: 42, message_id: 5, text: "edited" },
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("message in a forum topic: send/reply stay in it, editText/react don't carry it", () => {
|
|
363
|
+
const { api, calls } = recorder();
|
|
364
|
+
const ctx = new MessageContext(api, {
|
|
365
|
+
update_id: 1,
|
|
366
|
+
message: {
|
|
367
|
+
message_id: 5,
|
|
368
|
+
date: 0,
|
|
369
|
+
chat: { id: 42, type: "supergroup" },
|
|
370
|
+
is_topic_message: true,
|
|
371
|
+
message_thread_id: 9,
|
|
372
|
+
},
|
|
373
|
+
} as never);
|
|
374
|
+
assert.equal(ctx.messageThreadId, 9);
|
|
375
|
+
|
|
376
|
+
ctx.reply("yo"); // sugar path
|
|
377
|
+
assert.deepEqual(calls[0], {
|
|
378
|
+
m: "sendMessage",
|
|
379
|
+
p: { chat_id: 42, reply_parameters: { message_id: 5 }, message_thread_id: 9, text: "yo" },
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
calls.length = 0;
|
|
383
|
+
ctx.send("hi"); // sugar path
|
|
384
|
+
assert.deepEqual(calls[0], {
|
|
385
|
+
m: "sendMessage",
|
|
386
|
+
p: { chat_id: 42, message_thread_id: 9, text: "hi" },
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// editMessageText/setMessageReaction don't accept message_thread_id — must stay clean.
|
|
390
|
+
calls.length = 0;
|
|
391
|
+
ctx.editText("edited");
|
|
392
|
+
assert.deepEqual(calls[0], {
|
|
393
|
+
m: "editMessageText",
|
|
394
|
+
p: { chat_id: 42, message_id: 5, text: "edited" },
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
calls.length = 0;
|
|
398
|
+
ctx.react("🔥");
|
|
399
|
+
assert.deepEqual(calls[0], {
|
|
400
|
+
m: "setMessageReaction",
|
|
401
|
+
p: { chat_id: 42, message_id: 5, reaction: [{ type: "emoji", emoji: "🔥" }] },
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
// closeForumTopic targets the topic this message is in — generated (non-sugar) path.
|
|
405
|
+
calls.length = 0;
|
|
406
|
+
ctx.closeForumTopic();
|
|
407
|
+
assert.deepEqual(calls[0], {
|
|
408
|
+
m: "closeForumTopic",
|
|
409
|
+
p: { chat_id: 42, message_thread_id: 9 },
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test("message in a channel direct-messages topic: send/reply fill direct_messages_topic_id", () => {
|
|
414
|
+
const { api, calls } = recorder();
|
|
415
|
+
const ctx = new MessageContext(api, {
|
|
416
|
+
update_id: 1,
|
|
417
|
+
message: {
|
|
418
|
+
message_id: 5,
|
|
419
|
+
date: 0,
|
|
420
|
+
chat: { id: 42, type: "private" },
|
|
421
|
+
direct_messages_topic: { topic_id: 3, user: { id: 7, is_bot: false, first_name: "u" } },
|
|
422
|
+
},
|
|
423
|
+
} as never);
|
|
424
|
+
|
|
425
|
+
ctx.send("hi");
|
|
426
|
+
assert.deepEqual(calls[0], {
|
|
427
|
+
m: "sendMessage",
|
|
428
|
+
p: { chat_id: 42, direct_messages_topic_id: 3, text: "hi" },
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test("callback query on a forum-topic message threads message_thread_id into send", () => {
|
|
433
|
+
const { api, calls } = recorder();
|
|
434
|
+
const ctx = new CallbackQueryContext(api, {
|
|
435
|
+
update_id: 1,
|
|
436
|
+
callback_query: {
|
|
437
|
+
id: "q1",
|
|
438
|
+
from: { id: 7, is_bot: false, first_name: "u" },
|
|
439
|
+
message: {
|
|
440
|
+
message_id: 5,
|
|
441
|
+
date: 0,
|
|
442
|
+
chat: { id: 42, type: "supergroup" },
|
|
443
|
+
message_thread_id: 9,
|
|
444
|
+
},
|
|
445
|
+
data: "x",
|
|
446
|
+
},
|
|
447
|
+
} as never);
|
|
448
|
+
|
|
449
|
+
ctx.send({ text: "hi" });
|
|
450
|
+
assert.deepEqual(calls[0], {
|
|
451
|
+
m: "sendMessage",
|
|
452
|
+
p: { chat_id: 42, message_thread_id: 9, text: "hi" },
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
|
|
229
456
|
test("contextFor builds the right class per update type", () => {
|
|
230
457
|
const { api } = recorder();
|
|
231
458
|
const m = contextFor("message", api, {
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { BusinessMessageContextBase } from "../generated/business-message.js";
|
|
2
2
|
import { MessageSugar } from "./message-mixin.js";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* BusinessMessageContext = generated base + the shared Message sugar.
|
|
6
|
+
* `delete` is overridden because plain deleteMessage does not work in business
|
|
7
|
+
* chats — Telegram only deletes there via deleteBusinessMessages.
|
|
8
|
+
*/
|
|
9
|
+
export class BusinessMessageContext extends MessageSugar(BusinessMessageContextBase) {
|
|
10
|
+
/** delete this message (routed via deleteBusinessMessages; needs the can_delete_* right). */
|
|
11
|
+
override delete(): Promise<boolean> {
|
|
12
|
+
return this.api.call<boolean>("deleteBusinessMessages", {
|
|
13
|
+
business_connection_id: this.business_connection_id,
|
|
14
|
+
message_ids: [this.message_id],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { EditedBusinessMessageContextBase } from "../generated/edited-business-message.js";
|
|
2
2
|
import { MessageSugar } from "./message-mixin.js";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* EditedBusinessMessageContext = generated base + the shared Message sugar.
|
|
6
|
+
* `delete` is overridden because plain deleteMessage does not work in business
|
|
7
|
+
* chats — Telegram only deletes there via deleteBusinessMessages.
|
|
8
|
+
*/
|
|
9
|
+
export class EditedBusinessMessageContext extends MessageSugar(EditedBusinessMessageContextBase) {
|
|
10
|
+
/** delete this message (routed via deleteBusinessMessages; needs the can_delete_* right). */
|
|
11
|
+
override delete(): Promise<boolean> {
|
|
12
|
+
return this.api.call<boolean>("deleteBusinessMessages", {
|
|
13
|
+
business_connection_id: this.business_connection_id,
|
|
14
|
+
message_ids: [this.message_id],
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as t from "@yaebal/types";
|
|
2
|
+
import { GuestMessageContextBase } from "../generated/guest-message.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* GuestMessageContext = generated base + hand-written ergonomic overloads.
|
|
6
|
+
* positional sugar for `answer` — pass the result directly. publishes it as a
|
|
7
|
+
* real message in the chat where the guest bot was summoned (unlike inline
|
|
8
|
+
* mode, there's no popup — this is the only way to respond).
|
|
9
|
+
*/
|
|
10
|
+
export class GuestMessageContext extends GuestMessageContextBase {
|
|
11
|
+
override answer(result: t.InlineQueryResult): Promise<t.SentGuestMessage>;
|
|
12
|
+
override answer(
|
|
13
|
+
params: Omit<t.AnswerGuestQueryParams, "guest_query_id">,
|
|
14
|
+
): Promise<t.SentGuestMessage>;
|
|
15
|
+
override answer(
|
|
16
|
+
a: t.InlineQueryResult | Omit<t.AnswerGuestQueryParams, "guest_query_id">,
|
|
17
|
+
): Promise<t.SentGuestMessage> {
|
|
18
|
+
return super.answer("type" in a ? { result: a } : a);
|
|
19
|
+
}
|
|
20
|
+
}
|