diff --git a/lib/botlib.pm b/lib/botlib.pm index 00b763f..ec23b79 100644 --- a/lib/botlib.pm +++ b/lib/botlib.pm @@ -60,6 +60,8 @@ sub logger { sub trim { my $str = shift; + return $str if ($str eq ''); + while (substr ($str, 0, 1) =~ /^\s$/xms) { $str = substr ($str, 1); } diff --git a/lib/telegrambot.pm b/lib/telegrambot.pm index 56fe300..40cae94 100644 --- a/lib/telegrambot.pm +++ b/lib/telegrambot.pm @@ -268,7 +268,7 @@ MYHELP my @arr = split(/\n/, $text); if ($#arr < 1) { - $reply = karmaSet ($chatid, substr ($text, 0, -2), substr ($text, -2)); + $reply = karmaSet ($chatid, trim (substr ($text, 0, -2)), substr ($text, -2)); } else { $just_message_in_chat = 1; } @@ -418,7 +418,7 @@ MYHELP my @arr = split(/\n/, $text); if ($#arr < 1) { - $reply = karmaSet ($chatid, substr ($text, 0, -2), substr ($text, -2)); + $reply = karmaSet ($chatid, trim (substr ($text, 0, -2)), substr ($text, -2)); } else { # just message in chat $hailo->{$msg->chat->id}->learn ($text);