Slack::RTM::Bot - This is a perl module helping to create slack bot with Real Time Messaging(RTM) API.
use Slack::RTM::Bot; my $bot = Slack::RTM::Bot->new( token => '<API token>'); $bot->add_action({ channel => 'general', text => '.*' }, sub { my ($response) = @_; print $response->{text}."\n"; } ); $bot->start_RTM; $bot->say( channel => 'general', text => '<!here> hello, world.' ); $bot->say({ channel => '@username', text => 'hello, world.' });
method new(token => $token)
Constructs a Slack::RTM::Bot object.
The $token is the slack API token.
$token
method add_action(\%event, $callback)
$callback will be executed when it fitted the \%event conditions. The \%event key is equal to a key of json received from slack, and value is estimated as regex.
$callback
\%event
$callback is handed JSON object of message received from Slack.
method start_RTM()
It start Real Time Messaging API.
method stop_RTM()
It stop Real Time Messaging API.
method say(%options)
It sent a message to a Slack. The channel name can be used to designate channel. if you want to send a direct message, let designate the @username as a channel.
This is opensource software.
https://github.com/duck8823/Slack-RTM-Bot
https://api.slack.com/rtm
The MIT License (MIT)
Copyright (c) 2016 Shunsuke Maeda
See LICENSE file.
Shunsuke Maeda <duck8823@gmail.com>
To install Slack::RTM::Bot, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Slack::RTM::Bot
CPAN shell
perl -MCPAN -e shell install Slack::RTM::Bot
For more information on module installation, please visit the detailed CPAN module installation guide.