Mastod...stener(3pm)
πΈ Mastodon::Listener β the manual page π
okay bestie, welcome to the Mastodon::Listener page, from the User Contributed Perl Documentation corner of the 3pm section. this is the thing that lets your Perl code vibe with the streaming API of a Mastodon server, and honestly? it's giving main character energy. π¦
β¨ NAME β¨
Mastodon::Listener β Access the streaming API of a Mastodon server π
π SYNOPSIS π
# From Mastodon::Client
my $listener = $client->stream( 'public' );
# Or use it directly
my $listener = Mastodon::Listener->new(
url => 'https://mastodon.cloud/api/v1/streaming/public',
access_token => $token,
coerce_entities => 1,
)
$listener->on( update => sub {
my ($listener, $status) = @_;
printf "%s said: %s\n",
$status->account->display_name,
$status->content;
});
$listener->start;
no cap, that's the whole vibe right there π«Ά
π DESCRIPTION π
so here's the tea. a Mastodon::Listener object gets created when you call the stream method from a Mastodon::Client, and it has literally one (1) job: parsing a stream of events coming from a Mastodon server. that's it. that's the whole purpose. iconic behavior honestly π
Mastodon::Listener objects inherit from Role::EventEmitter. so if you wanna know how to register callbacks for the different events, go read its documentation, bestie β that's where the details live. i'm just the messenger π§
once you've registered your callbacks, you set the whole thing in motion by calling its start method. and listen: start takes no arguments and it never returns. it's a forever girlie. π
but don't panic, because the stop method exists, and you can call it from inside your callbacks to disconnect from the stream. so you're never actually trapped. slay β¨
π ATTRIBUTES π
β access_token
The OAuth2 access token of your application, if authorization is needed. This is not needed for streaming from public timelines.
so like β if you're just lurking the public timeline, you don't need this. no key, no problem π
β api_version
The API version to use. Defaults to 1.
β coerce_entities
Whether JSON responses should be coerced into Mastodon::Entity objects. Currently defaults to false (but this will likely change in v0.01).
β instance
The instance to use, as a Mastodon::Entity::Instance object. Will be coerced from a URL, and defaults to "mastodon.social".
β stream
The stream to use. Current valid streams are "public", "user", and tag timelines. To access a tag timeline, the argument to this value should begin with a hash character ("#").
β url
The full streaming URL to use. By default, it is constructed from the values in the instance, api_version, and stream attributes.
π₯ EVENTS π₯
π update
A new status has appeared. Callback will be called with the listener and the new status.
π notification
A new notification has appeared. Callback will be called with the listener and the new notification.
π delete
A status has been deleted. Callback will be called with the listener and the ID of the deleted status.
π heartbeat
A new ":thump" has been received from the server. This is mostly for debugging purposes.
π error
Inherited from Role::EventEmitter, will be emitted when an error was found. The callback will be called with a fatal flag, an error message, and any relevant data as a single third argument.
If the error event is triggered in response to a 4xx or 5xx error, the data payload will be an array reference with the response and request objects as received from Net::Async::HTTP.
π AUTHOR π
- JosΓ© JoaquΓn Atria
<jjatria@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2017 by JosΓ© JoaquΓn Atria.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie!! π«Ά this was perl v5.36.0, dated 2022-11-03, and it lives at Mastod...stener(3pm) in the User Contributed Perl Documentation section. go stream something cute. bye bestie πβ¨πΈ
π¦ where this page comes from
- debian bookworm: libmastodon-client-perl 0.017-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmastodon-client-perl 0.017-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmastodon-client-perl 0.017-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmastodon-client-perl 0.017-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmastodon-client-perl 0.017-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms