1

Rework karma adjustment and smiles handle

This commit is contained in:
eleksir
2022-04-04 12:03:26 +03:00
parent 7ef4c0e28a
commit 4325061848

View File

@@ -93,12 +93,8 @@ sub __new_bot_message {
$reply = 'Чего тебе?';
} elsif (($text =~ /^$qname[\,|\:]? (.+)/u) && ($hash{type} eq 'groupchat')) {
$reply = $hailo->{$chatid}->learn_reply ($1);
} elsif ($text =~ /^\=\($/u || $text =~ /^\:\($/u || $text eq /^\)\:$/u) {
$reply = ':)';
} elsif ($text =~ /^\=\)$/u || $text =~ /^\:\)$/u || $text =~ /^\(\:$/u) {
$reply = ':D';
# karma adjustment
} elsif ($text =~ /(\+\+|\-\-)$/) {
} elsif ($text =~ /(\+\+|\-\-)$/u) {
my @arr = split /\n/, $text;
if ($#arr < 1) {
@@ -118,6 +114,31 @@ sub __new_bot_message {
$reply = Command (%hash);
# just message in chat
} else {
my @smiles = ('=(', ':(', '):');
my $done = 0;
while (my $smile = pop @smiles) {
if ($text eq $smile) {
$reply = ':)';
$done = 1;
last;
}
}
unless ($done) {
$#smiles = -1;
@smiles = ('=)', ':)', '(:');
while (my $smile = pop @smiles) {
if ($text eq $smile) {
$reply = ':D';
$done = 1;
last;
}
}
}
unless ($done) {
# in groupchat we answer only to phrases that mention us
if ($hash{type} eq 'groupchat') {
$hailo->{$chatid}->learn ($text);
@@ -126,6 +147,7 @@ sub __new_bot_message {
$reply = $hailo->{$chatid}->learn_reply ($text);
}
}
}
if (defined $reply && ($reply ne '')) {
if ($hash{'type'} eq 'groupchat') {