UNPKG

vk-io

Version:

Modern VK API SDK for Node.js

64 lines (63 loc) 2.11 kB
import { Context, ContextFactoryOptions, ContextDefaultState } from './context'; import { IMessageContextSendOptions, MessageContext } from './message'; import { kSerializeData } from '../../utils/constants'; export interface IMessageEventShowSnackbar { type: 'show_snackbar'; text: string; } export interface IMessageEventOpenLink { type: 'open_link'; link: string; } export interface IMessageEventOpenApp { type: 'open_app'; app_id: number; owner_id?: number; hash: string; } export type MessageEventAction = IMessageEventShowSnackbar | IMessageEventOpenLink | IMessageEventOpenApp; export type MessageEventContextType = 'message_event'; export type MessageEventContextSubType = 'message_event'; export interface IMessageEventContextPayload { user_id: number; conversation_message_id: number; peer_id: number; event_id: string; payload: any; } export type MessageEventContextOptions<S> = ContextFactoryOptions<IMessageEventContextPayload, S>; export declare class MessageEventContext<S = ContextDefaultState> extends Context<IMessageEventContextPayload, S, MessageEventContextType, MessageEventContextSubType> { constructor(options: MessageEventContextOptions<S>); /** * Returns the identifier user */ get userId(): number; /** * Returns the conversation message id */ get conversationMessageId(): number; /** * Returns the destination identifier */ get peerId(): number; /** * Returns a random string. Active for a minute, after a minute becomes invalid */ get eventId(): string; /** * Returns the event payload */ get eventPayload(): any; /** * Dispatches an event with an action that will occur when the callback button is pressed */ answer(eventData: MessageEventAction): Promise<1>; /** * Sends a message to the current dialog */ send(text: string | IMessageContextSendOptions, params?: IMessageContextSendOptions): Promise<MessageContext<S>>; /** * Returns the custom data */ [kSerializeData](): object; }