Slack::RTM::Bot;
use 5.008001;
use strict;
use warnings;
use POSIX qw/sys_wait_h/;
use JSON;
use Slack::RTM::Bot::Client;
our $VERSION = "1.15";
pipe(READH, WRITEH);
select(WRITEH);
uffer = <READH>) =~ s/\n.*$//;
if ($buffer) {
$self->{client}->write(
%{JSON::from_json(Encode::decode_utf8($buffer))}
);
}
if (++$i % 30 == 0) {
$self->
uffer = <READH>) =~ s/\n.*$//;
if ($buffer) {
$self->{client}->write(
%{JSON::from_json(Encode::decode_utf8($buffer))}
);
}
if (++$i % 30 == 0) {
$self->
package Slack::RTM::Bot::Client;
use strict;
use warnings;
use JSON;
use Encode;
use Data::Dumper;
use HTTP::Request::Common qw(POST GET);
use LWP::UserAgent;
use LWP::Protocol::https;
ps://slack.com/api/rtm.connect', [ token => $token ]);
my $content;
eval {
$content = JSON::from_json($res->content);
};
if ($@) {
die 'connect response fail:'.Dumper $res->content;
}
$data =~ /.*hello.*/;
}
}
sub write {
my $self = shift;
$self->{ws_client}->write(JSON::encode_json({@_}));
}
sub find_conversation_id {
my $self = shift;
my ($name) = @_;
my $id =