From d21bab68ef0d5328e9120453965003ccdb67d10e Mon Sep 17 00:00:00 2001 From: eleksir Date: Thu, 8 May 2025 15:49:25 +0300 Subject: [PATCH] Make proper use of Reaction stuff in Teapot lib --- lib/Teapot/Bot/Object/MessageReaction.pm | 1 - lib/Teapot/Bot/Object/MessageReactionCount.pm | 58 ++++++++++++++++ .../Bot/Object/MessageReactionCountUpdated.pm | 61 +++++++++++++++++ .../Bot/Object/MessageReactionUpdated.pm | 67 +++++++++++++++++++ 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 lib/Teapot/Bot/Object/MessageReactionCount.pm create mode 100644 lib/Teapot/Bot/Object/MessageReactionCountUpdated.pm create mode 100644 lib/Teapot/Bot/Object/MessageReactionUpdated.pm diff --git a/lib/Teapot/Bot/Object/MessageReaction.pm b/lib/Teapot/Bot/Object/MessageReaction.pm index 6aab71f..5c6e3fa 100644 --- a/lib/Teapot/Bot/Object/MessageReaction.pm +++ b/lib/Teapot/Bot/Object/MessageReaction.pm @@ -17,7 +17,6 @@ has 'emoji'; # Reaction emoji. Currently, it can be one of "👍", " # "🎃", "🙈", "😇", "ðŸ˜Ļ", "ðŸĪ", "✍", "ðŸĪ—", "ðŸŦĄ", "🎅", "🎄", "☃", "💅", "ðŸĪŠ", "ðŸ—ŋ", "🆒", "💘", "🙉", "ðŸĶ„", "😘", # "💊", "🙊", "😎", "ðŸ‘ū", "ðŸĪ·â€â™‚", "ðŸĪ·", "ðŸĪ·â€â™€", "ðŸ˜Ą" has 'custom_emoji_id'; # Only for ReactionTypeCustomEmoji. Custom emoji identifier. -has 'total_count'; # Only for ReactionCount. Number of times the reaction was added. sub fields { return { diff --git a/lib/Teapot/Bot/Object/MessageReactionCount.pm b/lib/Teapot/Bot/Object/MessageReactionCount.pm new file mode 100644 index 0000000..2e1c795 --- /dev/null +++ b/lib/Teapot/Bot/Object/MessageReactionCount.pm @@ -0,0 +1,58 @@ +package Teapot::Bot::Object::MessageReactionCount; +# ABSTRACT: The base class for Telegram message 'Reaction' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +use Teapot::Bot::Object::MessageReaction (); + +$Teapot::Bot::Object::MessageReactionCount::VERSION = '0.026'; + +has 'type'; # Type of the reaction +has 'total_count'; # Number of times the reaction was added + +sub fields { + return { + 'Teapot::Bot::Object::MessageReaction' => [qw/type/], + 'scalar' => [qw/total_count/], + }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::MessageReactionCount - The base class for Telegram message 'Reaction' type + +=head1 VERSION + +version 0.026 + +=head1 DESCRIPTION +The base class for Telegram message 'Reaction' 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) 2025 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/MessageReactionCountUpdated.pm b/lib/Teapot/Bot/Object/MessageReactionCountUpdated.pm new file mode 100644 index 0000000..0f881ce --- /dev/null +++ b/lib/Teapot/Bot/Object/MessageReactionCountUpdated.pm @@ -0,0 +1,61 @@ +package Teapot::Bot::Object::MessageReactionCountUpdated; +# ABSTRACT: The base class for Telegram message 'Reaction' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +use Teapot::Bot::Object::MessageReactionCount (); + +$Teapot::Bot::Object::MessageReactionCountUpdated::VERSION = '0.026'; + +has 'chat'; +has 'message_id'; +has 'date'; +has 'reactions'; + +sub fields { + return { + 'Teapot::Bot::Object::Chat' => [qw/chat actor_chat/], + 'Teapot::Bot::Object::MessageReactionCount' => [qw/reactions/], + 'scalar' => [qw/message_id date/], + }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::MessageReactionCountUpdated - The base class for Telegram message 'Reaction' type + +=head1 VERSION + +version 0.026 + +=head1 DESCRIPTION +The base class for Telegram message 'Reaction' 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) 2025 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/MessageReactionUpdated.pm b/lib/Teapot/Bot/Object/MessageReactionUpdated.pm new file mode 100644 index 0000000..b938f2a --- /dev/null +++ b/lib/Teapot/Bot/Object/MessageReactionUpdated.pm @@ -0,0 +1,67 @@ +package Teapot::Bot::Object::MessageReactionUpdated; +# ABSTRACT: The base class for Telegram message 'ReactionUpdated' type. + +use strict; +use warnings; +use 5.018; ## no critic (ProhibitImplicitImport) +use utf8; + +use Mojo::Base 'Teapot::Bot::Object::Base'; + +use Teapot::Bot::Object::Chat (); +use Teapot::Bot::Object::Chat (); +use Teapot::Bot::Object::User (); + +$Teapot::Bot::Object::MessageReactionUpdated::VERSION = '0.026'; + +has 'chat'; # The chat containing the message the user reacted to +has 'message_id'; # Unique identifier of the message inside the chat +has 'user'; # Optional. The user that changed the reaction, if the user isn't anonymous +has 'actor_chat'; # Optional. The chat on behalf of which the reaction was changed, if the user is anonymous +has 'date'; # Date of the change in Unix time +has 'old_reaction'; # Previous list of reaction types that were set by the user +has 'new_reaction'; # New list of reaction types that have been set by the user + +sub fields { + return { + 'Teapot::Bot::Object::Chat' => [qw/chat actor_chat/], + 'Teapot::Bot::Object::User' => [qw/user/], + 'Teapot::Bot::Object::MessageReaction' => [qw/old_reaction new_reaction/], + 'scalar' => [qw/message_id date/], + }; +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +Teapot::Bot::Object::MessageReaction - The base class for Telegram message 'ReactionUpdated' type + +=head1 VERSION + +version 0.026 + +=head1 DESCRIPTION +The base class for Telegram message 'ReactionUpdated' 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) 2025 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