aboutsummaryrefslogtreecommitdiff
path: root/lib/TgLib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TgLib')
-rw-r--r--lib/TgLib/Api.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/TgLib/Api.pm b/lib/TgLib/Api.pm
index b0a66bf..1fe8d06 100644
--- a/lib/TgLib/Api.pm
+++ b/lib/TgLib/Api.pm
@@ -49,11 +49,12 @@ sub send_message {
my ($self, $chat_id, $text) = @_;
my $logger = $self->{'logger'};
my $uri = "$self->{'uri'}/sendMessage";
- my $content = encode_json {'chat_id' => $chat_id, 'text' => $text};
+ $logger->info("Sending to $chat_id: '$text'\n");
+ utf8::decode($text) unless utf8::is_utf8($text);
+ my $content = encode_json {'chat_id' => $chat_id, 'text' => $text};
my $req = HTTP::Request->new("POST", $uri,
["Content-Type", "application/json"], $content);
- $logger->info("Sending to $chat_id: '$text'\n");
$logger->debug(sprintf "Request:\n%s\n", Dumper($req));
my $resp = $self->{'ua'}->request($req);