NAME

WebService::Mattermost::V4::Client - Perl websocket client for Mattermost.

VERSION

version 0.29

DESCRIPTION

This class connects to Mattermost via the WebSocket gateway and can either be extended in a child class, or used in a script.

USAGE

FROM A SCRIPT

use WebService::Mattermost::V4::Client;

my $bot = WebService::Mattermost::V4::Client->new({
    username => 'usernamehere',
    password => 'password',
    base_url => 'https://mattermost.server.com/api/v4/',

    # Optional arguments
    debug       => 1, # Show extra connection information
    ignore_self => 0, # May cause recursion!
});

$bot->on(message => sub {
    my ($bot, $args) = @_;

    # $args contains the decoded message content
});

$bot->start(); # Add me last

EXTENSION

See WebService::Mattermost::V4::Example::Bot.

EVENTS

Events are either available to be caught with on in scripts, or have methods which can be overridden in child classes.

gw_ws_started

The bot connected to the Mattermost gateway. Can be overridden as gw_ws_started().

gw_ws_finished

The bot disconnected from the Mattermost gateway. Can be overridden as gw_ws_finished().

gw_message

The bot received a message. Can be overridden as gw_message().

gw_ws_error

The bot received an error. Can be overridden as gw_error().

gw_message_no_event

The bot received a message without an event (which is usually a "ping" item). Can be overridden as gw_message_no_event().

AUTHOR

Mike Jones <mike@netsplit.org.uk>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Mike Jones.

This is free software, licensed under:

The MIT (X11) License