|
|
@@ -237,15 +237,15 @@ sub request
|
|
|
$ua->post("https://api.telegram.org/bot$config->{token}/$action" => form => $params => sub
|
|
|
{
|
|
|
my ($ua, $tx) = @_;
|
|
|
- my $resp = $tx->success;
|
|
|
+ my $resp = $tx->result;
|
|
|
|
|
|
- unless ($resp)
|
|
|
+ if ($resp->is_error)
|
|
|
{
|
|
|
- my $err = $tx->error;
|
|
|
- $err->{code} ||= 500;
|
|
|
- $err->{url} = $tx->req->url->to_string;
|
|
|
- $err->{body} = $tx->res->body;
|
|
|
- $err->{body} = j($err->{body}) if $tx->res->headers->content_type eq "application/json";
|
|
|
+ my $err = {};
|
|
|
+ $err->{code} = $resp->code;
|
|
|
+ $err->{url} = $resp->req->url->to_string;
|
|
|
+ $err->{body} = $resp->body;
|
|
|
+ $err->{body} = j($err->{body}) if $resp->headers->content_type eq "application/json";
|
|
|
$deferred->reject($err);
|
|
|
}
|
|
|
else
|