App-MatrixClient

 view release on metacpan or  search on metacpan

bin/matrixclient  view on Meta::CPAN

         my $request = $args{request};

         my $request_uri = $request->uri;
         return $orig->( $self, %args )
            ->on_done( sub {
               my ( $response ) = @_;

               my $data = eval { Data::Dump::pp( JSON::decode_json( $response->content ) ) };

               print $requests_fh "Response from $request_uri:\n";
               print $requests_fh "  $_\n" for split m/\n/, $data // $response->content;
            });
      }
   );
}

my $config;
if( -f $CONFIG ) {
   $config = YAML::LoadFile( $CONFIG );
   $SERVER //= $config->{server};
   $SSL    //= $config->{ssl};

lib/App/MatrixClient.pm  view on Meta::CPAN

         );
         $vbox->add( $scroller, expand => 1 );

         return $floatbox = Tickit::Widget::FloatBox->new(
            base_child  => $vbox,
         );
      },
      on_line => sub {
         my ( $tab, $line ) = @_;
         if( $line =~ s{^/}{} ) {
            my ( $cmd, @args ) = split m/\s+/, $line;
            if( my $code = $tab->can( "cmd_$cmd" ) ) {
               $room->adopt_future( $tab->$code( @args ) );
            }
            else {
               $self->do_command( $line, $tab );
            }
         }
         else {
            $room->adopt_future( $room->send_message( $line ) );
            $room->typing_stop;

lib/App/MatrixClient.pm  view on Meta::CPAN

      return $user->user_id;
   }
}

sub do_command
{
   my $self = shift;
   my ( $line, $tab ) = @_;

   # For now all commands are simple methods on __PACKAGE__
   my ( $cmd, @args ) = split m/\s+/, $line;

   $tab->append_line(
      String::Tagged->new( '$ ' . join " ", $cmd, @args )
         ->apply_tag( 0, -1, fg => "cyan" )
   );

   my $method = "cmd_$cmd";
   $self->{cmd_f} = Future->call( sub { $self->$method( @args ) } )
      ->on_done( sub {
         my @result = @_;



( run in 0.865 second using v1.01-cache-2.11-cpan-71847e10f99 )