diff --git a/bin/doctor_karma.pl b/bin/doctor_karma.pl index e84bc9b..269ede8 100755 --- a/bin/doctor_karma.pl +++ b/bin/doctor_karma.pl @@ -9,6 +9,7 @@ use Data::Dumper; use JSON; use Mojo::URL; +use Mojo::Util qw/xml_escape/; use DoctorKarma::Config; use DoctorKarma::Telegram; @@ -80,11 +81,15 @@ sub show_karma { my $user_dao = DoctorKarma::DAO::User->new( dbh => $db ); my $user = $user_dao->recover_id( id => $user_id ); + my $first_name = $user->first_name; + my $karma = $user->karma; + my $html_message = <<"EOF"; +@{[xml_escape($first_name)]} has @{[xml_escape($karma)]} points of karma. +EOF $telegram->send_message( chat_id => $chat_id, - text => -"*@{[$user->first_name]}* has @{[$user->karma =~ s/-/\\-/r]} points of karma\\." + text => $html_message, ); } @@ -105,7 +110,7 @@ User @{[$sending_karma_user->first_name]}:@{[$sending_karma_user->username]}:@{[ EOF $telegram->send_message( chat_id => $chat_id, - text => 'You cannot substract karma to yourself' + text => 'You cannot substract karma to yourself.' ); return; } @@ -121,10 +126,12 @@ EOF my $id_receptor = $receiving_karma_user->id_user; my $receptor_telegram_url = Mojo::URL->new('tg://user'); $receptor_telegram_url->query( id => $id_receptor ); + my $first_name = $receiving_karma_user->first_name; + my $karma = $receiving_karma_user->karma; $telegram->send_message( chat_id => $chat_id, text => -"[@{[$receiving_karma_user->first_name]}]($receptor_telegram_url) has now @{[$receiving_karma_user->karma =~ s/-/\\-/r]} of karma\\." +"@{[xml_escape($first_name)]} has now @{[xml_escape($karma)]} of karma." ); } @@ -145,7 +152,7 @@ User @{[$sending_karma_user->first_name]}:@{[$sending_karma_user->username]}:@{[ EOF $telegram->send_message( chat_id => $chat_id, - text => 'You cannot give karma to yourself' + text => 'You cannot give karma to yourself.' ); return; } @@ -160,11 +167,12 @@ EOF $user_dao->add_1_karma( user => $receiving_karma_user ); my $id_receptor = $receiving_karma_user->id_user; my $receptor_telegram_url = Mojo::URL->new('tg://user'); - $receptor_telegram_url->query( id => $id_receptor ); + my $first_name = $receiving_karma_user->first_name; + my $karma = $receiving_karma_user->karma; $telegram->send_message( chat_id => $chat_id, text => -"[@{[$receiving_karma_user->first_name]}]($receptor_telegram_url) has now @{[$receiving_karma_user->karma =~ s/-/\\-/r]} of karma\\." +"@{[xml_escape($first_name)]} has now @{[xml_escape($karma)]} of karma." ); } diff --git a/lib/DoctorKarma/Telegram.pm b/lib/DoctorKarma/Telegram.pm index 63420b9..d83f2ad 100644 --- a/lib/DoctorKarma/Telegram.pm +++ b/lib/DoctorKarma/Telegram.pm @@ -91,7 +91,7 @@ sub _user_agent { body => { chat_id => $chat_id, text => $text, - parse_mode => 'MarkdownV2', + parse_mode => 'HTML', } ); return $response->{result};