helper answer => sub {
my ($c, $update) = shift;
...
if ($update->{message}{text} eq "something") {
$api->sendMessage ({ chat_id => $chat_id, text => '/shot - Get online camera shot' });
}
};
...
post '/'.$config->{telegram_api_token} => sub {
my $c = shift;
my $update = $c->req->json;
$c->answer($update);
$c->render(json => "ok");
};
if ($config->{polling}) {
$api->deleteWebhook();
Mojo::IOLoop->recurring($config->{polling_timeout} => sub {
my $updates = $api->getUpdates;
my @updates = @{$updates->{result}};
for my $u (@updates) {
app->controller_class->helpers->answer($u); ##### How to call helper answer here ?
}
});
}