Add quirk for api incosistency in reactions

This commit is contained in:
eleksir
2025-05-08 17:01:15 +03:00
parent d21bab68ef
commit 6e76d85899
3 changed files with 43 additions and 24 deletions

View File

@@ -89,6 +89,7 @@ sub Highlight {
return ($userid, $username, $fullname, $highlight, undef);
}
if ($msg->can ('from')) {
$userid = $msg->from->id;
if ($msg->from->can ('username') && defined $msg->from->username ) {
@@ -104,6 +105,24 @@ sub Highlight {
} elsif ($msg->from->can ('last_name') && defined $msg->from->last_name) {
$fullname .= $msg->from->last_name;
}
} else {
# Reacions case.
$userid = $msg->user->id;
if ($msg->user->can ('username') && defined $msg->user->username ) {
$username = $msg->user->username;
}
if ($msg->user->can ('first_name') && defined $msg->user->first_name) {
$fullname = $msg->user->first_name;
if ($msg->user->can ('last_name') && defined $msg->user->last_name) {
$fullname .= ' ' . $msg->user->last_name;
}
} elsif ($msg->user->can ('last_name') && defined $msg->user->last_name) {
$fullname .= $msg->user->last_name;
}
}
if (defined $username) {
$visavi .= '@' . $username;

View File

@@ -33,7 +33,7 @@ use Teapot::Bot::Object::User ();
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::ChatMember ();
use Teapot::Bot::Object::ChatInviteLink ();
use Teapot::Bot::Object::MessageReaction ();
use Teapot::Bot::Object::MessageReactionUpdated ();
$Teapot::Bot::Brain::VERSION = '0.026';
@@ -939,7 +939,7 @@ sub _process_message {
$update = Teapot::Bot::Object::PollAnswer->create_from_hash($item->{poll_answer}, $self) if $item->{poll_answer};
$update = Teapot::Bot::Object::ChatMemberUpdated->create_from_hash($item->{my_chat_member}, $self) if $item->{my_chat_member};
$update = Teapot::Bot::Object::ChatMemberUpdated->create_from_hash($item->{chat_member}, $self) if $item->{chat_member};
$update = Teapot::Bot::Object::MessageReaction->create_from_hash($item->{message_reaction}, $self) if $item->{message_reaction};
$update = Teapot::Bot::Object::MessageReactionUpdated->create_from_hash($item->{message_reaction}, $self) if $item->{message_reaction};
# if we got to this point without creating a response, it must be a type we
# don't handle yet
if (! $update) {

View File

@@ -10,7 +10,7 @@ use Mojo::Base 'Teapot::Bot::Object::Base';
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::Chat ();
use Teapot::Bot::Object::User ();
use Teapot::Bot::Object::MessageReaction ();
$Teapot::Bot::Object::MessageReactionUpdated::VERSION = '0.026';