From 095cb57a18a4eae66bc7c02b31b7ecb84bcc747b Mon Sep 17 00:00:00 2001 From: eleksir Date: Tue, 4 May 2021 13:27:12 +0300 Subject: [PATCH] =?UTF-8?q?Implemented=20!=D1=85=D0=B5=D0=BB=D0=BF,=20!?= =?UTF-8?q?=D1=85=D1=8D=D0=BB=D0=BF,=20answer=20'=D0=BA=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D1=8D=D1=82=D0=B8=20=D0=BB=D1=8E=D0=B4?= =?UTF-8?q?=D0=B8=3F'=20question,=20hide=20notext=20log=20message=20to=20d?= =?UTF-8?q?ebug=20lever?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/BotLib.pm | 2 ++ lib/TelegramBot.pm | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/BotLib.pm b/lib/BotLib.pm index f307141..85b3623 100644 --- a/lib/BotLib.pm +++ b/lib/BotLib.pm @@ -184,6 +184,8 @@ sub Command { sleep (irand (2) + 1); $msg->replyMd ($reply); return; + } elsif (substr ($text, 1) eq 'хэлп') { + $reply = 'HALP!!!11'; } elsif (substr ($text, 1) eq 'help' || substr ($text, 1) eq 'помощь') { $reply = << "MYHELP"; ``` diff --git a/lib/TelegramBot.pm b/lib/TelegramBot.pm index 1729c57..95fbac9 100644 --- a/lib/TelegramBot.pm +++ b/lib/TelegramBot.pm @@ -227,7 +227,7 @@ sub __on_msg { # detect and log messages without text, noop here 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; } @@ -275,15 +275,30 @@ sub __on_msg { # phrase directed to bot if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){ $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 } elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) { $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 } elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) { $phrase = $text; - $reply = $hailo->{$msg->chat->id}->reply ($phrase); + + if ($text =~ /^кто +все +эти +люди\?$/i) { + $reply = 'Кто здесь?'; + } else { + $reply = $hailo->{$msg->chat->id}->learn_reply ($phrase); + } # karma adjustment } elsif (substr ($text, -2) eq '++' || substr ($text, -2) eq '--') { my @arr = split /\n/, $text; @@ -296,7 +311,11 @@ sub __on_msg { } # just message in chat } else { - $hailo->{$msg->chat->id}->learn ($text); + if ($text =~ /^кто +все +эти +люди\?$/i) { + $reply = 'Кто здесь?'; + } else { + $hailo->{$msg->chat->id}->learn ($text); + } } }