diff --git a/src/Console/ListCommand.php b/src/Console/ListCommand.php index 0b2131d..d78121b 100644 --- a/src/Console/ListCommand.php +++ b/src/Console/ListCommand.php @@ -7,7 +7,6 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Str; -use ReflectionProperty; use SergiX44\Nutgram\Handlers\Handler; use SergiX44\Nutgram\Handlers\Type\Command as NutgramCommand; use SergiX44\Nutgram\Nutgram; @@ -39,9 +38,8 @@ public function handle(Nutgram $bot): int protected function getHandlers(Nutgram $bot): Collection { - $refHandlers = new ReflectionProperty(Nutgram::class, "handlers"); - $refHandlers->setAccessible(true); - return collect(Arr::dot($refHandlers->getValue($bot))); + $handlers = (fn () => $this->handlers)->call($bot); + return collect(Arr::dot($handlers)); } protected function getHandlerName(string $signature, bool $isCommand = false): string @@ -60,6 +58,8 @@ protected function resolveUpdateListener(string $signature): string 'edited_message' => 'onEditedMessage', 'channel_post' => 'onChannelPost', 'edited_channel_post' => 'onEditedChannelPost', + 'message_reaction' => 'onMessageReaction', + 'message_reaction_count' => 'onMessageReactionCount', 'inline_query' => 'onInlineQuery', 'chosen_inline_result' => 'onChosenInlineResult', 'callback_query' => 'onCallbackQuery', @@ -70,8 +70,13 @@ protected function resolveUpdateListener(string $signature): string 'my_chat_member' => 'onMyChatMember', 'chat_member' => 'onChatMember', 'chat_join_request' => 'onChatJoinRequest', + 'chat_boost' => 'onChatBoost', + 'removed_chat_boost' => 'onRemovedChatBoost', 'api_error' => 'onApiError', 'exception' => 'onException', + 'fallback' => 'fallback', + 'before_api_request' => 'beforeApiRequest', + 'after_api_request' => 'afterApiRequest', default => 'unknown', }; } @@ -101,6 +106,7 @@ protected function resolveMessageListener(string $signature): string 'poll' => 'onMessagePoll', 'venue' => 'onVenue', 'location' => 'onLocation', + 'story' => 'onStory', 'new_chat_members' => 'onNewChatMembers', 'left_chat_member' => 'onLeftChatMember', 'new_chat_title' => 'onNewChatTitle', @@ -115,6 +121,8 @@ protected function resolveMessageListener(string $signature): string 'pinned_message' => 'onPinnedMessage', 'invoice' => 'onInvoice', 'successful_payment' => 'onSuccessfulPayment', + 'users_shared' => 'onUsersShared', + 'chat_shared' => 'onChatShared', 'connected_website' => 'onConnectedWebsite', 'passport_data' => 'onPassportData', 'proximity_alert_triggered' => 'onProximityAlertTriggered', @@ -122,6 +130,10 @@ protected function resolveMessageListener(string $signature): string 'forum_topic_edited' => 'onForumTopicEdited', 'forum_topic_closed' => 'onForumTopicClosed', 'forum_topic_reopened' => 'onForumTopicReopened', + 'giveaway_created' => 'onGiveawayCreated', + 'giveaway' => 'onGiveaway', + 'giveaway_winners' => 'onGiveawayWinners', + 'giveaway_completed' => 'onGiveawayCompleted', 'video_chat_scheduled' => 'onVideoChatScheduled', 'video_chat_started' => 'onVideoChatStarted', 'video_chat_ended' => 'onVideoChatEnded', @@ -134,9 +146,7 @@ protected function resolveMessageListener(string $signature): string protected function getCallableName(Handler $handler): string { // get callable value - $refCallable = new ReflectionProperty(Handler::class, "callable"); - $refCallable->setAccessible(true); - $callable = $refCallable->getValue($handler); + $callable = (fn () => $this->callable)->call($handler); // parse callable if (is_string($callable)) { diff --git a/tests/Commands/HookSetTest.php b/tests/Commands/HookSetTest.php index ab13ea5..5a2ed76 100644 --- a/tests/Commands/HookSetTest.php +++ b/tests/Commands/HookSetTest.php @@ -2,12 +2,13 @@ use Mockery\MockInterface; use Nutgram\Laravel\Console\HookSetCommand; +use SergiX44\Nutgram\Configuration; use SergiX44\Nutgram\Nutgram; test('nutgram:hook:set sets the bot webhook', function () { $this->mock(Nutgram::class, function (MockInterface $mock) { $mock->shouldReceive('setWebhook') - ->with('https://foo.bar/hook', null, null, 50, null, null, null) + ->with('https://foo.bar/hook', null, null, 50, Configuration::DEFAULT_ALLOWED_UPDATES, null, null) ->andReturn(0); }); @@ -27,7 +28,7 @@ $this->mock(Nutgram::class, function (MockInterface $mock) use ($hashedAppKey) { $mock->shouldReceive('setWebhook') - ->with('https://foo.bar/hook', null, null, 50, null, null, $hashedAppKey) + ->with('https://foo.bar/hook', null, null, 50, Configuration::DEFAULT_ALLOWED_UPDATES, null, $hashedAppKey) ->andReturn(0); });