Bugfixes
This commit is contained in:
parent
737048c1ae
commit
4f248b030b
2
bot.php
2
bot.php
@ -44,7 +44,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
|
||||
try {
|
||||
yield $this->messages->sendMessage(['peer' => $update, 'message' => "<code>$res</code>", 'reply_to_msg_id' => isset($update['message']['id']) ? $update['message']['id'] : null, 'parse_mode' => 'HTML']); //'entities' => [['_' => 'messageEntityPre', 'offset' => 0, 'length' => strlen($res), 'language' => 'json']]]);
|
||||
if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') {
|
||||
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $media]);
|
||||
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
|
||||
/* '_' => 'inputMediaUploadedDocument',
|
||||
'file' => $update,
|
||||
'attributes' => [
|
||||
|
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 8f6784adf5bca1dbab98ba1ec69ab52050633ca1
|
||||
Subproject commit c60f59ffe2ee74d6fb50cd96651e4ae234dbb6ea
|
@ -213,6 +213,9 @@ class DataCenterConnection implements JsonSerializable
|
||||
*/
|
||||
public function bind(bool $pfs = true)
|
||||
{
|
||||
if (!$pfs && !$this->tempAuthKey) {
|
||||
$this->tempAuthKey = new TempAuthKey();
|
||||
}
|
||||
$this->tempAuthKey->bind($this->permAuthKey, $pfs);
|
||||
}
|
||||
/**
|
||||
@ -326,12 +329,10 @@ class DataCenterConnection implements JsonSerializable
|
||||
$this->decRead = $media ? self::READ_WEIGHT_MEDIA : self::READ_WEIGHT;
|
||||
$this->decWrite = self::WRITE_WEIGHT;
|
||||
|
||||
if ($id === -1 || !isset($this->connections[$id])) {
|
||||
$this->connections = [];
|
||||
$this->availableConnections = [];
|
||||
|
||||
if ($id === -1) {
|
||||
yield $this->connectMore($count);
|
||||
} else {
|
||||
$this->availableConnections[$id] = 0;
|
||||
yield $this->connections[$id]->connect($ctx);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ use Amp\Deferred;
|
||||
use Amp\Promise;
|
||||
use Amp\Success;
|
||||
use danog\MadelineProto\Async\Parameters;
|
||||
use danog\MadelineProto\Tools;
|
||||
|
||||
use function Amp\Promise\all;
|
||||
|
||||
/**
|
||||
@ -149,7 +151,7 @@ trait CallHandler
|
||||
if (isset($args['multiple'])) {
|
||||
$aargs['multiple'] = true;
|
||||
}
|
||||
if (isset($args['message']) && \is_string($args['message']) && \mb_strlen($args['message'], 'UTF-8') > (yield $this->API->get_config_async())['message_length_max'] && \mb_strlen((yield $this->parse_mode_async($args))['message'], 'UTF-8') > (yield $this->API->get_config_async())['message_length_max']) {
|
||||
if (isset($args['message']) && \is_string($args['message']) && \mb_strlen($args['message'], 'UTF-8') > (yield $this->API->get_config_async())['message_length_max'] && \mb_strlen((yield $this->API->parse_mode_async($args))['message'], 'UTF-8') > (yield $this->API->get_config_async())['message_length_max']) {
|
||||
$args = yield $this->split_to_chunks_async($args);
|
||||
$promises = [];
|
||||
$aargs['queue'] = $method;
|
||||
@ -175,7 +177,7 @@ trait CallHandler
|
||||
}
|
||||
$args = yield $this->API->botAPI_to_MTProto_async($args);
|
||||
if (isset($args['ping_id']) && \is_int($args['ping_id'])) {
|
||||
$args['ping_id'] = $this->pack_signed_long($args['ping_id']);
|
||||
$args['ping_id'] = Tools::pack_signed_long($args['ping_id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ trait ResponseHandler
|
||||
}
|
||||
|
||||
if (isset($request['user_related']) && $request['user_related']) {
|
||||
$this->settings['connection_settings']['default_dc'] = $this->API->authorized_dc = $this->API->datacenter->curdc;
|
||||
$this->API->settings['connection_settings']['default_dc'] = $this->API->authorized_dc = $this->API->datacenter->curdc;
|
||||
}
|
||||
Loop::defer([$this, 'method_recall'], ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
||||
//$this->API->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter, 'postpone' => true]);
|
||||
@ -409,7 +409,6 @@ trait ResponseHandler
|
||||
|
||||
$this->logger->logger($response['error_message'], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
foreach ($this->API->datacenter->getDataCenterConnections() as $socket) {
|
||||
$socket->authorized(false);
|
||||
$socket->setTempAuthKey(null);
|
||||
$socket->setPermAuthKey(null);
|
||||
$socket->resetSession();
|
||||
@ -458,7 +457,6 @@ trait ResponseHandler
|
||||
|
||||
$this->logger->logger('Permanent auth key was main authorized key, logging out...', \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
foreach ($this->API->datacenter->getDataCenterConnections() as $socket) {
|
||||
$socket->authorized(false);
|
||||
$socket->setTempAuthKey(null);
|
||||
$socket->setPermAuthKey(null);
|
||||
}
|
||||
@ -506,7 +504,7 @@ trait ResponseHandler
|
||||
return;
|
||||
case 420:
|
||||
$seconds = \preg_replace('/[^0-9]+/', '', $response['error_message']);
|
||||
$limit = isset($request['FloodWaitLimit']) ? $request['FloodWaitLimit'] : $this->settings['flood_timeout']['wait_if_lt'];
|
||||
$limit = isset($request['FloodWaitLimit']) ? $request['FloodWaitLimit'] : $this->API->settings['flood_timeout']['wait_if_lt'];
|
||||
if (\is_numeric($seconds) && $seconds < $limit) {
|
||||
//$this->got_response_for_outgoing_message_id($request_id);
|
||||
|
||||
@ -535,7 +533,7 @@ trait ResponseHandler
|
||||
$this->logger->logger('Received bad_msg_notification: '.MTProto::BAD_MSG_ERROR_CODES[$response['error_code']], \danog\MadelineProto\Logger::WARNING);
|
||||
switch ($response['error_code']) {
|
||||
case 48:
|
||||
$this->getTempAuthKey()->setServerSalt($response['new_server_salt']);
|
||||
$this->shared->getTempAuthKey()->setServerSalt($response['new_server_salt']);
|
||||
$this->method_recall('', ['message_id' => $request_id, 'postpone' => true]);
|
||||
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user