diff --git a/lib/BotLib.pm b/lib/BotLib.pm index 7e776a0..1b3375d 100644 --- a/lib/BotLib.pm +++ b/lib/BotLib.pm @@ -28,6 +28,7 @@ my $c = LoadConf (); my $csign = $c->{telegrambot}->{csign}; my $redismsg->{from} = 'telegram'; +$redismsg->{threadid} = ''; $redismsg->{plugin} = 'telegram'; $redismsg->{misc}->{answer} = 1; $redismsg->{misc}->{csign} = "$c->{telegrambot}->{csign}"; @@ -130,6 +131,15 @@ sub Command { } } + # Если тип группы supergroup, в ней могут быть треды, попробуем найти message_thread_id, если таковой есть + if ($msg->chat->type eq 'supergroup') { + if ($msg->can ('is_topic_message') && $msg->is_topic_message) { + if ($msg->can ('message_thread_id') && $msg->message_thread_id ne '') { + $rmsg->{threadid} = "$msg->message_thread_id"; + } + } + } + # Если соединения с редиской нету, ждём, пока оно появится. Своего рода костыль на всякий случай. { do { diff --git a/lib/RedisLib.pm b/lib/RedisLib.pm index ece7447..aad0bdc 100644 --- a/lib/RedisLib.pm +++ b/lib/RedisLib.pm @@ -51,6 +51,9 @@ sub redis_parse_message { } $message->{text} = "$m->{message}"; + if (defined ($m->{threadid}) && $m->{threadid} ne '') { + $message->{message_thread_id} = 0 + $m->{threadid}; + } my $can_talk = Teapot::Bot::Object::ChatPermissions->canTalk ($main::TGM, 0 + $m->{chatid}); diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index d6e3df8..855b8ab 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -29,7 +29,7 @@ use Teapot::Bot::Object::Chat (); use Teapot::Bot::Object::ChatMember (); use Teapot::Bot::Object::ChatInviteLink (); -$Teapot::Bot::Brain::VERSION = '0.023'; +$Teapot::Bot::Brain::VERSION = '0.024'; # base class for building telegram robots with Mojolicious has longpoll_time => 60; @@ -298,6 +298,10 @@ sub sendMessage { $send_args->{chat_id} = $args->{chat_id}; + if (defined $args->{message_thread_id}) { + $send_args->{message_thread_id} = $args->{message_thread_id}; + } + unless ($args->{text}) { cluck 'No text supplied in sendMessage()'; return {'error' => 1}; @@ -351,6 +355,10 @@ sub forwardMessage { $send_args->{chat_id} = $args->{chat_id}; + if (defined $args->{message_thread_id}) { + $send_args->{message_thread_id} = $args->{message_thread_id}; + } + unless ($args->{from_chat_id}) { cluck 'No from_chat_id supplied in forwardMessage()'; return {'error' => 1}; @@ -419,6 +427,10 @@ sub sendPhoto { my $args = shift || {}; my $send_args = {}; + if (defined $args->{message_thread_id}) { + $send_args->{message_thread_id} = $args->{message_thread_id}; + } + unless ($args->{chat_id}) { cluck 'No chat_id supplied to sendPhoto()'; return {'error' => 1}; @@ -755,7 +767,7 @@ Teapot::Bot::Brain - A base class to make your very own Telegram bot =head1 VERSION -version 0.023 +version 0.024 =head1 SYNOPSIS diff --git a/lib/Teapot/Bot/Object/Animation.pm b/lib/Teapot/Bot/Object/Animation.pm index ef94cb0..a688658 100644 --- a/lib/Teapot/Bot/Object/Animation.pm +++ b/lib/Teapot/Bot/Object/Animation.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize (); -$Teapot::Bot::Object::Animation::VERSION = '0.023'; +$Teapot::Bot::Object::Animation::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -43,7 +43,7 @@ Teapot::Bot::Object::Animation - The base class for Telegram message 'Animation' =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'Animation' type. diff --git a/lib/Teapot/Bot/Object/Audio.pm b/lib/Teapot/Bot/Object/Audio.pm index 094f99e..7965bcc 100644 --- a/lib/Teapot/Bot/Object/Audio.pm +++ b/lib/Teapot/Bot/Object/Audio.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Audio::VERSION = '0.023'; +$Teapot::Bot::Object::Audio::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -41,7 +41,7 @@ Teapot::Bot::Object::Audio - The base class for Telegram 'Audio' type objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Audio' type objects. diff --git a/lib/Teapot/Bot/Object/Base.pm b/lib/Teapot/Bot/Object/Base.pm index 1a93d52..dc45766 100644 --- a/lib/Teapot/Bot/Object/Base.pm +++ b/lib/Teapot/Bot/Object/Base.pm @@ -13,7 +13,7 @@ use List::Util qw/any/; use Mojo::Base -base; -$Teapot::Bot::Object::Base::VERSION = '0.023'; +$Teapot::Bot::Object::Base::VERSION = '0.024'; has '_brain'; # a reference to our brain @@ -187,7 +187,7 @@ Teapot::Bot::Object::Base - The base class for all Telegram::Bot::Object objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION diff --git a/lib/Teapot/Bot/Object/CallbackGame.pm b/lib/Teapot/Bot/Object/CallbackGame.pm index 0a4506f..5ae2c72 100644 --- a/lib/Teapot/Bot/Object/CallbackGame.pm +++ b/lib/Teapot/Bot/Object/CallbackGame.pm @@ -7,7 +7,7 @@ use 5.018; ## no critic (ProhibitImplicitImport) use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::CallbackGame::VERSION = '0.023'; +$Teapot::Bot::Object::CallbackGame::VERSION = '0.024'; # https://core.telegram.org/bots/api#callbackgame # "A placeholder, currently holds no information. Use BotFather to set up your game" @@ -30,7 +30,7 @@ Teapot::Bot::Object::CallbackGame - The base class for Telegram message 'Callbac =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'CallbackGame' type. diff --git a/lib/Teapot/Bot/Object/Chat.pm b/lib/Teapot/Bot/Object/Chat.pm index 34a761b..1a8c9e2 100644 --- a/lib/Teapot/Bot/Object/Chat.pm +++ b/lib/Teapot/Bot/Object/Chat.pm @@ -12,7 +12,7 @@ use Teapot::Bot::Object::Message (); use Teapot::Bot::Object::ChatPermissions (); use Teapot::Bot::Object::ChatLocation (); -$Teapot::Bot::Object::Chat::VERSION = '0.023'; +$Teapot::Bot::Object::Chat::VERSION = '0.024'; has 'id'; has 'type'; @@ -20,7 +20,12 @@ has 'title'; # Optional. has 'username'; # Optional. has 'first_name'; # Optional. has 'last_name'; # Optional. +has 'is_forum'; # Optional. True, if the supergroup chat is a forum (has topics enabled) has 'photo'; # Teapot::Bot::Object::ChatPhoto. Optional. Returned only in getChat. +has 'active_usernames'; # Optional. If non-empty, the list of all active chat usernames; for private chats, + # supergroups and channels. Returned only in getChat. +has 'emoji_status_custom_emoji_id'; # Optional. Custom emoji identifier of emoji status of the other party in a private + # chat. Returned only in getChat. has 'bio'; # Optional. Bio of the other party in a private chat. Returned only in getChat. has 'has_private_forwards'; # Optional. True, if privacy settings of the other party in the private chat allows to # use tg://user?id= links only in chats with the user. @@ -42,7 +47,8 @@ has 'location'; # Optional. Returned only in getChat. sub fields { return { - 'scalar' => [qw/id type title username first_name last_name bio + 'scalar' => [qw/id type title username first_name last_name is_forum + emoji_status_custom_emoji_id bio has_private_forwards description invite_link slow_mode_delay message_auto_delete_time has_protected_content sticker_set_name can_set_sticker_set linked_chat_id/], @@ -53,6 +59,9 @@ sub fields { }; } +sub arrays { + return qw/active_usernames/; +} sub is_user { return shift->id > 0; @@ -77,7 +86,7 @@ Teapot::Bot::Object::Chat - The base class for Telegram 'Chat' type objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Chat' type objects. diff --git a/lib/Teapot/Bot/Object/ChatInviteLink.pm b/lib/Teapot/Bot/Object/ChatInviteLink.pm index bfbce46..b129c86 100644 --- a/lib/Teapot/Bot/Object/ChatInviteLink.pm +++ b/lib/Teapot/Bot/Object/ChatInviteLink.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User (); -$Teapot::Bot::Object::ChatInviteLink::VERSION = '0.023'; +$Teapot::Bot::Object::ChatInviteLink::VERSION = '0.024'; has 'invite_link'; has 'creator'; @@ -44,7 +44,7 @@ Teapot::Bot::Object::ChatInviteLink - The base class for Telegram message 'ChatI =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'ChatInviteLink' type. diff --git a/lib/Teapot/Bot/Object/ChatLocation.pm b/lib/Teapot/Bot/Object/ChatLocation.pm index 3613b33..85e60f4 100644 --- a/lib/Teapot/Bot/Object/ChatLocation.pm +++ b/lib/Teapot/Bot/Object/ChatLocation.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::ChatLocation::VERSION = '0.023'; +$Teapot::Bot::Object::ChatLocation::VERSION = '0.024'; has 'location'; has 'address'; @@ -34,7 +34,7 @@ Teapot::Bot::Object::ChatLocation - The base class for Telegram message 'ChatLoc =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'ChatLocation' type. diff --git a/lib/Teapot/Bot/Object/ChatMember.pm b/lib/Teapot/Bot/Object/ChatMember.pm index e3db49a..6b4a025 100644 --- a/lib/Teapot/Bot/Object/ChatMember.pm +++ b/lib/Teapot/Bot/Object/ChatMember.pm @@ -12,7 +12,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User (); -$Teapot::Bot::Object::ChatMember::VERSION = '0.023'; +$Teapot::Bot::Object::ChatMember::VERSION = '0.024'; # ChatMemberOwner has 'user'; @@ -39,7 +39,8 @@ has 'can_promote_members'; # optional. Administrators only. has 'can_change_info'; # optional. Administrators and restricted only. has 'can_invite_users'; # optional. Administrators and restricted only. has 'can_pin_messages'; # optional. Administrators and restricted only. - +has 'can_manage_topics'; # Optional. True, if the user is allowed to create, rename, close, and reopen forum + # topics; supergroups only # ChatMemberMember # has 'status'; # has 'user'; @@ -57,6 +58,7 @@ has 'can_send_polls'; # optional. Restricted only. has 'can_send_other_messages'; # optional. Restricted only. has 'can_add_web_page_previews'; # optional. Restricted only. has 'until_date'; # optional. Restricted and kicked only. +# has 'can_manage_topics'; # ChatMemberLeft # has 'status'; @@ -73,7 +75,7 @@ sub fields { can_edit_messages can_delete_messages can_manage_voice_chats can_restrict_members can_promote_members can_change_info can_invite_users can_pin_messages is_member can_send_messages can_send_media_messages can_send_polls can_send_other_messages - can_add_web_page_previews until_date/], + can_add_web_page_previews until_date can_manage_topics/], 'Teapot::Bot::Object::User' => [qw/user/], }; } @@ -145,7 +147,7 @@ Teapot::Bot::Object::ChatMember - The base class for Telegram 'ChatMember' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'ChatMember' type objects. diff --git a/lib/Teapot/Bot/Object/ChatMemberUpdated.pm b/lib/Teapot/Bot/Object/ChatMemberUpdated.pm index 267324e..a37ffcf 100644 --- a/lib/Teapot/Bot/Object/ChatMemberUpdated.pm +++ b/lib/Teapot/Bot/Object/ChatMemberUpdated.pm @@ -13,7 +13,7 @@ use Teapot::Bot::Object::ChatMember (); use Teapot::Bot::Object::ChatInviteLink (); use Teapot::Bot::Object::Voice (); -$Teapot::Bot::Object::ChatMemberUpdated::VERSION = '0.023'; +$Teapot::Bot::Object::ChatMemberUpdated::VERSION = '0.024'; has 'chat'; has 'from'; @@ -50,7 +50,7 @@ Teapot::Bot::Object::ChatMemberUpdated - The base class for Telegram 'ChatMember =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'ChatMemberUpdated' type objects. diff --git a/lib/Teapot/Bot/Object/ChatPermissions.pm b/lib/Teapot/Bot/Object/ChatPermissions.pm index 8be62a5..e5fc72c 100644 --- a/lib/Teapot/Bot/Object/ChatPermissions.pm +++ b/lib/Teapot/Bot/Object/ChatPermissions.pm @@ -10,7 +10,7 @@ use Carp qw(carp); use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Brain (); -$Teapot::Bot::Object::ChatPermissions::VERSION = '0.023'; +$Teapot::Bot::Object::ChatPermissions::VERSION = '0.024'; # all fields are optional # N.B. Some of the fields "overlaps" other, so in order to guess valid set of permissions you should check all of them @@ -26,12 +26,14 @@ has 'can_change_info'; # True, if the user is allowed to change the ch # Ignored in public supergroups has 'can_invite_users'; # True, if the user is allowed to invite new users to the chat has 'can_pin_messages'; # True, if the user is allowed to pin messages. Ignored in public supergroups +has 'can_manage_topics'; # Optional. True, if the user is allowed to create forum topics. If omitted defaults to + # the value of can_pin_messages sub fields { return { 'scalar' => [qw/can_send_messages can_send_media_messages can_send_polls can_send_other_messages can_add_web_page_previews can_change_info - can_invite_users can_pin_messages/], + can_invite_users can_pin_messages can_manage_topics/], }; } @@ -98,7 +100,7 @@ Teapot::Bot::Object::ChatPermissions - The base class for Telegram 'ChatPermissi =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'ChatPermissions' type objects. diff --git a/lib/Teapot/Bot/Object/ChatPhoto.pm b/lib/Teapot/Bot/Object/ChatPhoto.pm index 15c6b59..c775cc7 100644 --- a/lib/Teapot/Bot/Object/ChatPhoto.pm +++ b/lib/Teapot/Bot/Object/ChatPhoto.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::ChatPhoto::VERSION = '0.023'; +$Teapot::Bot::Object::ChatPhoto::VERSION = '0.024'; has 'small_file_id'; has 'small_file_unique_id'; @@ -35,7 +35,7 @@ Teapot::Bot::Object::ChatPhoto - The base class for Telegram 'ChatPhoto' type ob =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'ChatPhoto' type objects. diff --git a/lib/Teapot/Bot/Object/Contact.pm b/lib/Teapot/Bot/Object/Contact.pm index a799006..9cbb12f 100644 --- a/lib/Teapot/Bot/Object/Contact.pm +++ b/lib/Teapot/Bot/Object/Contact.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Contact::VERSION = '0.023'; +$Teapot::Bot::Object::Contact::VERSION = '0.024'; has 'phone_number'; has 'first_name'; @@ -36,7 +36,7 @@ Teapot::Bot::Object::Contact - The base class for Telegram 'Contact' objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Contact' objects. diff --git a/lib/Teapot/Bot/Object/Dice.pm b/lib/Teapot/Bot/Object/Dice.pm index ad314ef..a40c490 100644 --- a/lib/Teapot/Bot/Object/Dice.pm +++ b/lib/Teapot/Bot/Object/Dice.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Dice::VERSION = '0.023'; +$Teapot::Bot::Object::Dice::VERSION = '0.024'; has 'emoji'; has 'value'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::Dice - The base class for Telegram message 'Dice' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'Dice' type. diff --git a/lib/Teapot/Bot/Object/Document.pm b/lib/Teapot/Bot/Object/Document.pm index 673115b..8bf8d95 100644 --- a/lib/Teapot/Bot/Object/Document.pm +++ b/lib/Teapot/Bot/Object/Document.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize (); -$Teapot::Bot::Object::Document::VERSION = '0.023'; +$Teapot::Bot::Object::Document::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -39,7 +39,7 @@ Teapot::Bot::Object::Document - The base class for Telegram 'Document' objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Document' objects. diff --git a/lib/Teapot/Bot/Object/EncryptedCredentials.pm b/lib/Teapot/Bot/Object/EncryptedCredentials.pm index 1f55272..3657443 100644 --- a/lib/Teapot/Bot/Object/EncryptedCredentials.pm +++ b/lib/Teapot/Bot/Object/EncryptedCredentials.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.023'; +$Teapot::Bot::Object::EncryptedCredentials::VERSION = '0.024'; has 'data'; has 'hash'; @@ -32,7 +32,7 @@ Teapot::Bot::Object::EncryptedCredentials - The base class for Telegram 'Encrypt =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'EncryptedCredentials' type objects. diff --git a/lib/Teapot/Bot/Object/EncryptedPassportElement.pm b/lib/Teapot/Bot/Object/EncryptedPassportElement.pm index a2ce017..5f881d9 100644 --- a/lib/Teapot/Bot/Object/EncryptedPassportElement.pm +++ b/lib/Teapot/Bot/Object/EncryptedPassportElement.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.023'; +$Teapot::Bot::Object::EncryptedPassportElement::VERSION = '0.024'; # XXX Implement rest of this # https://core.telegram.org/bots/api#encryptedpassportelement @@ -38,7 +38,7 @@ Teapot::Bot::Object::EncryptedPassportElement - The base class for Telegram 'Enc =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'EncryptedPassportElement' type objects. diff --git a/lib/Teapot/Bot/Object/ForumTopicClosed.pm b/lib/Teapot/Bot/Object/ForumTopicClosed.pm new file mode 100644 index 0000000..04efa9e --- /dev/null +++ b/lib/Teapot/Bot/Object/ForumTopicClosed.pm @@ -0,0 +1,51 @@ +package Teapot::Bot::Object::ForumTopicClosed; +# ABSTRACT: The base class for Telegram message 'ForumTopicClosed' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +$Teapot::Bot::Object::ForumTopicClosed::VERSION = '0.024'; + + +sub fields { + return { }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::ForumTopicClosed - The base class for Telegram message 'ForumTopicClosed' type + +=head1 VERSION + +version 0.024 + +=head1 DESCRIPTION +The base class for Telegram message 'ForumTopicClosed' type. + +See L for details of the +attributes available for C objects. + +=head1 AUTHOR + +Sergei Fedosov + +=head1 LICENSE AND COPYRIGHT + +This software is copyright (c) 2022 by Sergei Fedosov . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Teapot/Bot/Object/ForumTopicCreated.pm b/lib/Teapot/Bot/Object/ForumTopicCreated.pm new file mode 100644 index 0000000..f06c068 --- /dev/null +++ b/lib/Teapot/Bot/Object/ForumTopicCreated.pm @@ -0,0 +1,54 @@ +package Teapot::Bot::Object::ForumTopicCreated; +# ABSTRACT: The base class for Telegram message 'ForumTopicCreated' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +$Teapot::Bot::Object::ForumTopicCreated::VERSION = '0.024'; + +has 'name'; +has 'icon_color'; +has 'icon_custom_emoji_id'; + +sub fields { + return { scalar => [qw/name icon_color icon_custom_emoji_id/] }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::ForumTopicCreated - The base class for Telegram message 'ForumTopicCreated' type + +=head1 VERSION + +version 0.024 + +=head1 DESCRIPTION +The base class for Telegram message 'ForumTopicCreated' type. + +See L for details of the +attributes available for C objects. + +=head1 AUTHOR + +Sergei Fedosov + +=head1 LICENSE AND COPYRIGHT + +This software is copyright (c) 2022 by Sergei Fedosov . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Teapot/Bot/Object/ForumTopicReopened.pm b/lib/Teapot/Bot/Object/ForumTopicReopened.pm new file mode 100644 index 0000000..5001e05 --- /dev/null +++ b/lib/Teapot/Bot/Object/ForumTopicReopened.pm @@ -0,0 +1,51 @@ +package Teapot::Bot::Object::ForumTopicReopened; +# ABSTRACT: The base class for Telegram message 'ForumTopicReopened' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +$Teapot::Bot::Object::ForumTopicReopened::VERSION = '0.024'; + + +sub fields { + return { }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::ForumTopicReopened - The base class for Telegram message 'ForumTopicReopened' type + +=head1 VERSION + +version 0.024 + +=head1 DESCRIPTION +The base class for Telegram message 'ForumTopicReopened' type. + +See L for details of the +attributes available for C objects. + +=head1 AUTHOR + +Sergei Fedosov + +=head1 LICENSE AND COPYRIGHT + +This software is copyright (c) 2022 by Sergei Fedosov . + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut diff --git a/lib/Teapot/Bot/Object/Game.pm b/lib/Teapot/Bot/Object/Game.pm index d4cca57..140dab5 100644 --- a/lib/Teapot/Bot/Object/Game.pm +++ b/lib/Teapot/Bot/Object/Game.pm @@ -11,7 +11,7 @@ use Teapot::Bot::Object::PhotoSize (); use Teapot::Bot::Object::Animation (); use Teapot::Bot::Object::MessageEntity (); -$Teapot::Bot::Object::Game::VERSION = '0.023'; +$Teapot::Bot::Object::Game::VERSION = '0.024'; has 'title'; has 'description'; @@ -45,7 +45,7 @@ Teapot::Bot::Object::Game - The base class for Telegram message 'Game' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'Game' type. diff --git a/lib/Teapot/Bot/Object/InlineKeyboardButton.pm b/lib/Teapot/Bot/Object/InlineKeyboardButton.pm index 211db6c..7134797 100644 --- a/lib/Teapot/Bot/Object/InlineKeyboardButton.pm +++ b/lib/Teapot/Bot/Object/InlineKeyboardButton.pm @@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::LoginUrl (); use Teapot::Bot::Object::CallbackGame (); -$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.023'; +$Teapot::Bot::Object::InlineKeyboardButton::VERSION = '0.024'; has 'text'; has 'url'; @@ -43,7 +43,7 @@ Teapot::Bot::Object::InlineKeyboardButton - The base class for Telegram 'InlineK =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'InlineKeyboardButton' type objects. diff --git a/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm b/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm index 11dc1e4..a2cf5d3 100644 --- a/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm +++ b/lib/Teapot/Bot/Object/InlineKeyboardMarkup.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::InlineKeyboardButton (); -$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.023'; +$Teapot::Bot::Object::InlineKeyboardMarkup::VERSION = '0.024'; has 'inline_keyboard'; @@ -35,7 +35,7 @@ Teapot::Bot::Object::InlineKeyboardMarkup - The base class for Telegram 'InlineK =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'InlineKeyboardMarkup' type objects. diff --git a/lib/Teapot/Bot/Object/Invoice.pm b/lib/Teapot/Bot/Object/Invoice.pm index e2f7bd4..9848ed5 100644 --- a/lib/Teapot/Bot/Object/Invoice.pm +++ b/lib/Teapot/Bot/Object/Invoice.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Invoice::VERSION = '0.023'; +$Teapot::Bot::Object::Invoice::VERSION = '0.024'; has 'title'; has 'description'; @@ -34,7 +34,7 @@ Teapot::Bot::Object::Invoice - The base class for Telegram 'Invoice' type object =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Invoice' type objects. diff --git a/lib/Teapot/Bot/Object/Location.pm b/lib/Teapot/Bot/Object/Location.pm index 10b8fcd..35d1f22 100644 --- a/lib/Teapot/Bot/Object/Location.pm +++ b/lib/Teapot/Bot/Object/Location.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Location::VERSION = '0.023'; +$Teapot::Bot::Object::Location::VERSION = '0.024'; has 'longitude'; has 'latitude'; @@ -35,7 +35,7 @@ Teapot::Bot::Object::Location - The base class for Telegram message 'Location' t =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'Location' type. diff --git a/lib/Teapot/Bot/Object/LoginUrl.pm b/lib/Teapot/Bot/Object/LoginUrl.pm index ac170be..d61425b 100644 --- a/lib/Teapot/Bot/Object/LoginUrl.pm +++ b/lib/Teapot/Bot/Object/LoginUrl.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::LoginUrl::VERSION = '0.023'; +$Teapot::Bot::Object::LoginUrl::VERSION = '0.024'; has 'url'; has 'forward_text'; @@ -33,7 +33,7 @@ Teapot::Bot::Object::LoginUrl - The base class for Telegram 'LoginUrl' type obje =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'LoginUrl' type objects. diff --git a/lib/Teapot/Bot/Object/MaskPosition.pm b/lib/Teapot/Bot/Object/MaskPosition.pm index e3d381e..19ec37d 100644 --- a/lib/Teapot/Bot/Object/MaskPosition.pm +++ b/lib/Teapot/Bot/Object/MaskPosition.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::MaskPosition::VERSION = '0.023'; +$Teapot::Bot::Object::MaskPosition::VERSION = '0.024'; has 'point'; has 'x_shift'; @@ -33,7 +33,7 @@ Teapot::Bot::Object::MaskPosition - The base class for Telegram 'MaskPosition' t =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'MaskPosition' type objects. diff --git a/lib/Teapot/Bot/Object/Message.pm b/lib/Teapot/Bot/Object/Message.pm index e522a4d..28dc6ac 100644 --- a/lib/Teapot/Bot/Object/Message.pm +++ b/lib/Teapot/Bot/Object/Message.pm @@ -40,10 +40,12 @@ use Teapot::Bot::Object::VideoChatStarted (); use Teapot::Bot::Object::VideoChatEnded (); use Teapot::Bot::Object::VideoChatParticipantsInvited (); -$Teapot::Bot::Object::Message::VERSION = '0.023'; +$Teapot::Bot::Object::Message::VERSION = '0.024'; # basic message stuff has 'message_id'; +has 'message_thread_id'; # Optional. Unique identifier of a message thread to which the message belongs; + # for supergroups only has 'from'; # User has 'sender_chat'; # Chat has 'date'; @@ -54,6 +56,7 @@ has 'forward_from_message_id'; has 'forward_signature'; has 'forward_sender_name'; has 'forward_date'; +has 'is_topic_message'; # Optional. True, if the message is sent to a forum topic has 'is_automatic_forward'; has 'reply_to_message'; # Message has 'via_bot'; # User @@ -96,6 +99,9 @@ has 'successful_payment'; # SuccessfulPayment has 'connected_website'; has 'passport_data'; # PassportData has 'proximity_alert_triggered'; +has 'forum_topic_created'; # ForumTopicCreated +has 'forum_topic_closed'; # ForumTopicClosed +has 'forum_topic_reopened'; # ForumTopicReopened has 'video_chat_scheduled'; has 'video_chat_started'; has 'video_chat_ended'; @@ -105,11 +111,11 @@ has 'reply_markup'; # Array of InlineKeyboardMarkup sub fields { return { - 'scalar' => [qw/message_id date forward_from_message_id - forward_signature forward_sender_name - forward_date is_automatic_forward edit_date has_protected_content - media_group_id author_signature text caption - new_chat_title delete_chat_photo + 'scalar' => [qw/message_id message_thread_id date forward_from_message_id + forward_signature forward_sender_name forward_date + is_topic_message is_automatic_forward edit_date + has_protected_content media_group_id author_signature text + caption new_chat_title delete_chat_photo group_chat_created supergroup_chat_created channel_chat_created migrate_to_chat_id migrate_from_chat_id connected_website/], @@ -138,6 +144,9 @@ sub fields { 'Teapot::Bot::Object::Invoice' => [qw/invoice/], 'Teapot::Bot::Object::SuccessfulPayment' => [qw/successful_payment/], 'Teapot::Bot::Object::PassportData' => [qw/passport_data/], + 'Teapot::Bot::Object::ForumTopicCreated' => [qw/forum_topic_created/], + 'Teapot::Bot::Object::ForumTopicClosed' => [qw/forum_topic_closed/], + 'Teapot::Bot::Object::ForumTopicReopened' => [qw/forum_topic_reopened/], 'Teapot::Bot::Object::InlineKeyboardMarkup' => [qw/reply_markup/], 'Teapot::Bot::Object::ProximityAlertTriggered' => [qw/proximity_alert_triggered/], 'Teapot::Bot::Object::Dice' => [qw/dice/], @@ -160,9 +169,14 @@ sub reply { my $text = shift; my $chatid = $self->chat->id; + my $message_thread_id = eval {$self->message_thread_id}; if (Teapot::Bot::Object::ChatPermissions->canTalk($self, $chatid)) { - return $self->_brain->sendMessage({chat_id => $chatid, text => $text}); + if (defined $message_thread_id && $message_thread_id ne '') { + return $self->_brain->sendMessage({chat_id => $chatid, message_thread_id => $message_thread_id, text => $text}); + } else { + return $self->_brain->sendMessage({chat_id => $chatid, text => $text}); + } } return {'error' => 1}; @@ -173,13 +187,14 @@ sub replyMd { my $text = shift; my $chatid = $self->chat->id; + my $message_thread_id = eval {$self->message_thread_id}; if (Teapot::Bot::Object::ChatPermissions->canTalk ($self, $chatid)) { my $send_args; - $send_args->{text} = $text; - $send_args->{parse_mode} = 'Markdown'; - $send_args->{chat_id} = $chatid; - + $send_args->{text} = $text; + $send_args->{parse_mode} = 'Markdown'; + $send_args->{chat_id} = $chatid; + $send_args->{message_thread_id} = $message_thread_id if (defined $message_thread_id); return $self->_brain->sendMessage($send_args); } @@ -212,7 +227,7 @@ Teapot::Bot::Object::Message - The base class for the Telegram type "Message" =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for the Telegram type "Message". diff --git a/lib/Teapot/Bot/Object/MessageAutoDeleteTimerChanged.pm b/lib/Teapot/Bot/Object/MessageAutoDeleteTimerChanged.pm index c3283c5..541cd6f 100644 --- a/lib/Teapot/Bot/Object/MessageAutoDeleteTimerChanged.pm +++ b/lib/Teapot/Bot/Object/MessageAutoDeleteTimerChanged.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::MessageAutoDeleteTimerChanged::VERSION = '0.023'; +$Teapot::Bot::Object::MessageAutoDeleteTimerChanged::VERSION = '0.024'; has 'message_auto_delete_time'; @@ -32,7 +32,7 @@ Teapot::Bot::Object::MessageAutoDeleteTimerChanged - The base class for Telegram =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'MessageAutoDeleteTimerChanged' type objects. diff --git a/lib/Teapot/Bot/Object/MessageEntity.pm b/lib/Teapot/Bot/Object/MessageEntity.pm index fec3bc8..264588f 100644 --- a/lib/Teapot/Bot/Object/MessageEntity.pm +++ b/lib/Teapot/Bot/Object/MessageEntity.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User (); -$Teapot::Bot::Object::MessageEntity::VERSION = '0.023'; +$Teapot::Bot::Object::MessageEntity::VERSION = '0.024'; has 'type'; has 'offset'; @@ -39,7 +39,7 @@ Teapot::Bot::Object::MessageEntity - The base class for Telegram 'MessageEntity' =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'MessageEntity' type objects. diff --git a/lib/Teapot/Bot/Object/PassportData.pm b/lib/Teapot/Bot/Object/PassportData.pm index 430ac05..89896db 100644 --- a/lib/Teapot/Bot/Object/PassportData.pm +++ b/lib/Teapot/Bot/Object/PassportData.pm @@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::EncryptedPassportElement (); use Teapot::Bot::Object::EncryptedCredentials (); -$Teapot::Bot::Object::PassportData::VERSION = '0.023'; +$Teapot::Bot::Object::PassportData::VERSION = '0.024'; has 'data'; # Array of EncryptedPassportElement has 'credentials'; # EncryptedCredentials @@ -40,7 +40,7 @@ Teapot::Bot::Object::PassportData - The base class for Telegram 'PassportData' t =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'PassportData' type objects. diff --git a/lib/Teapot/Bot/Object/PhotoSize.pm b/lib/Teapot/Bot/Object/PhotoSize.pm index de5988c..7768d50 100644 --- a/lib/Teapot/Bot/Object/PhotoSize.pm +++ b/lib/Teapot/Bot/Object/PhotoSize.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::PhotoSize::VERSION = '0.023'; +$Teapot::Bot::Object::PhotoSize::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -34,7 +34,7 @@ Teapot::Bot::Object::PhotoSize - The base class for Telegram message 'PhotoSize' =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'PhotoSize' type. diff --git a/lib/Teapot/Bot/Object/Poll.pm b/lib/Teapot/Bot/Object/Poll.pm index 4419bbc..468f1a7 100644 --- a/lib/Teapot/Bot/Object/Poll.pm +++ b/lib/Teapot/Bot/Object/Poll.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PollOption (); -$Teapot::Bot::Object::Poll::VERSION = '0.023'; +$Teapot::Bot::Object::Poll::VERSION = '0.024'; has 'id'; has 'question'; @@ -52,7 +52,7 @@ Teapot::Bot::Object::Poll - The base class for Telegram 'Poll' type objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Poll' type objects diff --git a/lib/Teapot/Bot/Object/PollAnswer.pm b/lib/Teapot/Bot/Object/PollAnswer.pm index 5182193..3657aec 100644 --- a/lib/Teapot/Bot/Object/PollAnswer.pm +++ b/lib/Teapot/Bot/Object/PollAnswer.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::PollAnswer::VERSION = '0.023'; +$Teapot::Bot::Object::PollAnswer::VERSION = '0.024'; has 'poll_id'; has 'user'; @@ -39,7 +39,7 @@ Teapot::Bot::Object::PollAnswer - The base class for Telegram 'PollAnswer' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'PollAnswer' type objects. diff --git a/lib/Teapot/Bot/Object/PollOption.pm b/lib/Teapot/Bot/Object/PollOption.pm index 802e442..0904157 100644 --- a/lib/Teapot/Bot/Object/PollOption.pm +++ b/lib/Teapot/Bot/Object/PollOption.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::PollOption::VERSION = '0.023'; +$Teapot::Bot::Object::PollOption::VERSION = '0.024'; has 'text'; has 'voter_count'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::PollOption - The base class for Telegram 'PollOption' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'PollOption' type objects. diff --git a/lib/Teapot/Bot/Object/ProximityAlertTriggered.pm b/lib/Teapot/Bot/Object/ProximityAlertTriggered.pm index 62a0cb5..da2800b 100644 --- a/lib/Teapot/Bot/Object/ProximityAlertTriggered.pm +++ b/lib/Teapot/Bot/Object/ProximityAlertTriggered.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::ProximityAlertTriggered::VERSION = '0.023'; +$Teapot::Bot::Object::ProximityAlertTriggered::VERSION = '0.024'; has 'traveler'; # User has 'watcher'; # User @@ -35,7 +35,7 @@ Teapot::Bot::Object::ProximityAlertTriggered - The base class for Telegram messa =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'ProximityAlertTriggered' type. diff --git a/lib/Teapot/Bot/Object/Sticker.pm b/lib/Teapot/Bot/Object/Sticker.pm index 2fd1455..6db3581 100644 --- a/lib/Teapot/Bot/Object/Sticker.pm +++ b/lib/Teapot/Bot/Object/Sticker.pm @@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize (); use Teapot::Bot::Object::MaskPosition (); -$Teapot::Bot::Object::Sticker::VERSION = '0.023'; +$Teapot::Bot::Object::Sticker::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -46,7 +46,7 @@ Teapot::Bot::Object::Sticker - The base class for Telegram message 'Sticker' typ =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'Sticker' type. diff --git a/lib/Teapot/Bot/Object/SuccessfulPayment.pm b/lib/Teapot/Bot/Object/SuccessfulPayment.pm index c1e44c7..bc82d90 100644 --- a/lib/Teapot/Bot/Object/SuccessfulPayment.pm +++ b/lib/Teapot/Bot/Object/SuccessfulPayment.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; # use Teapot::Bot::Object::OrderInfo; -$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.023'; +$Teapot::Bot::Object::SuccessfulPayment::VERSION = '0.024'; has 'currency'; has 'total_amount'; @@ -41,7 +41,7 @@ Teapot::Bot::Object::SuccessfulPayment - The base class for Telegram 'Successful =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'SuccessfulPayment' type objects. diff --git a/lib/Teapot/Bot/Object/User.pm b/lib/Teapot/Bot/Object/User.pm index 5eac8ff..ba81684 100644 --- a/lib/Teapot/Bot/Object/User.pm +++ b/lib/Teapot/Bot/Object/User.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::User::VERSION = '0.023'; +$Teapot::Bot::Object::User::VERSION = '0.024'; has 'id'; has 'is_bot'; @@ -41,7 +41,7 @@ Teapot::Bot::Object::User - The base class for Telegram message 'User' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'User' type. diff --git a/lib/Teapot/Bot/Object/Venue.pm b/lib/Teapot/Bot/Object/Venue.pm index 2390503..f771163 100644 --- a/lib/Teapot/Bot/Object/Venue.pm +++ b/lib/Teapot/Bot/Object/Venue.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::Location (); -$Teapot::Bot::Object::Venue::VERSION = '0.023'; +$Teapot::Bot::Object::Venue::VERSION = '0.024'; has 'location'; #Location has 'title'; @@ -41,7 +41,7 @@ Teapot::Bot::Object::Venue - The base class for Telegram 'LoginUrl' type objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'LoginUrl' type objects. diff --git a/lib/Teapot/Bot/Object/Video.pm b/lib/Teapot/Bot/Object/Video.pm index 20127fa..ddafc7d 100644 --- a/lib/Teapot/Bot/Object/Video.pm +++ b/lib/Teapot/Bot/Object/Video.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize (); -$Teapot::Bot::Object::Video::VERSION = '0.023'; +$Teapot::Bot::Object::Video::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -43,7 +43,7 @@ Teapot::Bot::Object::Video - The base class for Telegram 'Video' object =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Video' object. diff --git a/lib/Teapot/Bot/Object/VideoChatEnded.pm b/lib/Teapot/Bot/Object/VideoChatEnded.pm index e191273..12f5432 100644 --- a/lib/Teapot/Bot/Object/VideoChatEnded.pm +++ b/lib/Teapot/Bot/Object/VideoChatEnded.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::VideoChatEnded::VERSION = '0.023'; +$Teapot::Bot::Object::VideoChatEnded::VERSION = '0.024'; # This object represents a service message about a Video chat started in the chat. Currently holds no information. has 'duration'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatEnded - The base class for Telegram message 'Video =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'VideoChatEnded' type. diff --git a/lib/Teapot/Bot/Object/VideoChatParticipantsInvited.pm b/lib/Teapot/Bot/Object/VideoChatParticipantsInvited.pm index 8d904a4..ee527e1 100644 --- a/lib/Teapot/Bot/Object/VideoChatParticipantsInvited.pm +++ b/lib/Teapot/Bot/Object/VideoChatParticipantsInvited.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::User (); -$Teapot::Bot::Object::VideoChatParticipantsInvited::VERSION = '0.023'; +$Teapot::Bot::Object::VideoChatParticipantsInvited::VERSION = '0.024'; # This object represents a service message about a Video chat started in the chat. Currently holds no information. has 'users'; @@ -36,7 +36,7 @@ Teapot::Bot::Object::VideoChatParticipantsInvited - The base class for Telegram =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'VideoChatParticipantsInvited' type. diff --git a/lib/Teapot/Bot/Object/VideoChatScheduled.pm b/lib/Teapot/Bot/Object/VideoChatScheduled.pm index b6e2e8f..b45c8bf 100644 --- a/lib/Teapot/Bot/Object/VideoChatScheduled.pm +++ b/lib/Teapot/Bot/Object/VideoChatScheduled.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::VideoChatScheduled::VERSION = '0.023'; +$Teapot::Bot::Object::VideoChatScheduled::VERSION = '0.024'; # This object represents a service message about a video chat started in the chat. Currently holds no information. has 'start_date'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatScheduled - The base class for Telegram message 'V =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'VideoChatScheduled' type. diff --git a/lib/Teapot/Bot/Object/VideoChatStarted.pm b/lib/Teapot/Bot/Object/VideoChatStarted.pm index f19da4c..f16d9eb 100644 --- a/lib/Teapot/Bot/Object/VideoChatStarted.pm +++ b/lib/Teapot/Bot/Object/VideoChatStarted.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::VideoChatStarted::VERSION = '0.023'; +$Teapot::Bot::Object::VideoChatStarted::VERSION = '0.024'; # This object represents a service message about a Video chat started in the chat. Currently holds no information. has 'stub'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::VideoChatStarted - The base class for Telegram message 'Vid =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram message 'VideoChatStarted' type. diff --git a/lib/Teapot/Bot/Object/VideoNote.pm b/lib/Teapot/Bot/Object/VideoNote.pm index c6834f5..3e0da1d 100644 --- a/lib/Teapot/Bot/Object/VideoNote.pm +++ b/lib/Teapot/Bot/Object/VideoNote.pm @@ -9,7 +9,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; use Teapot::Bot::Object::PhotoSize (); -$Teapot::Bot::Object::VideoNote::VERSION = '0.023'; +$Teapot::Bot::Object::VideoNote::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -40,7 +40,7 @@ Teapot::Bot::Object::VideoNote - The base class for Telegram 'VideoNote' type ob =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'VideoNote' type object. diff --git a/lib/Teapot/Bot/Object/Voice.pm b/lib/Teapot/Bot/Object/Voice.pm index 6f79880..90aac6a 100644 --- a/lib/Teapot/Bot/Object/Voice.pm +++ b/lib/Teapot/Bot/Object/Voice.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::Voice::VERSION = '0.023'; +$Teapot::Bot::Object::Voice::VERSION = '0.024'; has 'file_id'; has 'file_unique_id'; @@ -34,7 +34,7 @@ Teapot::Bot::Object::Voice - The base class for Telegram 'Voice' type objects =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'Voice' type objects. diff --git a/lib/Teapot/Bot/Object/WebAppData.pm b/lib/Teapot/Bot/Object/WebAppData.pm index fac4ba1..7eb3e42 100644 --- a/lib/Teapot/Bot/Object/WebAppData.pm +++ b/lib/Teapot/Bot/Object/WebAppData.pm @@ -8,7 +8,7 @@ use utf8; use Mojo::Base 'Teapot::Bot::Object::Base'; -$Teapot::Bot::Object::WebAppData::VERSION = '0.023'; +$Teapot::Bot::Object::WebAppData::VERSION = '0.024'; has 'data'; has 'button_text'; @@ -31,7 +31,7 @@ Teapot::Bot::Object::WebAppData - The base class for Telegram 'WebAppData' type =head1 VERSION -version 0.023 +version 0.024 =head1 DESCRIPTION The base class for Telegram 'WebAppData' type objects. diff --git a/lib/TelegramBot.pm b/lib/TelegramBot.pm index 9edda61..ad387b4 100644 --- a/lib/TelegramBot.pm +++ b/lib/TelegramBot.pm @@ -42,6 +42,7 @@ my @introduce_greet = ( ); my $redismsg->{from} = 'telegram'; +$redismsg->{threadid} = ''; $redismsg->{plugin} = 'telegram'; $redismsg->{misc}->{answer} = 1; $redismsg->{misc}->{csign} = "$c->{telegrambot}->{csign}"; @@ -362,6 +363,15 @@ sub __on_msg { $rmsg->{chatid} = "$chatid"; $rmsg->{misc}->{answer} = 1; + # Если тип группы supergroup, в ней могут быть треды, попробуем найти message_thread_id, если таковой есть + if ($msg->chat->type eq 'supergroup') { + if ($msg->can ('is_topic_message') && $msg->is_topic_message) { + if ($msg->can ('message_thread_id') && $msg->message_thread_id ne '') { + $rmsg->{threadid} = "$msg->message_thread_id"; + } + } + } + { do { my $ready = eval { $main::RCONN->is_connected; }; @@ -402,6 +412,15 @@ sub __on_msg { $rmsg->{chatid} = "$chatid"; $rmsg->{misc}->{answer} = 1; + # Если тип группы supergroup, в ней могут быть треды, попробуем найти message_thread_id, если таковой есть + if ($msg->chat->type eq 'supergroup') { + if ($msg->can ('is_topic_message') && $msg->is_topic_message) { + if ($msg->can ('message_thread_id') && $msg->message_thread_id ne '') { + $rmsg->{threadid} = "$msg->message_thread_id"; + } + } + } + # Сообщение обращено к боту if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){ $phrase = $1; @@ -454,10 +473,20 @@ sub __on_msg { $msg->typing (); sleep (irand 2); - $log->debug (sprintf ('[DEBUG] In public chat %s (%s) bot reply to %s: %s', $chatname, $chatid, $vis_a_vi, $reply)); + $log->debug ( + sprintf ( + '[DEBUG] In public chat %s (%s) bot reply to %s: %s', + $chatname, $chatid, $vis_a_vi, $reply, + ) + ); $msg->reply ($reply); } else { - $log->debug (sprintf ('[DEBUG] In public chat %s (%s) bot is not required to reply to %s', $chatname, $chatid, $vis_a_vi)); + $log->debug ( + sprintf ( + '[DEBUG] In public chat %s (%s) bot is not required to reply to %s', + $chatname, $chatid, $vis_a_vi, + ) + ); } # should be channel, so we can't talk