Fixes
This commit is contained in:
parent
86f6887148
commit
bb6f221939
@ -115,7 +115,9 @@ class FastAPI extends API
|
||||
$API = new API($session->getSessionPath(), $settings);
|
||||
yield from $API->initAsynchronously();
|
||||
unset($API);
|
||||
Logger::log("Destroying temporary MadelineProto...");
|
||||
while (\gc_collect_cycles());
|
||||
Logger::log("Destroyed temporary MadelineProto!");
|
||||
return null; // Should start IPC server
|
||||
}
|
||||
return yield from $this->tryConnect($session->getIpcPath());
|
||||
|
@ -224,7 +224,7 @@ class Logger
|
||||
10*1000,
|
||||
function () use ($max_size) {
|
||||
\clearstatcache(true, $this->optional);
|
||||
if (\filesize($this->optional) >= $max_size) {
|
||||
if (\file_exists($this->optional) && \filesize($this->optional) >= $max_size) {
|
||||
$this->stdout = null;
|
||||
\unlink($this->optional);
|
||||
$this->stdout = new ResourceOutputStream(\fopen($this->optional, 'a'));
|
||||
|
@ -53,7 +53,7 @@ trait Start
|
||||
$this->serialize();
|
||||
return yield from $this->fullGetSelf();
|
||||
}
|
||||
if ($this->authorized === MTProto::NOT_LOGGED_IN) {
|
||||
if ((yield $this->getAuthorization()) === MTProto::NOT_LOGGED_IN) {
|
||||
if (isset($_POST['phone_number'])) {
|
||||
yield from $this->webPhoneLogin();
|
||||
} elseif (isset($_POST['token'])) {
|
||||
@ -61,26 +61,26 @@ trait Start
|
||||
} else {
|
||||
yield from $this->webEcho();
|
||||
}
|
||||
} elseif ($this->authorized === MTProto::WAITING_CODE) {
|
||||
} elseif ((yield $this->getAuthorization()) === MTProto::WAITING_CODE) {
|
||||
if (isset($_POST['phone_code'])) {
|
||||
yield from $this->webCompletePhoneLogin();
|
||||
} else {
|
||||
yield from $this->webEcho("You didn't provide a phone code!");
|
||||
}
|
||||
} elseif ($this->authorized === MTProto::WAITING_PASSWORD) {
|
||||
} elseif ((yield $this->getAuthorization()) === MTProto::WAITING_PASSWORD) {
|
||||
if (isset($_POST['password'])) {
|
||||
yield from $this->webComplete2faLogin();
|
||||
} else {
|
||||
yield from $this->webEcho("You didn't provide the password!");
|
||||
}
|
||||
} elseif ($this->authorized === MTProto::WAITING_SIGNUP) {
|
||||
} elseif ((yield $this->getAuthorization()) === MTProto::WAITING_SIGNUP) {
|
||||
if (isset($_POST['first_name'])) {
|
||||
yield from $this->webCompleteSignup();
|
||||
} else {
|
||||
yield from $this->webEcho("You didn't provide the first name!");
|
||||
}
|
||||
}
|
||||
if ($this->authorized === MTProto::LOGGED_IN) {
|
||||
if ((yield $this->getAuthorization()) === MTProto::LOGGED_IN) {
|
||||
$this->serialize();
|
||||
return yield from $this->fullGetSelf();
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
namespace danog\MadelineProto\Wrappers;
|
||||
|
||||
use function Amp\ByteStream\getOutputBufferStream;
|
||||
use \danog\MadelineProto\MTProto;
|
||||
|
||||
trait Templates
|
||||
{
|
||||
@ -33,8 +34,8 @@ trait Templates
|
||||
private function webEcho(string $message = ''): \Generator
|
||||
{
|
||||
$stdout = getOutputBufferStream();
|
||||
switch ($this->authorized) {
|
||||
case self::NOT_LOGGED_IN:
|
||||
switch (yield $this->getAuthorization()) {
|
||||
case MTProto::NOT_LOGGED_IN:
|
||||
if (isset($_POST['type'])) {
|
||||
if ($_POST['type'] === 'phone') {
|
||||
yield $stdout->write($this->webEchoTemplate('Enter your phone number<br><b>'.$message.'</b>', '<input type="text" name="phone_number" placeholder="Phone number" required/>'));
|
||||
@ -45,13 +46,13 @@ trait Templates
|
||||
yield $stdout->write($this->webEchoTemplate('Do you want to login as user or bot?<br><b>'.$message.'</b>', '<select name="type"><option value="phone">User</option><option value="bot">Bot</option></select>'));
|
||||
}
|
||||
break;
|
||||
case self::WAITING_CODE:
|
||||
case MTProto::WAITING_CODE:
|
||||
yield $stdout->write($this->webEchoTemplate('Enter your code<br><b>'.$message.'</b>', '<input type="text" name="phone_code" placeholder="Phone code" required/>'));
|
||||
break;
|
||||
case self::WAITING_PASSWORD:
|
||||
case MTProto::WAITING_PASSWORD:
|
||||
yield $stdout->write($this->webEchoTemplate('Enter your password<br><b>'.$message.'</b>', '<input type="password" name="password" placeholder="Hint: '.$this->authorization['hint'].'" required/>'));
|
||||
break;
|
||||
case self::WAITING_SIGNUP:
|
||||
case MTProto::WAITING_SIGNUP:
|
||||
yield $stdout->write($this->webEchoTemplate('Sign up please<br><b>'.$message.'</b>', '<input type="text" name="first_name" placeholder="First name" required/><input type="text" name="last_name" placeholder="Last name"/>'));
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user