Skip to content

Commit

Permalink
Merge pull request #16 from setiawanhu/dev
Browse files Browse the repository at this point in the history
Updating behavior change on MadelineProto API instance
  • Loading branch information
setiawanhu authored May 20, 2021
2 parents ba8f3cb + 2a303fe commit 014d352
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion 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 $messages)
public function __construct($messages)
{
$this->messages = $messages;
}
Expand Down
13 changes: 7 additions & 6 deletions src/MadelineProto.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ public function completePhoneLogin(string $code): TelegramObject
{
$response = new TelegramObject($this->client->completePhoneLogin($code));

switch ($response->return_type) {
case Account::PASSWORD:
throw new NeedTwoFactorAuthException($response);
case Account::NEED_SIGN_UP:
throw new SignUpNeededException();
if ($response->return_type == Account::PASSWORD) {
throw new NeedTwoFactorAuthException($response);
}

if ($response->return_type == Account::NEED_SIGN_UP) {
throw new SignUpNeededException();
}

return $response;
Expand Down Expand Up @@ -145,7 +146,7 @@ public function isLoggedIn(): bool
*
* @return ClientMessages
*/
public function messages()
public function messages(): ClientMessages
{
return new ClientMessages($this->client->messages);
}
Expand Down

0 comments on commit 014d352

Please sign in to comment.