From ad4294423f34b3e92dd9b2cac1535c6385ac2ed0 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 7 Apr 2021 15:39:30 +0200 Subject: [PATCH] Button bugfix --- src/danog/MadelineProto/TL/Types/Button.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/danog/MadelineProto/TL/Types/Button.php b/src/danog/MadelineProto/TL/Types/Button.php index 3f6dfe04d..ef3951cfa 100644 --- a/src/danog/MadelineProto/TL/Types/Button.php +++ b/src/danog/MadelineProto/TL/Types/Button.php @@ -63,13 +63,17 @@ class Button implements \JsonSerializable, \ArrayAccess */ public function __construct(MTProto $API, array $message, array $button) { + if (!isset($message['from_id']) // No other option + // It's a channel/chat, 100% what we need + || $message['peer_id']['_'] !== 'peerUser' + // It is a user, and it's not ourselves + || $message['peer_id']['user_id'] !== $API->authorization['user']['id'] + ) { + $this->peer = $message['peer_id']; + } else { + $this->peer = $message['from_id']; + } $this->button = $button; - $this->peer = $message['peer_id'] === [ - '_' => 'peerUser', - 'user_id' => $API->authorization['user']['id'] - ] - ? $message['from_id'] - : $message['peer_id']; $this->id = $message['id']; $this->API = $API; $this->session = $API->getWrapper()->getSession()->getLegacySessionPath();