UNPKG

vk-io

Version:

Modern VK API SDK for Node.js

143 lines (142 loc) 3.64 kB
import { KeyboardButton, IKeyboardTextButtonOptions, IKeyboardURLButtonOptions, IKeyboardLocationRequestButtonOptions, IKeyboardVKPayButtonOptions, IKeyboardApplicationButtonOptions, IKeyboardCallbackButtonOptions } from './types'; export declare class KeyboardBuilder { /** * Does the keyboard close after pressing the button */ isOneTime: boolean; /** * The keyboard must be attached to the message */ isInline: boolean; /** * Rows with all buttons */ protected rows: KeyboardButton[][]; /** * Current row of buttons */ protected currentRow: KeyboardButton[]; /** * Returns custom tag */ get [Symbol.toStringTag](): string; /** * Text button, can be colored * * ```ts * builder.textButton({ * label: 'Buy a coffee', * payload: { * command: 'buy', * item: 'coffee' * }, * color: Keyboard.POSITIVE_COLOR * }); * ``` */ textButton({ label, payload: rawPayload, color, }: IKeyboardTextButtonOptions): this; /** * URL button * * ```ts * builder.urlButton({ * label: 'Buy a coffee', * url: 'https://coffee.mania/buy' * }); * ``` */ urlButton({ label, url, payload: rawPayload, }: IKeyboardURLButtonOptions): this; /** * User location request button, occupies the entire keyboard width * * ```ts * builder.locationRequestButton({ * payload: { * command: 'order_delivery' * } * }) * ``` */ locationRequestButton({ payload: rawPayload, }: IKeyboardLocationRequestButtonOptions): this; /** * VK Pay button, occupies the entire keyboard width * * ```ts * builder.payButton({ * hash: { * action: 'transfer-to-group', * group_id: 1, * aid: 10 * } * }) * ``` */ payButton({ payload: rawPayload, hash: rawHash, }: IKeyboardVKPayButtonOptions): this; /** * VK Apps button, occupies the entire keyboard width * * ```ts * builder.applicationButton({ * label: 'LiveWidget', * appId: 6232540, * ownerId: -157525928 * }) * ``` */ applicationButton({ label, appId, ownerId, hash, }: IKeyboardApplicationButtonOptions): this; /** * Allows without sending a message from the user * to receive a notification of a button click and perform the necessary action * * ```ts * builder.callbackButton({ * label: 'Buy a coffee', * payload: { * command: 'buy', * item: 'coffee' * } * }); * ``` */ callbackButton({ label, payload: rawPayload, color, }: IKeyboardCallbackButtonOptions): this; /** * Saves the current row of buttons in the general rows */ row(): this; /** * Sets the keyboard to close after pressing * * ```ts * builder.oneTime(); * * builder.oneTime(false); * ``` */ oneTime(enabled?: boolean): this; /** * Sets the keyboard inline * * ```ts * builder.inline(); * * builder.inline(false); * ``` */ inline(enabled?: boolean): this; /** * Clones the builder with all the settings */ clone(): KeyboardBuilder; /** * Returns a string to keyboard a VK */ toString(): string; /** * Adds a button to the current row */ protected addButton(button: KeyboardButton): this; /** * Adds a wide button to the new row */ protected addWideButton(button: KeyboardButton): this; }