diff --git a/lib/BotLib/Util.pm b/lib/BotLib/Util.pm index 6461dbf..11ca034 100644 --- a/lib/BotLib/Util.pm +++ b/lib/BotLib/Util.pm @@ -89,20 +89,39 @@ sub Highlight { return ($userid, $username, $fullname, $highlight, undef); } - $userid = $msg->from->id; + if ($msg->can ('from')) { + $userid = $msg->from->id; - if ($msg->from->can ('username') && defined $msg->from->username ) { - $username = $msg->from->username; - } - - if ($msg->from->can ('first_name') && defined $msg->from->first_name) { - $fullname = $msg->from->first_name; - - if ($msg->from->can ('last_name') && defined $msg->from->last_name) { - $fullname .= ' ' . $msg->from->last_name; + if ($msg->from->can ('username') && defined $msg->from->username ) { + $username = $msg->from->username; + } + + if ($msg->from->can ('first_name') && defined $msg->from->first_name) { + $fullname = $msg->from->first_name; + + if ($msg->from->can ('last_name') && defined $msg->from->last_name) { + $fullname .= ' ' . $msg->from->last_name; + } + } 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; } - } elsif ($msg->from->can ('last_name') && defined $msg->from->last_name) { - $fullname .= $msg->from->last_name; } if (defined $username) { diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index ba539a2..b042922 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -24,16 +24,16 @@ use Log::Any (); use Data::Dumper qw (Dumper); # TODO: import subs that are "used here directly by peeking into apropriate ns-es" -use Teapot::Bot::Object::Message (); -use Teapot::Bot::Object::Poll (); -use Teapot::Bot::Object::PollAnswer (); -use Teapot::Bot::Object::ChatMemberUpdated (); -use Teapot::Bot::Object::ChatPermissions (); -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::Message (); +use Teapot::Bot::Object::Poll (); +use Teapot::Bot::Object::PollAnswer (); +use Teapot::Bot::Object::ChatMemberUpdated (); +use Teapot::Bot::Object::ChatPermissions (); +use Teapot::Bot::Object::User (); +use Teapot::Bot::Object::Chat (); +use Teapot::Bot::Object::ChatMember (); +use Teapot::Bot::Object::ChatInviteLink (); +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) { diff --git a/lib/Teapot/Bot/Object/MessageReactionUpdated.pm b/lib/Teapot/Bot/Object/MessageReactionUpdated.pm index b938f2a..cbf55ad 100644 --- a/lib/Teapot/Bot/Object/MessageReactionUpdated.pm +++ b/lib/Teapot/Bot/Object/MessageReactionUpdated.pm @@ -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';