Using the html syntax instead of markdown.

This commit is contained in:
sergiotarxz 2022-02-08 05:12:12 +01:00
parent 2ddf3ca232
commit 72f2460402
2 changed files with 16 additions and 8 deletions

View File

@ -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";
<b>@{[xml_escape($first_name)]}</b> 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\\."
"<b>@{[xml_escape($first_name)]}</b> 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\\."
"<b>@{[xml_escape($first_name)]}</b> has now @{[xml_escape($karma)]} of karma."
);
}

View File

@ -91,7 +91,7 @@ sub _user_agent {
body => {
chat_id => $chat_id,
text => $text,
parse_mode => 'MarkdownV2',
parse_mode => 'HTML',
}
);
return $response->{result};