File: listener

package info (click to toggle)
libmastodon-client-perl 0.017-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: perl: 1,525; makefile: 9
file content (30 lines) | stat: -rwxr-xr-x 631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env perl

use strict;
use warnings;
use open ':std', ':encoding(UTF-8)';

use Mastodon::Listener;

my $access_token = shift
    or die "You must pass an access token as the first argument\n";

my $listener = Mastodon::Listener->new(
    url => 'https://botsin.space/api/v1/streaming/public',
    access_token => $ARGV[0],
    coerce_entities => 1,
);

$listener->on( error => sub {
    my ( undef, undef, $msg ) = @_;
    warn $msg;
});

$listener->on( update => sub {
    my ( undef, $status ) = @_;
    printf "%s said: %s\n\n",
        $status->account->display_name,
        $status->content;
});

$listener->start;