1 |
|
2 | import { Expand } from './core/helpers/util';
|
3 | import { Message, Opts, Telegram, Update, InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo } from './core/types/typegram';
|
4 | import { UnionKeys } from './deunionize';
|
5 | import { FmtString } from './format';
|
6 | export { Markup } from './markup';
|
7 | export type ChatAction = Opts<'sendChatAction'>['action'];
|
8 | export type WrapCaption<T> = T extends {
|
9 | caption?: string;
|
10 | } ? Expand<Omit<T, 'caption'> & {
|
11 | caption?: string | FmtString;
|
12 | }> : T;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | type MakeExtra<M extends keyof Telegram, K extends keyof Omit<Opts<M>, 'chat_id'> = never> = WrapCaption<Omit<Opts<M>, 'chat_id' | K>>;
|
19 | export type ExtraAddStickerToSet = MakeExtra<'addStickerToSet', 'name' | 'user_id'>;
|
20 | export type ExtraAnimation = MakeExtra<'sendAnimation', 'animation'>;
|
21 | export type ExtraAnswerCbQuery = MakeExtra<'answerCallbackQuery', 'text' | 'callback_query_id'>;
|
22 | export type ExtraAnswerInlineQuery = MakeExtra<'answerInlineQuery', 'inline_query_id' | 'results'>;
|
23 | export type ExtraSetChatPermissions = MakeExtra<'setChatPermissions', 'permissions'>;
|
24 | export type ExtraAudio = MakeExtra<'sendAudio', 'audio'>;
|
25 | export type ExtraContact = MakeExtra<'sendContact', 'phone_number' | 'first_name'>;
|
26 | export type ExtraCopyMessage = MakeExtra<'copyMessage', 'from_chat_id' | 'message_id'>;
|
27 | export type ExtraCreateChatInviteLink = MakeExtra<'createChatInviteLink'>;
|
28 | export type NewInvoiceLinkParameters = MakeExtra<'createInvoiceLink'>;
|
29 | export type ExtraCreateNewStickerSet = MakeExtra<'createNewStickerSet', 'name' | 'title' | 'user_id'>;
|
30 | export type ExtraDice = MakeExtra<'sendDice'>;
|
31 | export type ExtraDocument = MakeExtra<'sendDocument', 'document'>;
|
32 | export type ExtraEditChatInviteLink = MakeExtra<'editChatInviteLink', 'invite_link'>;
|
33 | export type ExtraEditMessageCaption = MakeExtra<'editMessageCaption', 'message_id' | 'inline_message_id' | 'caption'>;
|
34 | export type ExtraEditMessageLiveLocation = MakeExtra<'editMessageLiveLocation', 'message_id' | 'inline_message_id' | 'latitude' | 'longitude'>;
|
35 | export type ExtraEditMessageMedia = MakeExtra<'editMessageMedia', 'message_id' | 'inline_message_id' | 'media'>;
|
36 | export type ExtraEditMessageText = MakeExtra<'editMessageText', 'message_id' | 'inline_message_id' | 'text'>;
|
37 | export type ExtraGame = MakeExtra<'sendGame', 'game_short_name'>;
|
38 | export type NewInvoiceParameters = MakeExtra<'sendInvoice', 'disable_notification' | 'reply_to_message_id' | 'allow_sending_without_reply' | 'reply_markup' | 'message_thread_id'>;
|
39 | export type ExtraInvoice = MakeExtra<'sendInvoice', keyof NewInvoiceParameters>;
|
40 | export type ExtraBanChatMember = MakeExtra<'banChatMember', 'user_id' | 'until_date'>;
|
41 | export type ExtraKickChatMember = ExtraBanChatMember;
|
42 | export type ExtraLocation = MakeExtra<'sendLocation', 'latitude' | 'longitude'>;
|
43 | export type ExtraMediaGroup = MakeExtra<'sendMediaGroup', 'media'>;
|
44 | export type ExtraPhoto = MakeExtra<'sendPhoto', 'photo'>;
|
45 | export type ExtraPoll = MakeExtra<'sendPoll', 'question' | 'options' | 'type'>;
|
46 | export type ExtraPromoteChatMember = MakeExtra<'promoteChatMember', 'user_id'>;
|
47 | export type ExtraReplyMessage = MakeExtra<'sendMessage', 'text'>;
|
48 | export type ExtraForwardMessage = MakeExtra<'forwardMessage', 'from_chat_id' | 'message_id'>;
|
49 | export type ExtraSendChatAction = MakeExtra<'sendChatAction', 'action'>;
|
50 | export type ExtraRestrictChatMember = MakeExtra<'restrictChatMember', 'user_id'>;
|
51 | export type ExtraSetMyCommands = MakeExtra<'setMyCommands', 'commands'>;
|
52 | export type ExtraSetWebhook = MakeExtra<'setWebhook', 'url'>;
|
53 | export type ExtraSticker = MakeExtra<'sendSticker', 'sticker'>;
|
54 | export type ExtraStopPoll = MakeExtra<'stopPoll', 'message_id'>;
|
55 | export type ExtraVenue = MakeExtra<'sendVenue', 'latitude' | 'longitude' | 'title' | 'address'>;
|
56 | export type ExtraVideo = MakeExtra<'sendVideo', 'video'>;
|
57 | export type ExtraVideoNote = MakeExtra<'sendVideoNote', 'video_note'>;
|
58 | export type ExtraVoice = MakeExtra<'sendVoice', 'voice'>;
|
59 | export type ExtraBanChatSenderChat = MakeExtra<'banChatSenderChat', 'sender_chat_id'>;
|
60 | export type ExtraCreateForumTopic = MakeExtra<'createForumTopic', 'name'>;
|
61 | export type ExtraEditForumTopic = MakeExtra<'editForumTopic', 'message_thread_id'>;
|
62 | export type MediaGroup = readonly (InputMediaPhoto | InputMediaVideo)[] | readonly InputMediaAudio[] | readonly InputMediaDocument[];
|
63 |
|
64 | export type UpdateType = Exclude<UnionKeys<Update>, keyof Update>;
|
65 |
|
66 | export type MessageSubType = 'forward_date' | Exclude<UnionKeys<Message>, keyof Message.CaptionableMessage | 'entities' | 'media_group_id'>;
|
67 | type ExtractPartial<T extends object, U extends object> = T extends unknown ? Required<T> extends U ? T : never : never;
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | export type MountMap = {
|
73 | [T in UpdateType]: Extract<Update, Record<T, object>>;
|
74 | } & {
|
75 | [T in MessageSubType]: {
|
76 | message: ExtractPartial<Update.MessageUpdate['message'], Record<T, unknown>>;
|
77 | update_id: number;
|
78 | };
|
79 | };
|
80 |
|
\ | No newline at end of file |