Skip to content

Commit

Permalink
Merge pull request #12 from setiawanhu/dev
Browse files Browse the repository at this point in the history
Fixing TelegramObject constructor issue (#10)
  • Loading branch information
setiawanhu authored Dec 10, 2020
2 parents 7ea512e + 4e5db77 commit ba8f3cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
34 changes: 17 additions & 17 deletions src/ClientMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ClientMessages
*
* @param messages $messages
*/
public function __construct($messages)
public function __construct(messages $messages)
{
$this->messages = $messages;
}
Expand All @@ -26,7 +26,7 @@ public function __construct($messages)
*
* <br>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.acceptUrlAuth</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $messageId
Expand Down Expand Up @@ -79,7 +79,7 @@ public function acceptUrlAuth($messageId, int $buttonId = 0, array $extra = []):
* </li>
* </ol>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.addChatUser</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $chatId
Expand Down Expand Up @@ -107,7 +107,7 @@ public function addChatUser($chatId, $userId = '', int $forwardLimit = 1): Teleg
*
* <br>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.addChatUser</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $hash
Expand Down Expand Up @@ -139,7 +139,7 @@ public function clearAllDrafts(): bool
/**
* Clear recent stickers.
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.clearRecentStickers</strong> method payload. It's fields will be sent as payload.
*
* @param bool|TelegramObject $attached
Expand Down Expand Up @@ -183,7 +183,7 @@ public function clearRecentStickers($attached = false): bool
* </li>
* </ol>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.createChat</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $title
Expand Down Expand Up @@ -229,7 +229,7 @@ public function createChat($title, array $users = []): TelegramObject
* </li>
* </ol>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.deleteChatUser</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $chatId
Expand Down Expand Up @@ -275,7 +275,7 @@ public function deleteChatUser($chatId, $userId): TelegramObject
* </li>
* </ol>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.deleteHistory</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $peer
Expand Down Expand Up @@ -304,7 +304,7 @@ public function deleteHistory($peer, int $maxId = 0, array $extra = []): Telegra
*
* <br>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.deleteMessages</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $id
Expand All @@ -328,7 +328,7 @@ public function deleteMessages($id, bool $revoke = false): TelegramObject
/**
* Delete scheduled messages.
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.deleteScheduledMessages</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $peer
Expand All @@ -352,7 +352,7 @@ public function deleteScheduledMessages($peer, array $id = []): TelegramObject
/**
* Edit the description of a group/supergroup/channel.
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.editChatAbout</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $peer
Expand All @@ -376,7 +376,7 @@ public function editChatAbout($peer, string $about = ''): TelegramObject
/**
* Make a user admin in a legacy group.
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.editChatAdmin</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $chatId
Expand All @@ -402,7 +402,7 @@ public function editChatAdmin($chatId, $userId, bool $isAdmin): bool
/**
* Edit the default banned rights of a channel/supergroup/group.
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.editChatDefaultBannedRights</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $peer
Expand Down Expand Up @@ -448,7 +448,7 @@ public function editChatDefaultBannedRights($peer, array $bannedRights): Telegra
* </li>
* </ol>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.sendMessage</strong> method payload. It's fields will be sent as payload.
*
* @param mixed $peer
Expand Down Expand Up @@ -477,10 +477,10 @@ public function sendMessage($peer, string $message = '', array $extra = []): Tel
*
* <br>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.getPeerDialog</strong> method payload. It's fields will be sent as payload.
*
* @param int ...$peers
* @param array ...$peers
* @return TelegramObject
*/
public function getPeerDialogs(...$peers): TelegramObject
Expand All @@ -501,7 +501,7 @@ public function getPeerDialogs(...$peers): TelegramObject
*
* <br>
*
* For convenience, you may pass a TelegramObject to the first argument which contains
* For convenience, you may pass a {@link \Hu\MadelineProto\TelegramObject TelegramObject} to the first argument which contains
* <strong>messages.getHistory</strong> method payload. It's fields will be sent as payload.
*
* @param array|TelegramObject $params
Expand Down
12 changes: 5 additions & 7 deletions src/TelegramObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Hu\MadelineProto;

use danog\MadelineProto\Logger;
use danog\MadelineProto\updates;
use Illuminate\Contracts\Support\Arrayable;

/**
Expand All @@ -24,12 +24,10 @@ class TelegramObject implements Arrayable
/**
* TelegramObject constructor.
*
* @param $fields
* @param array|updates $fields request / response payloads
*/
public function __construct($fields)
public function __construct($fields = [])
{
Logger::log($fields);

$this->fields = $fields;
}

Expand Down Expand Up @@ -62,10 +60,10 @@ public function __set($name, $value)
/**
* is triggered by calling isset() or empty() on inaccessible members.
*
* @param $name string
* @param string $name
* @return bool
*/
public function __isset($name)
public function __isset(string $name)
{
return isset($this->fields[$name]);
}
Expand Down

0 comments on commit ba8f3cb

Please sign in to comment.