From f6a5a05e5870033ef72dcd7d2d57b5deb5490904 Mon Sep 17 00:00:00 2001 From: eleksir Date: Thu, 15 Dec 2022 02:19:01 +0300 Subject: [PATCH] Disable chat in morning greet list if chat id is not found --- lib/RedisLib.pm | 11 ++++++++--- lib/Teapot/Bot/Brain.pm | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/RedisLib.pm b/lib/RedisLib.pm index 27f8059..a0f200b 100644 --- a/lib/RedisLib.pm +++ b/lib/RedisLib.pm @@ -77,12 +77,17 @@ sub redis_parse_message { return; } - unless (defined $j->{migrate_to_chat_id}) { - $log->error ("An error occured while sending message to chat $m->{chatid}"); + if (defined $j->{migrate_to_chat_id}) { + MigrateSettingsToNewChatID ($m->{chatid}, $j->{migrate_to_chat_id}); + } elsif (defined ($j->{message}) && $j->{message} eq 'Bad Request: chat not found') { + if (defined $j->{param}->{chat_id}) { + FortuneToggle ($j->{param}->{chat_id}, 0); + } + } else { + $log->error("An error occured while sending message to chat $m->{chatid}"); return; } - MigrateSettingsToNewChatID ($m->{chatid}, $j->{migrate_to_chat_id}); $message->{chat_id} = $j->{migrate_to_chat_id}; $r = undef; diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index 37ebbb9..715503c 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -756,6 +756,7 @@ sub _post_request { $result->{message} = $res->content->asset->content; $result->{http_code} = $res->code; + $result->{param} = $form_args; return $result; # to handle this in upper layers }