Using the html syntax instead of markdown.
This commit is contained in:
parent
2ddf3ca232
commit
72f2460402
@ -9,6 +9,7 @@ use Data::Dumper;
|
|||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
use Mojo::URL;
|
use Mojo::URL;
|
||||||
|
use Mojo::Util qw/xml_escape/;
|
||||||
|
|
||||||
use DoctorKarma::Config;
|
use DoctorKarma::Config;
|
||||||
use DoctorKarma::Telegram;
|
use DoctorKarma::Telegram;
|
||||||
@ -80,11 +81,15 @@ sub show_karma {
|
|||||||
|
|
||||||
my $user_dao = DoctorKarma::DAO::User->new( dbh => $db );
|
my $user_dao = DoctorKarma::DAO::User->new( dbh => $db );
|
||||||
my $user = $user_dao->recover_id( id => $user_id );
|
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(
|
$telegram->send_message(
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text =>
|
text => $html_message,
|
||||||
"*@{[$user->first_name]}* has @{[$user->karma =~ s/-/\\-/r]} points of karma\\."
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +110,7 @@ User @{[$sending_karma_user->first_name]}:@{[$sending_karma_user->username]}:@{[
|
|||||||
EOF
|
EOF
|
||||||
$telegram->send_message(
|
$telegram->send_message(
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text => 'You cannot substract karma to yourself'
|
text => 'You cannot substract karma to yourself.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,10 +126,12 @@ EOF
|
|||||||
my $id_receptor = $receiving_karma_user->id_user;
|
my $id_receptor = $receiving_karma_user->id_user;
|
||||||
my $receptor_telegram_url = Mojo::URL->new('tg://user');
|
my $receptor_telegram_url = Mojo::URL->new('tg://user');
|
||||||
$receptor_telegram_url->query( id => $id_receptor );
|
$receptor_telegram_url->query( id => $id_receptor );
|
||||||
|
my $first_name = $receiving_karma_user->first_name;
|
||||||
|
my $karma = $receiving_karma_user->karma;
|
||||||
$telegram->send_message(
|
$telegram->send_message(
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text =>
|
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
|
EOF
|
||||||
$telegram->send_message(
|
$telegram->send_message(
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text => 'You cannot give karma to yourself'
|
text => 'You cannot give karma to yourself.'
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -160,11 +167,12 @@ EOF
|
|||||||
$user_dao->add_1_karma( user => $receiving_karma_user );
|
$user_dao->add_1_karma( user => $receiving_karma_user );
|
||||||
my $id_receptor = $receiving_karma_user->id_user;
|
my $id_receptor = $receiving_karma_user->id_user;
|
||||||
my $receptor_telegram_url = Mojo::URL->new('tg://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(
|
$telegram->send_message(
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text =>
|
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."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ sub _user_agent {
|
|||||||
body => {
|
body => {
|
||||||
chat_id => $chat_id,
|
chat_id => $chat_id,
|
||||||
text => $text,
|
text => $text,
|
||||||
parse_mode => 'MarkdownV2',
|
parse_mode => 'HTML',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return $response->{result};
|
return $response->{result};
|
||||||
|
Loading…
Reference in New Issue
Block a user