Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram\Bot\Objects\Update::getMessage(): Return value must be of type Illuminate\Support\Collection, Hyperf\Collection\Collection returned #1083

Closed
guanzhihua168 opened this issue Jun 15, 2023 · 3 comments
Labels

Comments

@guanzhihua168
Copy link

PHP version

8.2

irazasyed/telegram-bot-sdk version

v3.13.0

Laravel version (if any)

No response

Code To Reproduce the bug

$manager = new BotsManager($config);
try {
$telegram = $manager->bot('mybot');
$update = $telegram->commandsHandler();
var_dump($update);

        } catch (Exception $e) {
            var_dump('exception: ' . $e->getMessage().$e->getTraceAsString());
        }

Error stacktrace (if any)

string(7) "message"
string(7) "message"
string(7) "message"
string(14) "my_chat_member"
vendor/irazasyed/telegram-bot-sdk/src/Objects/Update.php:133. Above output [var_dump($this->detectType())],Throws an exception while printing my chat member

Telegram\Bot\Objects\Update::getMessage(): Return value must be of type Illuminate\Support\Collection, Hyperf\Collection\Collection returned
[ERROR] TypeError: Telegram\Bot\Objects\Update::getMessage(): Return value must be of type Illuminate\Support\Collection, Hyperf\Collection\Collection returned in /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Objects/Update.php:145
Stack trace:
#0 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Objects/Update.php(107): Telegram\Bot\Objects\Update->getMessage()
#1 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Methods/Update.php(212): Telegram\Bot\Objects\Update->objectType()
#2 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Methods/Update.php(57): Telegram\Bot\Api->dispatchUpdateEvent()
#3 [internal function]: Telegram\Bot\Api->Telegram\Bot\Methods{closure}()
#4 /data/tgbot/vendor/hyperf/collection/src/Collection.php(877): array_map()
#5 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Methods/Update.php(53): Hyperf\Collection\Collection->map()
#6 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Traits/CommandsHandler.php(60): Telegram\Bot\Api->getUpdates()
#7 /data/tgbot/vendor/irazasyed/telegram-bot-sdk/src/Traits/CommandsHandler.php(37): Telegram\Bot\Api->useGetUpdates()
#8 /data/tgbot/app/Command/TgBotCommand.php(43): Telegram\Bot\Api->commandsHandler()
#9 /data/tgbot/vendor/hyperf/command/src/Command.php(428): App\Command\TgBotCommand->handle()
#10 [internal function]: Hyperf\Command\Command->Hyperf\Command{closure}()
#11 {main}

@guanzhihua168
Copy link
Author

My solution is on line 144, add 'my_chat_member' => $this->myChatMember

@irazasyed
Copy link
Owner

It seems like you have Hyperf Collection which is causing this conflict. Remove that and it should work.

@guanzhihua168
Copy link
Author

You're right, there is a conflict, but Hyperf's built-in can't remove it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants