From ba69f9d9df73b1b443ee3369faa3a92aa3b7a24e Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 27 Mar 2022 20:38:15 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=81=D0=B8=D0=BD=D1=82=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BA=D0=B8=20=D0=B8=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D0=B0=20=D0=BA=D0=B0=D1=80=D0=BC=D1=8B=20?= =?UTF-8?q?=D0=BF=D1=83=D1=81=D1=82=D0=BE=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Karma.pm | 18 ++++++++++++++---- lib/Phrases.pm | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Karma.pm b/lib/Karma.pm index 42895c2..e8d06a8 100644 --- a/lib/Karma.pm +++ b/lib/Karma.pm @@ -28,12 +28,17 @@ sub KarmaSet (@) { my $phrase = shift; my $action = shift; - if ((! defined $phrase) || $phrase eq '') { - $phrase = ' '; + unless (defined $phrase) { + $phrase = ''; } $phrase = trim ($phrase); + # Костылёк для кармы пустоты + if ($phrase eq '') { + $phrase = ' '; + } + my $cache = CHI->new ( driver => 'BerkeleyDB', root_dir => $cachedir, @@ -80,12 +85,17 @@ sub KarmaGet (@) { my $chatid = shift; my $phrase = shift; - if ((! defined $phrase) || $phrase eq '') { - $phrase = ' '; + unless (defined $phrase) { + $phrase = ''; } $phrase = trim ($phrase); + # Костылёк для кармы пустоты + if ($phrase eq '') { + $phrase = ' '; + } + my $cache = CHI->new ( driver => 'BerkeleyDB', root_dir => $cachedir, diff --git a/lib/Phrases.pm b/lib/Phrases.pm index 86553f3..16a0b49 100644 --- a/lib/Phrases.pm +++ b/lib/Phrases.pm @@ -97,7 +97,7 @@ my $parse_message = sub { } else { $reply = trim (Fortune ()); } - } elsif (length ($cmd) >= length ('karma ') && substr ($cmd, 0, length ('karma ') eq 'karma ')) { + } elsif (length ($cmd) >= length ('karma ') && substr ($cmd, 0, length ('karma ')) eq 'karma ') { # По-умолчанию достаём карму пустоты my $text = undef; @@ -106,7 +106,7 @@ my $parse_message = sub { } $reply = KarmaGet ($m->{chatid}, $text); - } elsif (length ($cmd) >= length ('карма ') && substr ($cmd, 0, length ('карма ') eq 'карма ')) { + } elsif (length ($cmd) >= length ('карма ') && substr ($cmd, 0, length ('карма ')) eq 'карма ') { # По-умолчанию достаём карму пустоты my $text = undef; @@ -123,7 +123,7 @@ my $parse_message = sub { $reply = KarmaGet ($m->{chatid}, undef); } # Скорее всего изменение кармы, но это не точно - } elsif ($m->{message} > length ('++')) { + } elsif (length ($m->{message}) > length ('++')) { if (substr ($m->{message}, 0 - length ('++')) eq '++' || substr ($m->{message}, 0 - length ('--')) eq '--') { my @arr = split /\n/s, $m->{message};