UNPKG

4.63 kBTypeScriptView Raw
1/** @format */
2import { Message, Opts, Telegram, Update } from './core/types/typegram';
3import { UnionKeys } from './deunionize';
4export { Markup } from './markup';
5export declare type ChatAction = Opts<'sendChatAction'>['action'];
6/**
7 * Create an `Extra*` type from the arguments of a given method `M extends keyof Telegram` but `Omit`ting fields with key `K` from it.
8 *
9 * Note that `chat_id` may not be specified in `K` because it is `Omit`ted by default.
10 */
11declare type MakeExtra<M extends keyof Telegram, K extends keyof Omit<Opts<M>, 'chat_id'> = never> = Omit<Opts<M>, 'chat_id' | K>;
12export declare type ExtraAddStickerToSet = MakeExtra<'addStickerToSet', 'name' | 'user_id'>;
13export declare type ExtraAnimation = MakeExtra<'sendAnimation', 'animation'>;
14export declare type ExtraAnswerCbQuery = MakeExtra<'answerCallbackQuery', 'text' | 'callback_query_id'>;
15export declare type ExtraAnswerInlineQuery = MakeExtra<'answerInlineQuery', 'inline_query_id' | 'results'>;
16export declare type ExtraAudio = MakeExtra<'sendAudio', 'audio'>;
17export declare type ExtraContact = MakeExtra<'sendContact', 'phone_number' | 'first_name'>;
18export declare type ExtraCopyMessage = MakeExtra<'copyMessage', 'from_chat_id' | 'message_id'>;
19export declare type ExtraCreateChatInviteLink = MakeExtra<'createChatInviteLink'>;
20export declare type ExtraCreateNewStickerSet = MakeExtra<'createNewStickerSet', 'name' | 'title' | 'user_id'>;
21export declare type ExtraDice = MakeExtra<'sendDice'>;
22export declare type ExtraDocument = MakeExtra<'sendDocument', 'document'>;
23export declare type ExtraEditChatInviteLink = MakeExtra<'editChatInviteLink', 'invite_link'>;
24export declare type ExtraEditMessageCaption = MakeExtra<'editMessageCaption', 'message_id' | 'inline_message_id' | 'caption'>;
25export declare type ExtraEditMessageLiveLocation = MakeExtra<'editMessageLiveLocation', 'message_id' | 'inline_message_id' | 'latitude' | 'longitude'>;
26export declare type ExtraEditMessageMedia = MakeExtra<'editMessageMedia', 'message_id' | 'inline_message_id' | 'media'>;
27export declare type ExtraEditMessageText = MakeExtra<'editMessageText', 'message_id' | 'inline_message_id' | 'text'>;
28export declare type ExtraGame = MakeExtra<'sendGame', 'game_short_name'>;
29export declare type NewInvoiceParameters = MakeExtra<'sendInvoice', 'disable_notification' | 'reply_to_message_id' | 'allow_sending_without_reply' | 'reply_markup'>;
30export declare type ExtraInvoice = MakeExtra<'sendInvoice', keyof NewInvoiceParameters>;
31export declare type ExtraKickChatMember = MakeExtra<'kickChatMember', 'user_id' | 'until_date'>;
32export declare type ExtraLocation = MakeExtra<'sendLocation', 'latitude' | 'longitude'>;
33export declare type ExtraMediaGroup = MakeExtra<'sendMediaGroup', 'media'>;
34export declare type ExtraPhoto = MakeExtra<'sendPhoto', 'photo'>;
35export declare type ExtraPoll = MakeExtra<'sendPoll', 'question' | 'options' | 'type'>;
36export declare type ExtraPromoteChatMember = MakeExtra<'promoteChatMember', 'user_id'>;
37export declare type ExtraReplyMessage = MakeExtra<'sendMessage', 'text'>;
38export declare type ExtraRestrictChatMember = MakeExtra<'restrictChatMember', 'user_id'>;
39export declare type ExtraSetMyCommands = MakeExtra<'setMyCommands', 'commands'>;
40export declare type ExtraSetWebhook = MakeExtra<'setWebhook', 'url'>;
41export declare type ExtraSticker = MakeExtra<'sendSticker', 'sticker'>;
42export declare type ExtraStopPoll = MakeExtra<'stopPoll', 'message_id'>;
43export declare type ExtraVenue = MakeExtra<'sendVenue', 'latitude' | 'longitude' | 'title' | 'address'>;
44export declare type ExtraVideo = MakeExtra<'sendVideo', 'video'>;
45export declare type ExtraVideoNote = MakeExtra<'sendVideoNote', 'video_note'>;
46export declare type ExtraVoice = MakeExtra<'sendVoice', 'voice'>;
47/** Possible update types */
48export declare type UpdateType = Exclude<UnionKeys<Update>, keyof Update>;
49/** Possible message subtypes. Same as the properties on a message object */
50export declare type MessageSubType = 'forward_date' | Exclude<UnionKeys<Message>, keyof Message.CaptionableMessage | 'entities' | 'media_group_id'>;
51declare type ExtractPartial<T extends object, U extends object> = T extends unknown ? Required<T> extends U ? T : never : never;
52/**
53 * Maps [[`Composer.on`]]'s `updateType` or `messageSubType` to a `tt.Update` subtype.
54 */
55export declare type MountMap = {
56 [T in UpdateType]: Extract<Update, Record<T, object>>;
57} & {
58 [T in MessageSubType]: {
59 message: ExtractPartial<Update.MessageUpdate['message'], Record<T, unknown>>;
60 update_id: number;
61 };
62};
63//# sourceMappingURL=telegram-types.d.ts.map
\No newline at end of file