Adding /about and /donate.

This commit is contained in:
sergiotarxz 2022-02-09 18:50:48 +01:00
parent 3e93c4dc0d
commit bca8c0c8d1
1 changed files with 60 additions and 7 deletions

View File

@ -27,16 +27,26 @@ my $db = DoctorKarma::DB->dbh;
$telegram->set_my_commands(
commands => [
{
command => 'karma',
description => 'Shows your karma or the one of the user you are replying to',
command => 'karma',
description =>
'Shows your karma or the one of the user you are replying to',
},
{
command => 'doctortop',
command => 'doctortop',
description => 'Shows the most popular users.',
},
{
command => 'doctorhate',
command => 'doctorhate',
description => 'Shows the most hated users.',
},
{
command => 'about',
description =>
'Shows license information, author and where to find the code.',
},
{
command => 'donate',
description => 'Shows how to donate',
}
]
);
@ -98,14 +108,56 @@ sub process_message_with_text {
show_top_ten_hate($message);
return;
}
if ( $text =~ m{^/about(?:@\w+)?$} ) {
show_about($message);
return;
}
if ( $text =~ m{^/donate(?:@\w+)?$} ) {
show_donate($message);
return;
}
if ( defined $reply_to_message && $text =~ /^(?:-|\+)\d+$/ ) {
error_too_much_karma($message);
return;
}
}
sub show_donate {
my $message =shift;
my $chat_id = $message->{chat}{id};
my $html = <<'EOF';
You can donate btc using the following bitcoin address:
bc1qtas98jqjglezqtz5es8cpg0h72qquc4h83e0gz
EOF
$telegram->send_message(
chat_id => $chat_id,
text => $html
);
}
sub show_about {
my $message = shift;
my $chat_id = $message->{chat}{id};
my $html = <<'EOF';
This bot is free software licensed under the <b>AGPLv3</b>.
You can grab a copy of the source code at:
<a href="https://gitea.sergiotarxz.freemyip.com/sergiotarxz/DoctorKarma">https://gitea.sergiotarxz.freemyip.com/sergiotarxz/DoctorKarma</a>
If you want to contribute contact with @sergiotarxz.
If you are interested in donate use the /donate command.
EOF
$telegram->send_message(
chat_id => $chat_id,
text => $html,
);
}
sub error_too_much_karma {
my $message = shift;
my $message = shift;
my $chat_id = $message->{chat}{id};
$telegram->send_message(
@ -135,6 +187,7 @@ sub show_top_ten_hate {
text => $html
);
}
sub show_top_ten {
my $message = shift;
my $chat_id = $message->{chat}{id};