Yuriy Zhilovets 4 years ago
parent
commit
f00f7b242f
1 changed files with 12 additions and 3 deletions
  1. 12 3
      telegram.pl

+ 12 - 3
telegram.pl

@@ -204,6 +204,7 @@ sub notify::telegram::send
   my $body = shift;
   my $to = $body->{to};
   $to = [ $to ] unless ref($to) eq "ARRAY";
+  $body->{disable_error_handler} = 1;
   
   my @results;
   
@@ -344,10 +345,18 @@ sub notify
   $params->{reply_to_message_id} = $rest->{msgid} if $rest->{msgid};
   $params->{disable_notification} = 1 if $rest->{silent};
   
-  return request("sendMessage", $params)->catch(sub
+  my $disable_error_handler = delete $params->{disable_error_handler};
+  
+  my $promise = request("sendMessage", $params);
+  unless ($disable_error_handler)
   {
-    $log->error(Dumper $params,@_);
-  });
+    $promise = $promise->catch(sub
+    {
+      $log->error(Dumper $params,@_);
+    });
+  }
+  
+  return $promise;
 }
 
 sub refpath