Aion-Surf

 view release on metacpan or  search on metacpan

lib/Aion/Surf.pm  view on Meta::CPAN

Sends a message to a telegram bot.

	bot_message "hi!" # --> {ok => 1}

=head2 tech_message (;$message)

Sends a message to a technical telegram channel.

	tech_message "hi!" # --> {ok => 1}

=head2 bot_update ()

Receives the latest messages sent to the bot.

	# mock
	*LWP::UserAgent::request = sub {
	    my ($ua, $request) = @_;
	
	    my $offset = from_json($request->content)->{offset};
	    if($offset) {
	        return HTTP::Response->new(200, "OK", undef, to_json {
	            ok => 1,
	            result => [],
	        });
	    }
	
	    HTTP::Response->new(200, "OK", undef, to_json {
	        ok => 1,
	        result => [{
	            message => "hi!",
	            update_id => 0,
	        }],
	    });
	};
	
	bot_update  # --> ["hi!"]
	
	
	# mock
	*LWP::UserAgent::request = sub {
	    HTTP::Response->new(200, "OK", undef, to_json {
	        ok => 0,
	        description => "nooo!"
	    })
	};
	
	eval { bot_update }; $@  # ~> nooo!

=head1 SEE ALSO

=over

=item * LWP::Simple

=item * LWP::Simple::Post

=item * HTTP::Request::Common

=item * WWW::Mechanize

=item * LLL<https://habr.com/ru/articles/63432/>

=back

=head1 AUTHOR

Yaroslav O. Kosmina LL<mailto:dart@cpan.org>

=head1 LICENSE

âš– B<GPLv3>

=head1 COPYRIGHT

The Aion::Surf module is copyright © 2023 Yaroslav O. Kosmina. Rusland. All rights reserved.



( run in 1.040 second using v1.01-cache-2.11-cpan-df04353d9ac )