Исправлены синтаксические ошибки и обработка кармы пустоты
This commit is contained in:
18
lib/Karma.pm
18
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,
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user