NAME

WebService::Mattermost::V4::Example::Bot - An example Perl Mattermost bot.

VERSION

version 0.30

DESCRIPTION

An example Mattermost WebSocket bot using WebService::Mattermost. The bot connects to the network, and responds to "Ping" messages with "Pong".

USAGE

#!/usr/bin/env perl

use strict;
use warnings;

use WebService::Mattermost::V4::Example::Bot;

my $bot = WebService::Mattermost::V4::Example::Bot->new({
    username => 'usernamehere',
    password => 'passwordhere',
    base_url => 'https://my.mattermost.server.com/api/v4/'
    debug    => 1, # optional
})->start();

The gw_ methods in this class are events emitted by WebService::Mattermost::V4::Client. Each one has one argument passed which is a HashRef of decoded data from the Mattermost server.

METHODS

gw_ws_started()

Triggered when the bot connects to the Mattermost gateway.

gw_ws_finished()

Triggered when the connection to the gateway closes.

gw_message()

Triggered when a message with an event is received from the gateway.

gw_ws_error()

Triggered when an error is received from the gateway.

gw_message_no_event()

Triggered when a message without an event is received from the gateway.

AUTHOR

Mike Jones <mike@netsplit.org.uk>

COPYRIGHT AND LICENSE

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

This is free software, licensed under:

The MIT (X11) License