Implemented !хелп, !хэлп, answer 'кто все эти люди?' question, hide notext log message to debug lever

This commit is contained in:
eleksir
2021-05-04 13:27:12 +03:00
parent 36c79eb46c
commit 095cb57a18
2 changed files with 26 additions and 5 deletions

View File

@@ -184,6 +184,8 @@ sub Command {
sleep (irand (2) + 1); sleep (irand (2) + 1);
$msg->replyMd ($reply); $msg->replyMd ($reply);
return; return;
} elsif (substr ($text, 1) eq 'хэлп') {
$reply = 'HALP!!!11';
} elsif (substr ($text, 1) eq 'help' || substr ($text, 1) eq 'помощь') { } elsif (substr ($text, 1) eq 'help' || substr ($text, 1) eq 'помощь') {
$reply = << "MYHELP"; $reply = << "MYHELP";
``` ```

View File

@@ -227,7 +227,7 @@ sub __on_msg {
# detect and log messages without text, noop here # detect and log messages without text, noop here
unless (defined $msg->text) { unless (defined $msg->text) {
carp sprintf ('[INFO] No text in message from %s', $vis_a_vi); carp sprintf ('[DEBUG] No text in message from %s', $vis_a_vi) if $c->{debug};
return; return;
} }
@@ -275,15 +275,30 @@ sub __on_msg {
# phrase directed to bot # phrase directed to bot
if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){ if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){
$phrase = $1; $phrase = $1;
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
if ($text =~ /^кто +все +эти +люди\?$/i) {
$reply = 'Кто здесь?';
} else {
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
}
# bot mention by name # bot mention by name
} elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) { } elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) {
$phrase = $text; $phrase = $text;
$reply = $hailo->{$msg->chat->id}->reply($phrase);
if ($text =~ /^кто +все +эти +люди\?$/i) {
$reply = 'Кто здесь?';
} else {
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
}
# bot mention by telegram name # bot mention by telegram name
} elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) { } elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) {
$phrase = $text; $phrase = $text;
$reply = $hailo->{$msg->chat->id}->reply ($phrase);
if ($text =~ /^кто +все +эти +люди\?$/i) {
$reply = 'Кто здесь?';
} else {
$reply = $hailo->{$msg->chat->id}->learn_reply ($phrase);
}
# karma adjustment # karma adjustment
} elsif (substr ($text, -2) eq '++' || substr ($text, -2) eq '--') { } elsif (substr ($text, -2) eq '++' || substr ($text, -2) eq '--') {
my @arr = split /\n/, $text; my @arr = split /\n/, $text;
@@ -296,7 +311,11 @@ sub __on_msg {
} }
# just message in chat # just message in chat
} else { } else {
$hailo->{$msg->chat->id}->learn ($text); if ($text =~ /^кто +все +эти +люди\?$/i) {
$reply = 'Кто здесь?';
} else {
$hailo->{$msg->chat->id}->learn ($text);
}
} }
} }