Skip to main content

Button

Provides api for a new button with custom name.

Button API is similar as for Node.js EventEmitter class, but provides only on, once, emit functions.

import { Button } from "@tlgr/button";
const button = new Button(options);

extends​

constructor(bot, name, [options])​

added in 1.0.0
  • bot - <Object>. Telegraf instance.
  • name - <string>. Button name, or text which user will see.
  • options? - <Object>
    • prefix - <string>. Name of the control. Default is @tlgr/button
    • disableUUID - <boolean>. Enable/Disable uuid generation for button control. It guarantee about button has be unique name. Default is false
    • payloadDivider -<string>. Payload divider between name and payload. Default is -
    • alert - <Object>. Alert options. Default is undefined
      • text- <string>. Alert text.
      • mode - <string>. Alert mode. Possible values: text or modal. Default is text
      • show - <boolean>. Show modal or not. Default is false.

methods​

render([payload])​

added in 1.0.0

properties​

uuid​

added in 1.0.0

modifiers​

  • readonly

description​

Random generated hash. Returns undefined in case if options.disableUUID=true

name​

added in 1.0.0

modifiers​

  • readonly
  • getter

description​

Resolved button name. This property consist of options.prefix and options.disableUUID.

payload​

added in 1.0.0

modifiers​

  • readonly
  • getter

description​

Called payload. Payload sets after render([payload]) function