Extra

Class for building extra parameters of messages

Constructor

new Extra(optsopt)

Parameters:
NameTypeAttributesDescription
optsobject<optional>

Initial extra parameters

// Loads `reply_to_message_id: 1` parameter
new Extra({ reply_to_message_id: 1 })

Members

(static) Markup :Markup

Markup class. You can import Markup from Extra

const { Extra: { Markup } } = require('opengram')
Type:
  • Markup

Methods

HTML(valueopt) → {Extra}

Enable / Disable parse_mode: 'HTML' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

caption(captionopt) → {Extra}

Adds caption for the animation, audio, document, photo, video or voice

Parameters:
NameTypeAttributesDescription
captionstring<optional>

The text of caption

Returns:
Type: 
Extra

captionEntities(entities) → {Extra}

Adds caption entities for the animation, audio, document, photo, video or voice

Parameters:
NameTypeDescription
entitiesArray.<MessageEntity>

Array of entities

Returns:
Type: 
Extra

entities(entities) → {Extra}

Adds entities for message text

Parameters:
NameTypeDescription
entitiesArray.<MessageEntity>

Array of entities

Returns:
Type: 
Extra

inReplyTo(messageId) → {Extra}

Adding reply to message

Parameters:
NameTypeDescription
messageIdnumber

Message id to reply

Returns:
Type: 
Extra

load(opts) → {Extra}

Loads extra parameters from object to Extra instance

// Returns new instance with `reply_to_message_id: 1`
Extra.load({ reply_to_message_id: 1 })
// Loads `reply_to_message_id: 1` parameter to exists instance
new Extra().load({ reply_to_message_id: 1 })
Parameters:
NameTypeDescription
optsobject

Extra parameters object

Returns:
Type: 
Extra

markdown(valueopt) → {Extra}

Enable / Disable parse_mode: 'Markdown' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

markdownV2(valueopt) → {Extra}

Enable / Disable parse_mode: 'MarkdownV2' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

value

Returns:
Type: 
Extra

markup(markup) → {Extra}

Adds (inline-)keyboard markup to Extra instance

// Example with factory function
ctx.reply('Hello',
  Extra.markdown()
    .markup((markup) => markup.removeKeyboard())
)

// With Markup instance / object
const { Markup } = require('opengram')
const keyboard = Markup.inlineKeyboard([Markup.callbackButton('Anime', 'data')])

ctx.reply('Hello',
  Extra.markdown().markup(keyboard)
)
Parameters:
NameTypeDescription
markupobject | MarkupCallback

Callback returning markup / Markup object

Returns:
Type: 
Extra

notifications(valueopt) → {Extra}

Enable / Disable notification for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

webPreview(valueopt) → {Extra}

Enable / Disable web preview for links in message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

(static) HTML(valueopt) → {Extra}

Enable / Disable parse_mode: 'HTML' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

(static) caption(captionopt) → {Extra}

Adds caption for the animation, audio, document, photo, video or voice

Parameters:
NameTypeAttributesDescription
captionstring<optional>

The text of caption

Returns:
Type: 
Extra

(static) captionEntities(entities) → {Extra}

Adds caption entities for the animation, audio, document, photo, video or voice

Parameters:
NameTypeDescription
entitiesArray.<MessageEntity>

Array of entities

Returns:
Type: 
Extra

(static) entities(entities) → {Extra}

Adds entities for message text

Parameters:
NameTypeDescription
entitiesArray.<MessageEntity>

Array of entities

Returns:
Type: 
Extra

(static) inReplyTo(messageId) → {Extra}

Adding reply to message

Parameters:
NameTypeDescription
messageIdnumber

Message id to reply

Returns:
Type: 
Extra

(static) load(opts) → {Extra}

Loads extra parameters from object to Extra instance

// Returns new instance with `reply_to_message_id: 1`
Extra.load({ reply_to_message_id: 1 })
// Loads `reply_to_message_id: 1` parameter to exists instance
new Extra().load({ reply_to_message_id: 1 })
Parameters:
NameTypeDescription
optsobject

Extra parameters object

Returns:
Type: 
Extra

(static) markdown(valueopt) → {Extra}

Enable / Disable parse_mode: 'Markdown' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

(static) markdownV2(valueopt) → {Extra}

Enable / Disable parse_mode: 'MarkdownV2' for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

(static) markup(markup) → {object}

Adds (inline-)keyboard markup to Extra instance

// Example with factory function
ctx.reply('Hello',
  Extra.markdown()
    .markup((markup) => markup.removeKeyboard())
)

// With Markup instance / object
const { Markup } = require('opengram')
const keyboard = Markup.inlineKeyboard([Markup.callbackButton('Anime', 'data')])

ctx.reply('Hello',
  Extra.markdown().markup(keyboard)
)
Parameters:
NameTypeDescription
markupobject | Markup | MarkupCallback

Markup object

Returns:
Type: 
object

(static) notifications(valueopt) → {Extra}

Enable / Disable notification for message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra

(static) webPreview(valueopt) → {Extra}

Enable / Disable web preview for links in message

Parameters:
NameTypeAttributesDefaultDescription
valueboolean<optional>
true

Value

Returns:
Type: 
Extra