RandomImageResponder

RandomImageResponder

Class representing a bot random image responder. Random image responders always reply with a randomly selected image from a list, as a Slack attachment.

Constructor

new RandomImageResponder(options)

Create a bot random image responder.
Source:
Parameters:
Name Type Description
options Object The responder options.
Name Type Attributes Description
images Array.<String> | Array.<Object> The images to respond with, one will be randomly picked each time.
label String <optional>
Default text to show alongside images.
color String <optional>
Default color of the image attachment, a hex code including the preceeding "#".
alias String | Alias <optional>
The alias to respond with. This must be either an Alias or the name of one registered the bot.
Examples

Create a random image responder

new Bot.Responder.RandomImage({
    images: [
        'https://i.imgur.com/ydM3Wb4.gif',
        'https://media.giphy.com/media/XdACBmg3lx6RG/giphy.gif'
    ]
});

Create a random image responder with additional configurations

new Bot.Responder.RandomImage({
    images: [
        {
            image: 'https://i.imgur.com/ydM3Wb4.gif',
            label: 'Some cute goats'
        },
        {
            image: 'https://media.giphy.com/media/XdACBmg3lx6RG/giphy.gif',
            label: 'A goat with ice-skating skills'
        }
    ]
});

Create a random image responder with a default label/color

new Bot.Responder.RandomImage({
    label: 'Have a goat',
    color: '#ffced8',
    images: [
        'https://i.imgur.com/ydM3Wb4.gif',
        'https://media.giphy.com/media/XdACBmg3lx6RG/giphy.gif'
    ]
});

Extends

Methods

(static) create() → {RandomImageResponder}

Create a bot random image responder (see RandomImageResponder for parameters).
Source:
Returns:
Type:
RandomImageResponder
The new random image responder.

(async) respond(message) → {Promise}

Respond to an incoming message with a random responder message.
Overrides:
Source:
Parameters:
Name Type Description
message Object The Slack message to respond to.
Returns:
Type:
Promise
A promise which resolves when the message is sent.