Various bugfixes
This commit is contained in:
parent
03c3419240
commit
df4e667bd7
@ -19,9 +19,9 @@
|
|||||||
namespace danog\MadelineProto\Loop\Update;
|
namespace danog\MadelineProto\Loop\Update;
|
||||||
|
|
||||||
use Amp\Loop;
|
use Amp\Loop;
|
||||||
|
use danog\MadelineProto\Exception;
|
||||||
use danog\MadelineProto\Loop\Impl\ResumableSignalLoop;
|
use danog\MadelineProto\Loop\Impl\ResumableSignalLoop;
|
||||||
use danog\MadelineProto\RPCErrorException;
|
use danog\MadelineProto\RPCErrorException;
|
||||||
use danog\MadelineProto\Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update loop.
|
* Update loop.
|
||||||
@ -148,13 +148,13 @@ class UpdateLoop extends ResumableSignalLoop
|
|||||||
|
|
||||||
$difference = yield $API->method_call_async_read('updates.getDifference', ['pts' => $state->pts(), 'date' => $state->date(), 'qts' => $state->qts()], ['datacenter' => $API->settings['connection_settings']['default_dc']]);
|
$difference = yield $API->method_call_async_read('updates.getDifference', ['pts' => $state->pts(), 'date' => $state->date(), 'qts' => $state->qts()], ['datacenter' => $API->settings['connection_settings']['default_dc']]);
|
||||||
$API->logger->logger('Got '.$difference['_'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$API->logger->logger('Got '.$difference['_'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
|
|
||||||
switch ($difference['_']) {
|
switch ($difference['_']) {
|
||||||
case 'updates.differenceEmpty':
|
case 'updates.differenceEmpty':
|
||||||
$state->update($difference);
|
$state->update($difference);
|
||||||
unset($difference);
|
unset($difference);
|
||||||
break 2;
|
break 2;
|
||||||
case 'updates.difference':
|
case 'updates.difference':
|
||||||
|
$state->qts($difference['state']['qts']);
|
||||||
foreach ($difference['new_encrypted_messages'] as &$encrypted) {
|
foreach ($difference['new_encrypted_messages'] as &$encrypted) {
|
||||||
$encrypted = ['_' => 'updateNewEncryptedMessage', 'message' => $encrypted];
|
$encrypted = ['_' => 'updateNewEncryptedMessage', 'message' => $encrypted];
|
||||||
}
|
}
|
||||||
@ -165,6 +165,7 @@ class UpdateLoop extends ResumableSignalLoop
|
|||||||
unset($difference);
|
unset($difference);
|
||||||
break 2;
|
break 2;
|
||||||
case 'updates.differenceSlice':
|
case 'updates.differenceSlice':
|
||||||
|
$state->qts($difference['state']['qts']);
|
||||||
foreach ($difference['new_encrypted_messages'] as &$encrypted) {
|
foreach ($difference['new_encrypted_messages'] as &$encrypted) {
|
||||||
$encrypted = ['_' => 'updateNewEncryptedMessage', 'message' => $encrypted];
|
$encrypted = ['_' => 'updateNewEncryptedMessage', 'message' => $encrypted];
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ trait Files
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = yield all($promises);
|
$result = yield all($promises);
|
||||||
foreach ($result as $key => $result) {
|
foreach ($result as $kkey => $result) {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new \danog\MadelineProto\Exception('Upload of part '.$key.' failed');
|
throw new \danog\MadelineProto\Exception('Upload of part '.$kkey.' failed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,6 @@ trait PeerHandler
|
|||||||
case 'updateNewChannelMessage':
|
case 'updateNewChannelMessage':
|
||||||
case 'updateEditMessage':
|
case 'updateEditMessage':
|
||||||
case 'updateEditChannelMessage':
|
case 'updateEditChannelMessage':
|
||||||
case 'updateNewEncryptedMessage':
|
|
||||||
return $this->get_id($id['message']);
|
return $this->get_id($id['message']);
|
||||||
default:
|
default:
|
||||||
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($id, true));
|
throw new \danog\MadelineProto\Exception('Invalid constructor given '.var_export($id, true));
|
||||||
@ -341,6 +340,8 @@ trait PeerHandler
|
|||||||
case 'updateEncryptedChatTyping':
|
case 'updateEncryptedChatTyping':
|
||||||
case 'updateEncryptedMessagesRead':
|
case 'updateEncryptedMessagesRead':
|
||||||
return $this->get_secret_chat($id['chat_id']);
|
return $this->get_secret_chat($id['chat_id']);
|
||||||
|
case 'updateNewEncryptedMessage':
|
||||||
|
$id = $id['message'];
|
||||||
case 'encryptedMessage':
|
case 'encryptedMessage':
|
||||||
case 'encryptedMessageService':
|
case 'encryptedMessageService':
|
||||||
$id = $id['chat_id'];
|
$id = $id['chat_id'];
|
||||||
|
@ -39,7 +39,7 @@ class RPCErrorException extends \Exception
|
|||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
$result = sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], $this->getMess(), $this->rpc, $this->file, $this->line.PHP_EOL, \danog\MadelineProto\Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
|
$result = sprintf(\danog\MadelineProto\Lang::$current_lang['rpc_tg_error'], $this->getMess()." ({$this->code})", $this->rpc, $this->file, $this->line.PHP_EOL, \danog\MadelineProto\Magic::$revision.PHP_EOL.PHP_EOL).PHP_EOL.$this->getTLTrace().PHP_EOL;
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
$result = str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
$result = str_replace(PHP_EOL, '<br>'.PHP_EOL, $result);
|
||||||
}
|
}
|
||||||
|
@ -224,12 +224,12 @@ trait TL
|
|||||||
throw new Exception('Invalid callback object provided!');
|
throw new Exception('Invalid callback object provided!');
|
||||||
}
|
}
|
||||||
$new = [
|
$new = [
|
||||||
TLCallback::METHOD_BEFORE_CALLBACK => $object->getMethodBeforeCallbacks(),
|
TLCallback::METHOD_BEFORE_CALLBACK => $object->getMethodBeforeCallbacks(),
|
||||||
TLCallback::METHOD_CALLBACK => $object->getMethodCallbacks(),
|
TLCallback::METHOD_CALLBACK => $object->getMethodCallbacks(),
|
||||||
TLCallback::CONSTRUCTOR_BEFORE_CALLBACK => $object->getConstructorBeforeCallbacks(),
|
TLCallback::CONSTRUCTOR_BEFORE_CALLBACK => $object->getConstructorBeforeCallbacks(),
|
||||||
TLCallback::CONSTRUCTOR_CALLBACK => $object->getConstructorCallbacks(),
|
TLCallback::CONSTRUCTOR_CALLBACK => $object->getConstructorCallbacks(),
|
||||||
TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK => $object->getConstructorSerializeCallbacks(),
|
TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK => $object->getConstructorSerializeCallbacks(),
|
||||||
TLCallback::TYPE_MISMATCH_CALLBACK => $object->getTypeMismatchCallbacks(),
|
TLCallback::TYPE_MISMATCH_CALLBACK => $object->getTypeMismatchCallbacks(),
|
||||||
];
|
];
|
||||||
foreach ($new as $type => $values) {
|
foreach ($new as $type => $values) {
|
||||||
foreach ($values as $match => $callback) {
|
foreach ($values as $match => $callback) {
|
||||||
@ -449,7 +449,7 @@ trait TL
|
|||||||
$method = 'messages.importChatInvite';
|
$method = 'messages.importChatInvite';
|
||||||
$arguments['hash'] = $matches[2];
|
$arguments['hash'] = $matches[2];
|
||||||
}
|
}
|
||||||
} elseif ($method === 'messages.sendMessage' && isset($arguments['peer']['_']) && $arguments['peer']['_'] === 'inputEncryptedChat') {
|
} elseif ($method === 'messages.sendMessage' && isset($arguments['peer']['_']) && in_array($arguments['peer']['_'], ['inputEncryptedChat', 'updateEncryption', 'updateEncryptedChatTyping', 'updateEncryptedMessagesRead', 'updateNewEncryptedMessage', 'encryptedMessage', 'encryptedMessageService'])) {
|
||||||
$method = 'messages.sendEncrypted';
|
$method = 'messages.sendEncrypted';
|
||||||
$arguments = ['peer' => $arguments['peer'], 'message' => $arguments];
|
$arguments = ['peer' => $arguments['peer'], 'message' => $arguments];
|
||||||
if (!isset($arguments['message']['_'])) {
|
if (!isset($arguments['message']['_'])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user