=> sub { URI->new( $_[0]->url . 'stream' ) },
);
has 'json' => (
is => 'lazy',
default => sub {
require JSON;
return JSON->new()
},
);
sub build_post_message( $self, %opt
message_url,
headers => {
'Content-Type' => 'application/json',
},
data => $self->json->encode( \%options ),
ua => $self->short_ua,
);
}
sub buil
package API::Matterbridge::Message;
use strict;
use warnings;
use Moo 2;
use JSON 'decode_json';
use Filter::signatures;
use feature 'signatures';
no warnings 'experimental::signatures';
our $VERSIO
a",
] => (
is => 'ro',
);
sub from_bytes( $class, $bytes ) {
return $class->new( decode_json($bytes))
}
sub reply( $msg, $text, %options ) {
my %reply = (
gateway => $msg->gatew
d_get_messages();
$self->short_ua->start_p($tx)->then(sub($tx) {
my $payload = $self->json->decode( $tx->result->body );
for my $message (@$payload) {
my $m = API::Matt
eam( $self ) {
my $tx = $self->build_get_message_stream();
# Just in case we read half a JSON message
state $buffer = '';
# Replace "read" events to disable default content parser
ead => sub($content,$bytes) {
$buffer .= $bytes;
# Every (full) line should be a JSON stanza
while( $buffer =~ s!^(.*?)\n!! ) {
my $m = API::Matterbridge::Message-