/** * Helper functions for processing Telegram updates * * @module helpers/update-helpers */ import type { Message } from '../api/types/index.js'; /** * Telegram update types */ export declare const UpdateType: { readonly MESSAGE: "message"; readonly EDITED_MESSAGE: "edited_message"; readonly CHANNEL_POST: "channel_post"; readonly EDITED_CHANNEL_POST: "edited_channel_post"; readonly BUSINESS_CONNECTION: "business_connection"; readonly BUSINESS_MESSAGE: "business_message"; readonly EDITED_BUSINESS_MESSAGE: "edited_business_message"; readonly DELETED_BUSINESS_MESSAGES: "deleted_business_messages"; readonly MESSAGE_REACTION: "message_reaction"; readonly MESSAGE_REACTION_COUNT: "message_reaction_count"; readonly INLINE_QUERY: "inline_query"; readonly CHOSEN_INLINE_RESULT: "chosen_inline_result"; readonly CALLBACK_QUERY: "callback_query"; readonly SHIPPING_QUERY: "shipping_query"; readonly PRE_CHECKOUT_QUERY: "pre_checkout_query"; readonly POLL: "poll"; readonly POLL_ANSWER: "poll_answer"; readonly MY_CHAT_MEMBER: "my_chat_member"; readonly CHAT_MEMBER: "chat_member"; readonly CHAT_JOIN_REQUEST: "chat_join_request"; readonly CHAT_BOOST: "chat_boost"; readonly REMOVED_CHAT_BOOST: "removed_chat_boost"; readonly UNKNOWN: "unknown"; }; export type UpdateType = typeof UpdateType[keyof typeof UpdateType]; /** * Telegram message types */ export declare const MessageType: { readonly COMMAND: "command"; readonly TEXT: "message.text"; readonly AUDIO: "message.audio"; readonly ANIMATION: "message.animation"; readonly VIDEO: "message.video"; readonly PHOTO: "message.photo"; readonly DOCUMENT: "message.document"; readonly CONTACT: "message.contact"; readonly LOCATION: "message.location"; readonly POLL: "message.poll"; readonly NEW_CHAT_MEMBERS: "message.new_chat_members"; readonly LEFT_CHAT_MEMBER: "message.left_chat_member"; readonly STICKER: "message.sticker"; readonly VIDEO_NOTE: "message.video_note"; readonly VOICE: "message.voice"; readonly DICE: "message.dice"; readonly GAME: "message.game"; readonly VENUE: "message.venue"; readonly INVOICE: "message.invoice"; readonly PINNED_MESSAGE: "message.pinned_message"; readonly USERS_SHARED: "message.users_shared"; readonly CHAT_SHARED: "message.chat_shared"; readonly WEB_APP_DATA: "message.web_app_data"; readonly CONNECTED_WEBSITE: "message.connected_website"; readonly SUCCESSFUL_PAYMENT: "message.successful_payment"; readonly REFUNDED_PAYMENT: "message.refunded_payment"; readonly MIGRATE_TO_CHAT_ID: "message.migrate_to_chat_id"; readonly MIGRATE_FROM_CHAT_ID: "message.migrate_from_chat_id"; readonly PASSPORT_DATA: "message.passport_data"; readonly NEW_CHAT_TITLE: "message.new_chat_title"; readonly NEW_CHAT_PHOTO: "message.new_chat_photo"; readonly DELETE_CHAT_PHOTO: "message.delete_chat_photo"; readonly GROUP_CHAT_CREATED: "message.group_chat_created"; readonly SUPERGROUP_CHAT_CREATED: "message.supergroup_chat_created"; readonly CHANNEL_CHAT_CREATED: "message.channel_chat_created"; readonly MESSAGE_AUTO_DELETE_TIMER_CHANGED: "message.message_auto_delete_timer_changed"; readonly PROXIMITY_ALERT_TRIGGERED: "message.proximity_alert_triggered"; readonly VIDEO_CHAT_SCHEDULED: "message.video_chat_scheduled"; readonly VIDEO_CHAT_STARTED: "message.video_chat_started"; readonly VIDEO_CHAT_PARTICIPANTS_INVITED: "message.video_chat_participants_invited"; readonly VIDEO_CHAT_ENDED: "message.video_chat_ended"; readonly FORUM_TOPIC_CREATED: "message.forum_topic_created"; readonly FORUM_TOPIC_EDITED: "message.forum_topic_edited"; readonly FORUM_TOPIC_CLOSED: "message.forum_topic_closed"; readonly FORUM_TOPIC_REOPENED: "message.forum_topic_reopened"; readonly GENERAL_FORUM_TOPIC_HIDDEN: "message.general_forum_topic_hidden"; readonly GENERAL_FORUM_TOPIC_UNHIDDEN: "message.general_forum_topic_unhidden"; readonly GIVEAWAY_CREATED: "message.giveaway_created"; readonly GIVEAWAY: "message.giveaway"; readonly GIVEAWAY_WINNERS: "message.giveaway_winners"; readonly GIVEAWAY_COMPLETED: "message.giveaway_completed"; readonly WRITE_ACCESS_ALLOWED: "message.write_access_allowed"; readonly BOOST_ADDED: "message.boost_added"; readonly CHAT_BACKGROUND_SET: "message.chat_background_set"; readonly SERVICE_MESSAGE: "service_message"; }; export type MessageType = typeof MessageType[keyof typeof MessageType]; /** * Service message types */ export declare const SERVICE_MESSAGE_TYPES: MessageType[]; /** * Parsed command structure */ export interface ParsedCommand { /** Command name without slash */ command: string; /** Command parameters */ params: string; /** Bot username if command was targeted (@botname) */ botName: string; } /** * Parse command from text string * * @param text - Text to parse (e.g., "/start@mybot param1 param2") * @returns Parsed command structure or undefined if text is not a command * * @example * ```typescript * const result = parseCommand('/start param1 param2'); * // { command: 'start', params: 'param1 param2', botName: '' } * * const result2 = parseCommand('/start@mybot'); * // { command: 'start', params: '', botName: 'mybot' } * ``` */ export declare function parseCommand(text: string): ParsedCommand | undefined; /** * Determine message type from message object * * @param message - Telegram Message object * @returns Message type constant * * @example * ```typescript * const type = getMessageType(message); * if (type === MessageType.PHOTO) { * console.log('This is a photo message'); * } * ``` */ export declare function getMessageType(message: Message): MessageType; /** * Extract file_id from message object containing media * * @param message - Message object that may contain media * @returns File ID string or undefined if no media found * * @example * ```typescript * const fileId = getFileId(message); * if (fileId) { * const file = await api.getFile({ file_id: fileId }); * } * ``` */ export declare function getFileId(message: Message): string | undefined; /** * Check if message type is a service message * * @param messageType - Message type to check * @returns True if message type is a service message */ export declare function isServiceMessage(messageType: MessageType): boolean;