It's better to explain the problem on example. I'm writing bot for Telegram
and want to implement getting updates via WebHook and polling (via Mojo::
IOLoop) both.
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 ?
}
});
}
Is there any way to execute helper 'answer' outside the routes or I need to
move project from Mojolicious::Lite to Mojolicious ?
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.