Class MessageContext

Hierarchy

Constructors

Properties

_client: Evogram
_source: IMessage
chat: ChatContext = ...
client: Evogram = ...
date: Date = ...
editDate: undefined | 0 | Date = ...
entities: undefined | IMessageEntity | IMessageEntity[] = ...
forumTopic: undefined | ForumTopicContext = ...
forwardMessage: undefined | 0 | ForwardMessageContext = ...
isAnswer: undefined | boolean = ...
location: undefined | LocationContext = ...
media: {
    animation: undefined | IAnimation;
    audio: undefined | IAudio;
    has_media_spoiler: undefined | true;
    media_group_id: undefined | string;
    photo: undefined | IPhotoSize[];
    sticker: undefined | ISticker;
    video: undefined | IVideo;
    video_note: undefined | IVideoNote;
    voice: undefined | IVoice;
} = ...

Type declaration

  • animation: undefined | IAnimation
  • audio: undefined | IAudio
  • has_media_spoiler: undefined | true
  • media_group_id: undefined | string
  • photo: undefined | IPhotoSize[]
  • sticker: undefined | ISticker
  • video: undefined | IVideo
  • video_note: undefined | IVideoNote
  • voice: undefined | IVoice
poll: undefined | PollContext = ...
replyMessage: undefined | MessageContext = ...
senderChat: undefined | ChatContext = ...
source: IMessage = ...
update: {
    channel_chat_created: undefined | true;
    connected_website: undefined | string;
    delete_chat_photo: undefined | true;
    group_chat_created: undefined | true;
    left_chat_member: undefined | UserContext;
    message_auto_delete_timer_changed: undefined | IMessageAutoDeleteTimerChanged;
    migrate_from_chat_id: undefined | number;
    migrate_to_chat_id: undefined | number;
    new_chat_members: undefined | UserContext[];
    new_chat_photo: undefined | IPhotoSize[];
    new_chat_title: undefined | string;
    pinned_message: undefined | IMessage;
    successful_payment: undefined | ISuccessfulPayment;
    supergroup_chat_created: undefined | true;
    video_chat_ended: undefined | IVideoChatEnded;
    video_chat_participants_invited: undefined | IVideoChatParticipantsInvited;
    video_chat_scheduled: undefined | IVideoChatScheduled;
    video_chat_started: undefined | IVideoChatStarted;
    web_app_data: undefined | IWebAppData;
    write_access_allowed: undefined | IWriteAccessAllowed;
} = ...

Type declaration

user: undefined | UserContext = ...
venue: undefined | VenueContext = ...
viaBot: undefined | UserContext = ...

Accessors

  • get hasCommand(): undefined | string
  • Checks whether the incoming message to the bot has a recognized command.

    Returns undefined | string

    Returns the matched command from the message, or undefined if no match was found.

Methods

  • Asks a question to the user and waits for a response.

    Throws

    • If there is no user id in the source object.

    Type Parameters

    Parameters

    • text: string

      The text of the message to be sent, or an object containing the text and other options.

    • callback: ((message) => any)

      The function to run once the user responds to the question.

    Returns Promise<T>

    • A promise that resolves with the context of the user's response.
  • Type Parameters

    Parameters

    Returns Promise<T>

  • Converts the source object to a context object of a given type.

    Example

    client.updates.on("message", message => {
    const user = message.user.toContext<CustomUserContext>();
    // Now user works correctly with your context
    })

    Type Parameters

    • TContext extends object

      Generic type parameter for the context object.

    Returns TContext

    The context object.

Generated using TypeDoc