UNPKG

4.93 kBTypeScriptView Raw
1import type { CallbackQuery, CommonMessageBundle, Message, Update } from '@telegraf/types';
2import type { Deunionize, UnionKeys } from './deunionize';
3import { Guarded } from './core/helpers/util';
4type DistinctKeys<T extends object> = Exclude<UnionKeys<T>, keyof T>;
5type Keyed<T extends object, K extends DistinctKeys<T>> = Record<K, {}> & Deunionize<Record<K, {}>, T>;
6export type Filter<U extends Update> = (update: Update) => update is U;
7export { Guarded };
8export type AllGuarded<Fs extends Filter<Update>[]> = Fs extends [
9 infer A,
10 ...infer B
11] ? B extends [] ? Guarded<A> : B extends Filter<Update>[] ? Guarded<A> & AllGuarded<B> : never : never;
12export declare const message: <Ks extends ("entities" | "text" | "caption" | "caption_entities" | "sticker" | "animation" | "reply_markup" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "poll" | "media_group_id" | "has_media_spoiler" | "forward_from" | "forward_from_chat" | "forward_from_message_id" | "forward_signature" | "forward_sender_name" | "forward_date" | "is_automatic_forward" | "reply_to_message" | "via_bot" | "edit_date" | "has_protected_content" | "author_signature" | "contact" | "dice" | "location" | "new_chat_members" | "left_chat_member" | "new_chat_title" | "new_chat_photo" | "delete_chat_photo" | "group_chat_created" | "supergroup_chat_created" | "channel_chat_created" | "message_auto_delete_timer_changed" | "migrate_to_chat_id" | "migrate_from_chat_id" | "pinned_message" | "invoice" | "successful_payment" | "user_shared" | "chat_shared" | "connected_website" | "write_access_allowed" | "passport_data" | "proximity_alert_triggered" | "forum_topic_created" | "forum_topic_edited" | "forum_topic_closed" | "forum_topic_reopened" | "general_forum_topic_hidden" | "general_forum_topic_unhidden" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "game" | "story" | "venue")[]>(...keys: Ks) => (update: Update) => update is Update.MessageUpdate<Keyed<Message, Ks[number]>>;
13export declare const editedMessage: <Ks extends ("entities" | "text" | "caption" | "caption_entities" | "sticker" | "animation" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "poll" | "media_group_id" | "has_media_spoiler" | "contact" | "dice" | "location" | "game" | "story" | "venue")[]>(...keys: Ks) => (update: Update) => update is Update.EditedMessageUpdate<Keyed<CommonMessageBundle, Ks[number]>>;
14export declare const channelPost: <Ks extends ("entities" | "text" | "caption" | "caption_entities" | "sticker" | "animation" | "reply_markup" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "poll" | "media_group_id" | "has_media_spoiler" | "forward_from" | "forward_from_chat" | "forward_from_message_id" | "forward_signature" | "forward_sender_name" | "forward_date" | "is_automatic_forward" | "reply_to_message" | "via_bot" | "edit_date" | "has_protected_content" | "author_signature" | "contact" | "dice" | "location" | "new_chat_members" | "left_chat_member" | "new_chat_title" | "new_chat_photo" | "delete_chat_photo" | "group_chat_created" | "supergroup_chat_created" | "channel_chat_created" | "message_auto_delete_timer_changed" | "migrate_to_chat_id" | "migrate_from_chat_id" | "pinned_message" | "invoice" | "successful_payment" | "user_shared" | "chat_shared" | "connected_website" | "write_access_allowed" | "passport_data" | "proximity_alert_triggered" | "forum_topic_created" | "forum_topic_edited" | "forum_topic_closed" | "forum_topic_reopened" | "general_forum_topic_hidden" | "general_forum_topic_unhidden" | "video_chat_scheduled" | "video_chat_started" | "video_chat_ended" | "video_chat_participants_invited" | "web_app_data" | "game" | "story" | "venue")[]>(...keys: Ks) => (update: Update) => update is Update.ChannelPostUpdate<Keyed<Message, Ks[number]>>;
15export declare const editedChannelPost: <Ks extends ("entities" | "text" | "caption" | "caption_entities" | "sticker" | "animation" | "audio" | "document" | "photo" | "video" | "video_note" | "voice" | "poll" | "media_group_id" | "has_media_spoiler" | "contact" | "dice" | "location" | "game" | "story" | "venue")[]>(...keys: Ks) => (update: Update) => update is Update.EditedChannelPostUpdate<Keyed<CommonMessageBundle, Ks[number]>>;
16export declare const callbackQuery: <Ks extends ("game_short_name" | "data")[]>(...keys: Ks) => (update: Update) => update is Update.CallbackQueryUpdate<Keyed<CallbackQuery, Ks[number]>>;
17/** Any of the provided filters must match */
18export declare const anyOf: <Us extends Update[]>(...filters: { [UIdx in keyof Us]: Filter<Us[UIdx]>; }) => (update: Update) => update is Us[number];
19/** All of the provided filters must match */
20export declare const allOf: <U extends Update, Fs extends Filter<U>[]>(...filters: Fs) => (update: Update) => update is AllGuarded<Fs>;
21//# sourceMappingURL=filters.d.ts.map
\No newline at end of file