diff --git a/lib/RedisLib.pm b/lib/RedisLib.pm index 691dfc3..74a4c95 100644 --- a/lib/RedisLib.pm +++ b/lib/RedisLib.pm @@ -13,6 +13,7 @@ use Mojo::Redis; use Mojo::Redis::Connection; use BotLib::Conf qw (LoadConf); +use Teapot::Bot::Object::ChatPermissions; use version; our $VERSION = qw (1.0); use Exporter qw (import); @@ -39,7 +40,9 @@ sub redis_parse_message { $message->{chat_id} = $m->{chatid}; $message->{text} = $m->{message}; - if (Teapot::Bot::Object::ChatPermissions::canTalk ($main::TGM, $m->{chatid})) { + my $can_talk = Teapot::Bot::Object::ChatPermissions->canTalk ($main::TGM, $m->{chatid}); + + if ($can_talk) { # Результат этого действия нас не сильно волнует, т.к. если будет ошибка, то в лог попадёт трейс $main::TGM->sendMessage ($message); } @@ -48,7 +51,7 @@ sub redis_parse_message { }; sub redis_events_listener { - $log->notice ('[NOTICE]Run redis events listener'); + $log->notice ('[NOTICE] Run redis events listener'); # If we already connected there is no point to disconnect if (defined $main::REDIS) { my $connected = eval { Mojo::Redis::Connection->is_connected ($main::REDIS); }; diff --git a/lib/Teapot/Bot/Object/ChatPermissions.pm b/lib/Teapot/Bot/Object/ChatPermissions.pm index 88cce62..7002547 100644 --- a/lib/Teapot/Bot/Object/ChatPermissions.pm +++ b/lib/Teapot/Bot/Object/ChatPermissions.pm @@ -33,11 +33,12 @@ sub canTalk { my $self = shift; my $chatid = shift; + my $args->{chat_id} = $chatid; my $can_talk = 0; if ($chatid < 0) { # group chat - my $chatobj = Teapot::Bot::Brain->getChat ($self, { 'chat_id' => $chatid }); + my $chatobj = Teapot::Bot::Brain->getChat ($args); # on api error, keep silence if ($chatobj == 0 || $chatobj->{error}) { @@ -54,7 +55,8 @@ sub canTalk { } my $myid = $myObj->id; - my $me = Teapot::Bot::Brain->getChatMember ($self, { 'chat_id' => $chatid, 'user_id' => $myid }); + $args->{user_id} = $myid; + my $me = Teapot::Bot::Brain->getChatMember ($self, $args); # on api error, keep silence if ($me == 0 || $me->{error}) {