Rework karma adjustment and smiles handle
This commit is contained in:
@@ -93,12 +93,8 @@ sub __new_bot_message {
|
|||||||
$reply = 'Чего тебе?';
|
$reply = 'Чего тебе?';
|
||||||
} elsif (($text =~ /^$qname[\,|\:]? (.+)/u) && ($hash{type} eq 'groupchat')) {
|
} elsif (($text =~ /^$qname[\,|\:]? (.+)/u) && ($hash{type} eq 'groupchat')) {
|
||||||
$reply = $hailo->{$chatid}->learn_reply ($1);
|
$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
|
# karma adjustment
|
||||||
} elsif ($text =~ /(\+\+|\-\-)$/) {
|
} elsif ($text =~ /(\+\+|\-\-)$/u) {
|
||||||
my @arr = split /\n/, $text;
|
my @arr = split /\n/, $text;
|
||||||
|
|
||||||
if ($#arr < 1) {
|
if ($#arr < 1) {
|
||||||
@@ -118,6 +114,31 @@ sub __new_bot_message {
|
|||||||
$reply = Command (%hash);
|
$reply = Command (%hash);
|
||||||
# just message in chat
|
# just message in chat
|
||||||
} else {
|
} 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
|
# in groupchat we answer only to phrases that mention us
|
||||||
if ($hash{type} eq 'groupchat') {
|
if ($hash{type} eq 'groupchat') {
|
||||||
$hailo->{$chatid}->learn ($text);
|
$hailo->{$chatid}->learn ($text);
|
||||||
@@ -126,6 +147,7 @@ sub __new_bot_message {
|
|||||||
$reply = $hailo->{$chatid}->learn_reply ($text);
|
$reply = $hailo->{$chatid}->learn_reply ($text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (defined $reply && ($reply ne '')) {
|
if (defined $reply && ($reply ne '')) {
|
||||||
if ($hash{'type'} eq 'groupchat') {
|
if ($hash{'type'} eq 'groupchat') {
|
||||||
|
|||||||
Reference in New Issue
Block a user