More constants and a regression to fix bugs
This commit is contained in:
parent
3aef7653a4
commit
7da8395234
@ -109,6 +109,48 @@ class MTProto extends \Volatile
|
|||||||
const CONFIRMED = 2;
|
const CONFIRMED = 2;
|
||||||
const READY = 3;
|
const READY = 3;
|
||||||
const EMOJIS = ['๐', '๐', '๐', '๐ญ', '๐ฑ', '๐ก', '๐', '๐ด', '๐ต', '๐', '๐ฌ', '๐', '๐', '๐ฎ', '๐ท', '๐', '๐ถ', '๐จ', '๐ฉ', '๐ด', '๐ต', '๐ป', '๐ฝ', '๐', '๐บ', '๐', '๐', '๐', '๐', '๐ฝ', '๐ฉ', '๐ฅ', '๐ฅ', '๐ค', '๐', '๐', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', 'โ', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ช', '๐ถ', '๐', '๐', '๐ซ', '๐ช', '๐ฌ', '๐ญ', '๐
', '๐ฉ', '๐', '๐', '๐', '๐', '๐ ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ถ', '๐บ', '๐ฑ', '๐ญ', '๐น', '๐ฐ', '๐ธ', '๐ฏ', '๐จ', '๐ป', '๐ท', '๐ฎ', '๐', '๐ด', '๐', '๐', '๐ผ', '๐ง', '๐ฅ', '๐', '๐', '๐ข', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฌ', '๐', '๐', '๐', '๐ซ', '๐', '๐น', '๐ป', '๐', '๐พ', '๐', '๐ต', '๐ด', '๐ณ', '๐', '๐', '๐', '๐', '๐', 'โก', 'โ', 'โ', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐ป', '๐
', '๐', '๐', '๐', '๐ฎ', '๐ฅ', '๐ท', '๐ฟ', '๐ป', 'โ', '๐ก', '๐บ', '๐ป', '๐', '๐', 'โณ', 'โฐ', 'โ', '๐', '๐', '๐', '๐ก', '๐ฆ', '๐', '๐', '๐ฟ', '๐ฝ', '๐ง', '๐จ', '๐ช', '๐ฌ', '๐ฃ', '๐ซ', '๐ช', '๐', '๐', '๐ฐ', '๐ต', '๐ณ', 'โ', '๐ซ', '๐ฆ', '๐
', '๐', 'โ', '๐', '๐', 'โ', 'โ', '๐', '๐', '๐ฌ', '๐ญ', '๐จ', '๐ฌ', '๐ค', '๐ง', '๐ต', '๐น', '๐ป', '๐บ', '๐ธ', '๐พ', '๐ฎ', '๐', '๐ฒ', '๐ฏ', '๐', '๐', 'โฝ', 'โพ', '๐พ', '๐ฑ', '๐', '๐ณ', '๐', '๐', '๐', '๐', '๐', 'โ', '๐ผ', '๐บ', '๐ท', '๐ด', '๐', '๐', '๐', '๐', '๐ฑ', '๐', '๐', '๐ก', '๐ณ', '๐', '๐ฉ', '๐ฆ', '๐', '๐ฐ', '๐ช', '๐ซ', '๐ญ', '๐ฏ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐
', '๐ฝ', '๐ก', '๐ฅ', '๐ฆ', 'โช', '๐ฐ', 'โบ', '๐ญ', '๐ป', '๐ฝ', '๐ ', '๐ก', 'โฒ', '๐ข', '๐ข', '๐ค', 'โ', '๐', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐จ', '๐', '๐', '๐', '๐ฒ', '๐ ', '๐', '๐ฆ', 'โ ', '๐ง', 'โฝ', '๐ฐ', '๐ฟ', '๐ช', '๐ญ', '๐ฏ๐ต', '๐ฐ๐ท', '๐ฉ๐ช', '๐จ๐ณ', '๐บ๐ธ', '๐ซ๐ท', '๐ช๐ธ', '๐ฎ๐น', '๐ท๐บ', '๐ฌ๐ง', '1โฃ', '2โฃ', '3โฃ', '4โฃ', '5โฃ', '6โฃ', '7โฃ', '8โฃ', '9โฃ', '0โฃ', '๐', 'โ', 'โ', 'โฅ', 'โฆ', '๐ฏ', '๐', '๐ฑ', '๐ด', '๐ต', '๐ถ', '๐ท'];
|
const EMOJIS = ['๐', '๐', '๐', '๐ญ', '๐ฑ', '๐ก', '๐', '๐ด', '๐ต', '๐', '๐ฌ', '๐', '๐', '๐ฎ', '๐ท', '๐', '๐ถ', '๐จ', '๐ฉ', '๐ด', '๐ต', '๐ป', '๐ฝ', '๐', '๐บ', '๐', '๐', '๐', '๐', '๐ฝ', '๐ฉ', '๐ฅ', '๐ฅ', '๐ค', '๐', '๐', '๐', '๐
', '๐', '๐', '๐', '๐', '๐', 'โ', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ช', '๐ถ', '๐', '๐', '๐ซ', '๐ช', '๐ฌ', '๐ญ', '๐
', '๐ฉ', '๐', '๐', '๐', '๐', '๐ ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ถ', '๐บ', '๐ฑ', '๐ญ', '๐น', '๐ฐ', '๐ธ', '๐ฏ', '๐จ', '๐ป', '๐ท', '๐ฎ', '๐', '๐ด', '๐', '๐', '๐ผ', '๐ง', '๐ฅ', '๐', '๐', '๐ข', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐ฌ', '๐', '๐', '๐', '๐ซ', '๐', '๐น', '๐ป', '๐', '๐พ', '๐', '๐ต', '๐ด', '๐ณ', '๐', '๐', '๐', '๐', '๐', 'โก', 'โ', 'โ', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐ป', '๐
', '๐', '๐', '๐', '๐ฎ', '๐ฅ', '๐ท', '๐ฟ', '๐ป', 'โ', '๐ก', '๐บ', '๐ป', '๐', '๐', 'โณ', 'โฐ', 'โ', '๐', '๐', '๐', '๐ก', '๐ฆ', '๐', '๐', '๐ฟ', '๐ฝ', '๐ง', '๐จ', '๐ช', '๐ฌ', '๐ฃ', '๐ซ', '๐ช', '๐', '๐', '๐ฐ', '๐ต', '๐ณ', 'โ', '๐ซ', '๐ฆ', '๐
', '๐', 'โ', '๐', '๐', 'โ', 'โ', '๐', '๐', '๐ฌ', '๐ญ', '๐จ', '๐ฌ', '๐ค', '๐ง', '๐ต', '๐น', '๐ป', '๐บ', '๐ธ', '๐พ', '๐ฎ', '๐', '๐ฒ', '๐ฏ', '๐', '๐', 'โฝ', 'โพ', '๐พ', '๐ฑ', '๐', '๐ณ', '๐', '๐', '๐', '๐', '๐', 'โ', '๐ผ', '๐บ', '๐ท', '๐ด', '๐', '๐', '๐', '๐', '๐ฑ', '๐', '๐', '๐ก', '๐ณ', '๐', '๐ฉ', '๐ฆ', '๐', '๐ฐ', '๐ช', '๐ซ', '๐ญ', '๐ฏ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐
', '๐ฝ', '๐ก', '๐ฅ', '๐ฆ', 'โช', '๐ฐ', 'โบ', '๐ญ', '๐ป', '๐ฝ', '๐ ', '๐ก', 'โฒ', '๐ข', '๐ข', '๐ค', 'โ', '๐', 'โ', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐', '๐จ', '๐', '๐', '๐', '๐ฒ', '๐ ', '๐', '๐ฆ', 'โ ', '๐ง', 'โฝ', '๐ฐ', '๐ฟ', '๐ช', '๐ญ', '๐ฏ๐ต', '๐ฐ๐ท', '๐ฉ๐ช', '๐จ๐ณ', '๐บ๐ธ', '๐ซ๐ท', '๐ช๐ธ', '๐ฎ๐น', '๐ท๐บ', '๐ฌ๐ง', '1โฃ', '2โฃ', '3โฃ', '4โฃ', '5โฃ', '6โฃ', '7โฃ', '8โฃ', '9โฃ', '0โฃ', '๐', 'โ', 'โ', 'โฅ', 'โฆ', '๐ฏ', '๐', '๐ฑ', '๐ด', '๐ต', '๐ถ', '๐ท'];
|
||||||
|
const TD_PARAMS_CONVERSION = [
|
||||||
|
'updateNewMessage' => [
|
||||||
|
'_' => 'updateNewMessage',
|
||||||
|
'disable_notification' => ['message', 'silent'],
|
||||||
|
'message' => ['message'],
|
||||||
|
],
|
||||||
|
'message' => [
|
||||||
|
'_' => 'message',
|
||||||
|
'id' => ['id'],
|
||||||
|
'sender_user_id' => ['from_id'],
|
||||||
|
'chat_id' => ['to_id', 'choose_chat_id_from_botapi'],
|
||||||
|
'send_state' => ['choose_incoming_or_sent'],
|
||||||
|
'can_be_edited' => ['choose_can_edit'],
|
||||||
|
'can_be_deleted' => ['choose_can_delete'],
|
||||||
|
'is_post' => ['post'],
|
||||||
|
'date' => ['date'],
|
||||||
|
'edit_date' => ['edit_date'],
|
||||||
|
'forward_info' => ['fwd_info', 'choose_forward_info'],
|
||||||
|
'reply_to_message_id' => ['reply_to_msg_id'],
|
||||||
|
'ttl' => ['choose_ttl'],
|
||||||
|
'ttl_expires_in' => ['choose_ttl_expires_in'],
|
||||||
|
'via_bot_user_id' => ['via_bot_id'],
|
||||||
|
'views' => ['views'],
|
||||||
|
'content' => ['choose_message_content'],
|
||||||
|
'reply_markup' => ['reply_markup'],
|
||||||
|
],
|
||||||
|
|
||||||
|
'messages.sendMessage' => [
|
||||||
|
'chat_id' => ['peer'],
|
||||||
|
'reply_to_message_id' => ['reply_to_msg_id'],
|
||||||
|
'disable_notification' => ['silent'],
|
||||||
|
'from_background' => ['background'],
|
||||||
|
'input_message_content' => ['choose_message_content'],
|
||||||
|
'reply_markup' => ['reply_markup'],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
|
const TD_REVERSE = [
|
||||||
|
'sendMessage'=> 'messages.sendMessage',
|
||||||
|
];
|
||||||
|
const TD_IGNORE = ['updateMessageID'];
|
||||||
|
|
||||||
|
|
||||||
public $settings = [];
|
public $settings = [];
|
||||||
private $config = ['expires' => -1];
|
private $config = ['expires' => -1];
|
||||||
@ -132,7 +174,7 @@ class MTProto extends \Volatile
|
|||||||
private $msg_ids = [];
|
private $msg_ids = [];
|
||||||
private $v = 0;
|
private $v = 0;
|
||||||
|
|
||||||
private $dialog_params = ['_' => 'MadelineProto.DialogParams', 'limit' => 0, 'offset_date' => 0, 'offset_id' => 0, 'offset_peer' => ['_' => 'inputPeerEmpty']];
|
private $dialog_params = ['_' => 'MadelineProto.dialogParams', 'limit' => 0, 'offset_date' => 0, 'offset_id' => 0, 'offset_peer' => ['_' => 'inputPeerEmpty']];
|
||||||
private $zero;
|
private $zero;
|
||||||
private $one;
|
private $one;
|
||||||
private $two;
|
private $two;
|
||||||
@ -246,6 +288,7 @@ class MTProto extends \Volatile
|
|||||||
}
|
}
|
||||||
unset($this->data);
|
unset($this->data);
|
||||||
}
|
}
|
||||||
|
if ($this->authorized === true) $this->authorized = self::LOGGED_IN;
|
||||||
$this->getting_state = false;
|
$this->getting_state = false;
|
||||||
$this->reset_session();
|
$this->reset_session();
|
||||||
if (!isset($this->v) || $this->v !== $this->getV()) {
|
if (!isset($this->v) || $this->v !== $this->getV()) {
|
||||||
@ -652,11 +695,395 @@ class MTProto extends \Volatile
|
|||||||
|
|
||||||
public function getV()
|
public function getV()
|
||||||
{
|
{
|
||||||
return 35;
|
return 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_self()
|
public function get_self()
|
||||||
{
|
{
|
||||||
return $this->authorization['user'];
|
return $this->authorization['user'];
|
||||||
}
|
}
|
||||||
|
const ALL_MIMES = [
|
||||||
|
'png' => [
|
||||||
|
0 => 'image/png',
|
||||||
|
1 => 'image/x-png',
|
||||||
|
],
|
||||||
|
'bmp' => [
|
||||||
|
0 => 'image/bmp',
|
||||||
|
1 => 'image/x-bmp',
|
||||||
|
2 => 'image/x-bitmap',
|
||||||
|
3 => 'image/x-xbitmap',
|
||||||
|
4 => 'image/x-win-bitmap',
|
||||||
|
5 => 'image/x-windows-bmp',
|
||||||
|
6 => 'image/ms-bmp',
|
||||||
|
7 => 'image/x-ms-bmp',
|
||||||
|
8 => 'application/bmp',
|
||||||
|
9 => 'application/x-bmp',
|
||||||
|
10 => 'application/x-win-bitmap',
|
||||||
|
],
|
||||||
|
'gif' => [
|
||||||
|
0 => 'image/gif',
|
||||||
|
],
|
||||||
|
'jpeg' => [
|
||||||
|
0 => 'image/jpeg',
|
||||||
|
1 => 'image/pjpeg',
|
||||||
|
],
|
||||||
|
'xspf' => [
|
||||||
|
0 => 'application/xspf+xml',
|
||||||
|
],
|
||||||
|
'vlc' => [
|
||||||
|
0 => 'application/videolan',
|
||||||
|
],
|
||||||
|
'wmv' => [
|
||||||
|
0 => 'video/x-ms-wmv',
|
||||||
|
1 => 'video/x-ms-asf',
|
||||||
|
],
|
||||||
|
'au' => [
|
||||||
|
0 => 'audio/x-au',
|
||||||
|
],
|
||||||
|
'ac3' => [
|
||||||
|
0 => 'audio/ac3',
|
||||||
|
],
|
||||||
|
'flac' => [
|
||||||
|
0 => 'audio/x-flac',
|
||||||
|
],
|
||||||
|
'ogg' => [
|
||||||
|
0 => 'audio/ogg',
|
||||||
|
1 => 'video/ogg',
|
||||||
|
2 => 'application/ogg',
|
||||||
|
],
|
||||||
|
'kmz' => [
|
||||||
|
0 => 'application/vnd.google-earth.kmz',
|
||||||
|
],
|
||||||
|
'kml' => [
|
||||||
|
0 => 'application/vnd.google-earth.kml+xml',
|
||||||
|
],
|
||||||
|
'rtx' => [
|
||||||
|
0 => 'text/richtext',
|
||||||
|
],
|
||||||
|
'rtf' => [
|
||||||
|
0 => 'text/rtf',
|
||||||
|
],
|
||||||
|
'jar' => [
|
||||||
|
0 => 'application/java-archive',
|
||||||
|
1 => 'application/x-java-application',
|
||||||
|
2 => 'application/x-jar',
|
||||||
|
],
|
||||||
|
'zip' => [
|
||||||
|
0 => 'application/x-zip',
|
||||||
|
1 => 'application/zip',
|
||||||
|
2 => 'application/x-zip-compressed',
|
||||||
|
3 => 'application/s-compressed',
|
||||||
|
4 => 'multipart/x-zip',
|
||||||
|
],
|
||||||
|
'7zip' => [
|
||||||
|
0 => 'application/x-compressed',
|
||||||
|
],
|
||||||
|
'xml' => [
|
||||||
|
0 => 'application/xml',
|
||||||
|
1 => 'text/xml',
|
||||||
|
],
|
||||||
|
'svg' => [
|
||||||
|
0 => 'image/svg+xml',
|
||||||
|
],
|
||||||
|
'3g2' => [
|
||||||
|
0 => 'video/3gpp2',
|
||||||
|
],
|
||||||
|
'3gp' => [
|
||||||
|
0 => 'video/3gp',
|
||||||
|
1 => 'video/3gpp',
|
||||||
|
],
|
||||||
|
'mp4' => [
|
||||||
|
0 => 'video/mp4',
|
||||||
|
],
|
||||||
|
'm4a' => [
|
||||||
|
0 => 'audio/x-m4a',
|
||||||
|
],
|
||||||
|
'f4v' => [
|
||||||
|
0 => 'video/x-f4v',
|
||||||
|
],
|
||||||
|
'flv' => [
|
||||||
|
0 => 'video/x-flv',
|
||||||
|
],
|
||||||
|
'webm' => [
|
||||||
|
0 => 'video/webm',
|
||||||
|
],
|
||||||
|
'aac' => [
|
||||||
|
0 => 'audio/x-acc',
|
||||||
|
],
|
||||||
|
'm4u' => [
|
||||||
|
0 => 'application/vnd.mpegurl',
|
||||||
|
],
|
||||||
|
'pdf' => [
|
||||||
|
0 => 'application/pdf',
|
||||||
|
1 => 'application/octet-stream',
|
||||||
|
],
|
||||||
|
'pptx' => [
|
||||||
|
0 => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||||
|
],
|
||||||
|
'ppt' => [
|
||||||
|
0 => 'application/powerpoint',
|
||||||
|
1 => 'application/vnd.ms-powerpoint',
|
||||||
|
2 => 'application/vnd.ms-office',
|
||||||
|
3 => 'application/msword',
|
||||||
|
],
|
||||||
|
'docx' => [
|
||||||
|
0 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
|
],
|
||||||
|
'xlsx' => [
|
||||||
|
0 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
|
1 => 'application/vnd.ms-excel',
|
||||||
|
],
|
||||||
|
'xl' => [
|
||||||
|
0 => 'application/excel',
|
||||||
|
],
|
||||||
|
'xls' => [
|
||||||
|
0 => 'application/msexcel',
|
||||||
|
1 => 'application/x-msexcel',
|
||||||
|
2 => 'application/x-ms-excel',
|
||||||
|
3 => 'application/x-excel',
|
||||||
|
4 => 'application/x-dos_ms_excel',
|
||||||
|
5 => 'application/xls',
|
||||||
|
6 => 'application/x-xls',
|
||||||
|
],
|
||||||
|
'xsl' => [
|
||||||
|
0 => 'text/xsl',
|
||||||
|
],
|
||||||
|
'mpeg' => [
|
||||||
|
0 => 'video/mpeg',
|
||||||
|
],
|
||||||
|
'mov' => [
|
||||||
|
0 => 'video/quicktime',
|
||||||
|
],
|
||||||
|
'avi' => [
|
||||||
|
0 => 'video/x-msvideo',
|
||||||
|
1 => 'video/msvideo',
|
||||||
|
2 => 'video/avi',
|
||||||
|
3 => 'application/x-troff-msvideo',
|
||||||
|
],
|
||||||
|
'movie' => [
|
||||||
|
0 => 'video/x-sgi-movie',
|
||||||
|
],
|
||||||
|
'log' => [
|
||||||
|
0 => 'text/x-log',
|
||||||
|
],
|
||||||
|
'txt' => [
|
||||||
|
0 => 'text/plain',
|
||||||
|
],
|
||||||
|
'css' => [
|
||||||
|
0 => 'text/css',
|
||||||
|
],
|
||||||
|
'html' => [
|
||||||
|
0 => 'text/html',
|
||||||
|
],
|
||||||
|
'wav' => [
|
||||||
|
0 => 'audio/x-wav',
|
||||||
|
1 => 'audio/wave',
|
||||||
|
2 => 'audio/wav',
|
||||||
|
],
|
||||||
|
'xhtml' => [
|
||||||
|
0 => 'application/xhtml+xml',
|
||||||
|
],
|
||||||
|
'tar' => [
|
||||||
|
0 => 'application/x-tar',
|
||||||
|
],
|
||||||
|
'tgz' => [
|
||||||
|
0 => 'application/x-gzip-compressed',
|
||||||
|
],
|
||||||
|
'psd' => [
|
||||||
|
0 => 'application/x-photoshop',
|
||||||
|
1 => 'image/vnd.adobe.photoshop',
|
||||||
|
],
|
||||||
|
'exe' => [
|
||||||
|
0 => 'application/x-msdownload',
|
||||||
|
],
|
||||||
|
'js' => [
|
||||||
|
0 => 'application/x-javascript',
|
||||||
|
],
|
||||||
|
'mp3' => [
|
||||||
|
0 => 'audio/mpeg',
|
||||||
|
1 => 'audio/mpg',
|
||||||
|
2 => 'audio/mpeg3',
|
||||||
|
3 => 'audio/mp3',
|
||||||
|
],
|
||||||
|
'rar' => [
|
||||||
|
0 => 'application/x-rar',
|
||||||
|
1 => 'application/rar',
|
||||||
|
2 => 'application/x-rar-compressed',
|
||||||
|
],
|
||||||
|
'gzip' => [
|
||||||
|
0 => 'application/x-gzip',
|
||||||
|
],
|
||||||
|
'hqx' => [
|
||||||
|
0 => 'application/mac-binhex40',
|
||||||
|
1 => 'application/mac-binhex',
|
||||||
|
2 => 'application/x-binhex40',
|
||||||
|
3 => 'application/x-mac-binhex40',
|
||||||
|
],
|
||||||
|
'cpt' => [
|
||||||
|
0 => 'application/mac-compactpro',
|
||||||
|
],
|
||||||
|
'bin' => [
|
||||||
|
0 => 'application/macbinary',
|
||||||
|
1 => 'application/mac-binary',
|
||||||
|
2 => 'application/x-binary',
|
||||||
|
3 => 'application/x-macbinary',
|
||||||
|
],
|
||||||
|
'oda' => [
|
||||||
|
0 => 'application/oda',
|
||||||
|
],
|
||||||
|
'ai' => [
|
||||||
|
0 => 'application/postscript',
|
||||||
|
],
|
||||||
|
'smil' => [
|
||||||
|
0 => 'application/smil',
|
||||||
|
],
|
||||||
|
'mif' => [
|
||||||
|
0 => 'application/vnd.mif',
|
||||||
|
],
|
||||||
|
'wbxml' => [
|
||||||
|
0 => 'application/wbxml',
|
||||||
|
],
|
||||||
|
'wmlc' => [
|
||||||
|
0 => 'application/wmlc',
|
||||||
|
],
|
||||||
|
'dcr' => [
|
||||||
|
0 => 'application/x-director',
|
||||||
|
],
|
||||||
|
'dvi' => [
|
||||||
|
0 => 'application/x-dvi',
|
||||||
|
],
|
||||||
|
'gtar' => [
|
||||||
|
0 => 'application/x-gtar',
|
||||||
|
],
|
||||||
|
'php' => [
|
||||||
|
0 => 'application/x-httpd-php',
|
||||||
|
1 => 'application/php',
|
||||||
|
2 => 'application/x-php',
|
||||||
|
3 => 'text/php',
|
||||||
|
4 => 'text/x-php',
|
||||||
|
5 => 'application/x-httpd-php-source',
|
||||||
|
],
|
||||||
|
'swf' => [
|
||||||
|
0 => 'application/x-shockwave-flash',
|
||||||
|
],
|
||||||
|
'sit' => [
|
||||||
|
0 => 'application/x-stuffit',
|
||||||
|
],
|
||||||
|
'z' => [
|
||||||
|
0 => 'application/x-compress',
|
||||||
|
],
|
||||||
|
'mid' => [
|
||||||
|
0 => 'audio/midi',
|
||||||
|
],
|
||||||
|
'aif' => [
|
||||||
|
0 => 'audio/x-aiff',
|
||||||
|
1 => 'audio/aiff',
|
||||||
|
],
|
||||||
|
'ram' => [
|
||||||
|
0 => 'audio/x-pn-realaudio',
|
||||||
|
],
|
||||||
|
'rpm' => [
|
||||||
|
0 => 'audio/x-pn-realaudio-plugin',
|
||||||
|
],
|
||||||
|
'ra' => [
|
||||||
|
0 => 'audio/x-realaudio',
|
||||||
|
],
|
||||||
|
'rv' => [
|
||||||
|
0 => 'video/vnd.rn-realvideo',
|
||||||
|
],
|
||||||
|
'jp2' => [
|
||||||
|
0 => 'image/jp2',
|
||||||
|
1 => 'video/mj2',
|
||||||
|
2 => 'image/jpx',
|
||||||
|
3 => 'image/jpm',
|
||||||
|
],
|
||||||
|
'tiff' => [
|
||||||
|
0 => 'image/tiff',
|
||||||
|
],
|
||||||
|
'eml' => [
|
||||||
|
0 => 'message/rfc822',
|
||||||
|
],
|
||||||
|
'pem' => [
|
||||||
|
0 => 'application/x-x509-user-cert',
|
||||||
|
1 => 'application/x-pem-file',
|
||||||
|
],
|
||||||
|
'p10' => [
|
||||||
|
0 => 'application/x-pkcs10',
|
||||||
|
1 => 'application/pkcs10',
|
||||||
|
],
|
||||||
|
'p12' => [
|
||||||
|
0 => 'application/x-pkcs12',
|
||||||
|
],
|
||||||
|
'p7a' => [
|
||||||
|
0 => 'application/x-pkcs7-signature',
|
||||||
|
],
|
||||||
|
'p7c' => [
|
||||||
|
0 => 'application/pkcs7-mime',
|
||||||
|
1 => 'application/x-pkcs7-mime',
|
||||||
|
],
|
||||||
|
'p7r' => [
|
||||||
|
0 => 'application/x-pkcs7-certreqresp',
|
||||||
|
],
|
||||||
|
'p7s' => [
|
||||||
|
0 => 'application/pkcs7-signature',
|
||||||
|
],
|
||||||
|
'crt' => [
|
||||||
|
0 => 'application/x-x509-ca-cert',
|
||||||
|
1 => 'application/pkix-cert',
|
||||||
|
],
|
||||||
|
'crl' => [
|
||||||
|
0 => 'application/pkix-crl',
|
||||||
|
1 => 'application/pkcs-crl',
|
||||||
|
],
|
||||||
|
'pgp' => [
|
||||||
|
0 => 'application/pgp',
|
||||||
|
],
|
||||||
|
'gpg' => [
|
||||||
|
0 => 'application/gpg-keys',
|
||||||
|
],
|
||||||
|
'rsa' => [
|
||||||
|
0 => 'application/x-pkcs7',
|
||||||
|
],
|
||||||
|
'ics' => [
|
||||||
|
0 => 'text/calendar',
|
||||||
|
],
|
||||||
|
'zsh' => [
|
||||||
|
0 => 'text/x-scriptzsh',
|
||||||
|
],
|
||||||
|
'cdr' => [
|
||||||
|
0 => 'application/cdr',
|
||||||
|
1 => 'application/coreldraw',
|
||||||
|
2 => 'application/x-cdr',
|
||||||
|
3 => 'application/x-coreldraw',
|
||||||
|
4 => 'image/cdr',
|
||||||
|
5 => 'image/x-cdr',
|
||||||
|
6 => 'zz-application/zz-winassoc-cdr',
|
||||||
|
],
|
||||||
|
'wma' => [
|
||||||
|
0 => 'audio/x-ms-wma',
|
||||||
|
],
|
||||||
|
'vcf' => [
|
||||||
|
0 => 'text/x-vcard',
|
||||||
|
],
|
||||||
|
'srt' => [
|
||||||
|
0 => 'text/srt',
|
||||||
|
],
|
||||||
|
'vtt' => [
|
||||||
|
0 => 'text/vtt',
|
||||||
|
],
|
||||||
|
'ico' => [
|
||||||
|
0 => 'image/x-icon',
|
||||||
|
1 => 'image/x-ico',
|
||||||
|
2 => 'image/vnd.microsoft.icon',
|
||||||
|
],
|
||||||
|
'csv' => [
|
||||||
|
0 => 'text/x-comma-separated-values',
|
||||||
|
1 => 'text/comma-separated-values',
|
||||||
|
2 => 'application/vnd.msexcel',
|
||||||
|
],
|
||||||
|
'json' => [
|
||||||
|
0 => 'application/json',
|
||||||
|
1 => 'text/json',
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ trait ResponseHandler
|
|||||||
foreach ($this->datacenter->sockets[$datacenter]->new_incoming as $current_msg_id) {
|
foreach ($this->datacenter->sockets[$datacenter]->new_incoming as $current_msg_id) {
|
||||||
$unset = false;
|
$unset = false;
|
||||||
\danog\MadelineProto\Logger::log(['Received '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].'.'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
\danog\MadelineProto\Logger::log(['Received '.$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].'.'], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
|
\danog\MadelineProto\Logger::log([$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']], \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
|
if (\danog\MadelineProto\Logger::$has_thread && is_object(\Thread::getCurrentThread())) {
|
||||||
if (!$this->synchronized(function ($zis, $datacenter, $current_msg_id) {
|
if (!$this->synchronized(function ($zis, $datacenter, $current_msg_id) {
|
||||||
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['handling'])) {
|
if (isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['handling'])) {
|
||||||
|
@ -19,394 +19,10 @@ namespace danog\MadelineProto\TL\Conversion;
|
|||||||
*/
|
*/
|
||||||
trait Extension
|
trait Extension
|
||||||
{
|
{
|
||||||
public $all_mimes = [
|
|
||||||
'png' => [
|
|
||||||
0 => 'image/png',
|
|
||||||
1 => 'image/x-png',
|
|
||||||
],
|
|
||||||
'bmp' => [
|
|
||||||
0 => 'image/bmp',
|
|
||||||
1 => 'image/x-bmp',
|
|
||||||
2 => 'image/x-bitmap',
|
|
||||||
3 => 'image/x-xbitmap',
|
|
||||||
4 => 'image/x-win-bitmap',
|
|
||||||
5 => 'image/x-windows-bmp',
|
|
||||||
6 => 'image/ms-bmp',
|
|
||||||
7 => 'image/x-ms-bmp',
|
|
||||||
8 => 'application/bmp',
|
|
||||||
9 => 'application/x-bmp',
|
|
||||||
10 => 'application/x-win-bitmap',
|
|
||||||
],
|
|
||||||
'gif' => [
|
|
||||||
0 => 'image/gif',
|
|
||||||
],
|
|
||||||
'jpeg' => [
|
|
||||||
0 => 'image/jpeg',
|
|
||||||
1 => 'image/pjpeg',
|
|
||||||
],
|
|
||||||
'xspf' => [
|
|
||||||
0 => 'application/xspf+xml',
|
|
||||||
],
|
|
||||||
'vlc' => [
|
|
||||||
0 => 'application/videolan',
|
|
||||||
],
|
|
||||||
'wmv' => [
|
|
||||||
0 => 'video/x-ms-wmv',
|
|
||||||
1 => 'video/x-ms-asf',
|
|
||||||
],
|
|
||||||
'au' => [
|
|
||||||
0 => 'audio/x-au',
|
|
||||||
],
|
|
||||||
'ac3' => [
|
|
||||||
0 => 'audio/ac3',
|
|
||||||
],
|
|
||||||
'flac' => [
|
|
||||||
0 => 'audio/x-flac',
|
|
||||||
],
|
|
||||||
'ogg' => [
|
|
||||||
0 => 'audio/ogg',
|
|
||||||
1 => 'video/ogg',
|
|
||||||
2 => 'application/ogg',
|
|
||||||
],
|
|
||||||
'kmz' => [
|
|
||||||
0 => 'application/vnd.google-earth.kmz',
|
|
||||||
],
|
|
||||||
'kml' => [
|
|
||||||
0 => 'application/vnd.google-earth.kml+xml',
|
|
||||||
],
|
|
||||||
'rtx' => [
|
|
||||||
0 => 'text/richtext',
|
|
||||||
],
|
|
||||||
'rtf' => [
|
|
||||||
0 => 'text/rtf',
|
|
||||||
],
|
|
||||||
'jar' => [
|
|
||||||
0 => 'application/java-archive',
|
|
||||||
1 => 'application/x-java-application',
|
|
||||||
2 => 'application/x-jar',
|
|
||||||
],
|
|
||||||
'zip' => [
|
|
||||||
0 => 'application/x-zip',
|
|
||||||
1 => 'application/zip',
|
|
||||||
2 => 'application/x-zip-compressed',
|
|
||||||
3 => 'application/s-compressed',
|
|
||||||
4 => 'multipart/x-zip',
|
|
||||||
],
|
|
||||||
'7zip' => [
|
|
||||||
0 => 'application/x-compressed',
|
|
||||||
],
|
|
||||||
'xml' => [
|
|
||||||
0 => 'application/xml',
|
|
||||||
1 => 'text/xml',
|
|
||||||
],
|
|
||||||
'svg' => [
|
|
||||||
0 => 'image/svg+xml',
|
|
||||||
],
|
|
||||||
'3g2' => [
|
|
||||||
0 => 'video/3gpp2',
|
|
||||||
],
|
|
||||||
'3gp' => [
|
|
||||||
0 => 'video/3gp',
|
|
||||||
1 => 'video/3gpp',
|
|
||||||
],
|
|
||||||
'mp4' => [
|
|
||||||
0 => 'video/mp4',
|
|
||||||
],
|
|
||||||
'm4a' => [
|
|
||||||
0 => 'audio/x-m4a',
|
|
||||||
],
|
|
||||||
'f4v' => [
|
|
||||||
0 => 'video/x-f4v',
|
|
||||||
],
|
|
||||||
'flv' => [
|
|
||||||
0 => 'video/x-flv',
|
|
||||||
],
|
|
||||||
'webm' => [
|
|
||||||
0 => 'video/webm',
|
|
||||||
],
|
|
||||||
'aac' => [
|
|
||||||
0 => 'audio/x-acc',
|
|
||||||
],
|
|
||||||
'm4u' => [
|
|
||||||
0 => 'application/vnd.mpegurl',
|
|
||||||
],
|
|
||||||
'pdf' => [
|
|
||||||
0 => 'application/pdf',
|
|
||||||
1 => 'application/octet-stream',
|
|
||||||
],
|
|
||||||
'pptx' => [
|
|
||||||
0 => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
||||||
],
|
|
||||||
'ppt' => [
|
|
||||||
0 => 'application/powerpoint',
|
|
||||||
1 => 'application/vnd.ms-powerpoint',
|
|
||||||
2 => 'application/vnd.ms-office',
|
|
||||||
3 => 'application/msword',
|
|
||||||
],
|
|
||||||
'docx' => [
|
|
||||||
0 => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
||||||
],
|
|
||||||
'xlsx' => [
|
|
||||||
0 => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
||||||
1 => 'application/vnd.ms-excel',
|
|
||||||
],
|
|
||||||
'xl' => [
|
|
||||||
0 => 'application/excel',
|
|
||||||
],
|
|
||||||
'xls' => [
|
|
||||||
0 => 'application/msexcel',
|
|
||||||
1 => 'application/x-msexcel',
|
|
||||||
2 => 'application/x-ms-excel',
|
|
||||||
3 => 'application/x-excel',
|
|
||||||
4 => 'application/x-dos_ms_excel',
|
|
||||||
5 => 'application/xls',
|
|
||||||
6 => 'application/x-xls',
|
|
||||||
],
|
|
||||||
'xsl' => [
|
|
||||||
0 => 'text/xsl',
|
|
||||||
],
|
|
||||||
'mpeg' => [
|
|
||||||
0 => 'video/mpeg',
|
|
||||||
],
|
|
||||||
'mov' => [
|
|
||||||
0 => 'video/quicktime',
|
|
||||||
],
|
|
||||||
'avi' => [
|
|
||||||
0 => 'video/x-msvideo',
|
|
||||||
1 => 'video/msvideo',
|
|
||||||
2 => 'video/avi',
|
|
||||||
3 => 'application/x-troff-msvideo',
|
|
||||||
],
|
|
||||||
'movie' => [
|
|
||||||
0 => 'video/x-sgi-movie',
|
|
||||||
],
|
|
||||||
'log' => [
|
|
||||||
0 => 'text/x-log',
|
|
||||||
],
|
|
||||||
'txt' => [
|
|
||||||
0 => 'text/plain',
|
|
||||||
],
|
|
||||||
'css' => [
|
|
||||||
0 => 'text/css',
|
|
||||||
],
|
|
||||||
'html' => [
|
|
||||||
0 => 'text/html',
|
|
||||||
],
|
|
||||||
'wav' => [
|
|
||||||
0 => 'audio/x-wav',
|
|
||||||
1 => 'audio/wave',
|
|
||||||
2 => 'audio/wav',
|
|
||||||
],
|
|
||||||
'xhtml' => [
|
|
||||||
0 => 'application/xhtml+xml',
|
|
||||||
],
|
|
||||||
'tar' => [
|
|
||||||
0 => 'application/x-tar',
|
|
||||||
],
|
|
||||||
'tgz' => [
|
|
||||||
0 => 'application/x-gzip-compressed',
|
|
||||||
],
|
|
||||||
'psd' => [
|
|
||||||
0 => 'application/x-photoshop',
|
|
||||||
1 => 'image/vnd.adobe.photoshop',
|
|
||||||
],
|
|
||||||
'exe' => [
|
|
||||||
0 => 'application/x-msdownload',
|
|
||||||
],
|
|
||||||
'js' => [
|
|
||||||
0 => 'application/x-javascript',
|
|
||||||
],
|
|
||||||
'mp3' => [
|
|
||||||
0 => 'audio/mpeg',
|
|
||||||
1 => 'audio/mpg',
|
|
||||||
2 => 'audio/mpeg3',
|
|
||||||
3 => 'audio/mp3',
|
|
||||||
],
|
|
||||||
'rar' => [
|
|
||||||
0 => 'application/x-rar',
|
|
||||||
1 => 'application/rar',
|
|
||||||
2 => 'application/x-rar-compressed',
|
|
||||||
],
|
|
||||||
'gzip' => [
|
|
||||||
0 => 'application/x-gzip',
|
|
||||||
],
|
|
||||||
'hqx' => [
|
|
||||||
0 => 'application/mac-binhex40',
|
|
||||||
1 => 'application/mac-binhex',
|
|
||||||
2 => 'application/x-binhex40',
|
|
||||||
3 => 'application/x-mac-binhex40',
|
|
||||||
],
|
|
||||||
'cpt' => [
|
|
||||||
0 => 'application/mac-compactpro',
|
|
||||||
],
|
|
||||||
'bin' => [
|
|
||||||
0 => 'application/macbinary',
|
|
||||||
1 => 'application/mac-binary',
|
|
||||||
2 => 'application/x-binary',
|
|
||||||
3 => 'application/x-macbinary',
|
|
||||||
],
|
|
||||||
'oda' => [
|
|
||||||
0 => 'application/oda',
|
|
||||||
],
|
|
||||||
'ai' => [
|
|
||||||
0 => 'application/postscript',
|
|
||||||
],
|
|
||||||
'smil' => [
|
|
||||||
0 => 'application/smil',
|
|
||||||
],
|
|
||||||
'mif' => [
|
|
||||||
0 => 'application/vnd.mif',
|
|
||||||
],
|
|
||||||
'wbxml' => [
|
|
||||||
0 => 'application/wbxml',
|
|
||||||
],
|
|
||||||
'wmlc' => [
|
|
||||||
0 => 'application/wmlc',
|
|
||||||
],
|
|
||||||
'dcr' => [
|
|
||||||
0 => 'application/x-director',
|
|
||||||
],
|
|
||||||
'dvi' => [
|
|
||||||
0 => 'application/x-dvi',
|
|
||||||
],
|
|
||||||
'gtar' => [
|
|
||||||
0 => 'application/x-gtar',
|
|
||||||
],
|
|
||||||
'php' => [
|
|
||||||
0 => 'application/x-httpd-php',
|
|
||||||
1 => 'application/php',
|
|
||||||
2 => 'application/x-php',
|
|
||||||
3 => 'text/php',
|
|
||||||
4 => 'text/x-php',
|
|
||||||
5 => 'application/x-httpd-php-source',
|
|
||||||
],
|
|
||||||
'swf' => [
|
|
||||||
0 => 'application/x-shockwave-flash',
|
|
||||||
],
|
|
||||||
'sit' => [
|
|
||||||
0 => 'application/x-stuffit',
|
|
||||||
],
|
|
||||||
'z' => [
|
|
||||||
0 => 'application/x-compress',
|
|
||||||
],
|
|
||||||
'mid' => [
|
|
||||||
0 => 'audio/midi',
|
|
||||||
],
|
|
||||||
'aif' => [
|
|
||||||
0 => 'audio/x-aiff',
|
|
||||||
1 => 'audio/aiff',
|
|
||||||
],
|
|
||||||
'ram' => [
|
|
||||||
0 => 'audio/x-pn-realaudio',
|
|
||||||
],
|
|
||||||
'rpm' => [
|
|
||||||
0 => 'audio/x-pn-realaudio-plugin',
|
|
||||||
],
|
|
||||||
'ra' => [
|
|
||||||
0 => 'audio/x-realaudio',
|
|
||||||
],
|
|
||||||
'rv' => [
|
|
||||||
0 => 'video/vnd.rn-realvideo',
|
|
||||||
],
|
|
||||||
'jp2' => [
|
|
||||||
0 => 'image/jp2',
|
|
||||||
1 => 'video/mj2',
|
|
||||||
2 => 'image/jpx',
|
|
||||||
3 => 'image/jpm',
|
|
||||||
],
|
|
||||||
'tiff' => [
|
|
||||||
0 => 'image/tiff',
|
|
||||||
],
|
|
||||||
'eml' => [
|
|
||||||
0 => 'message/rfc822',
|
|
||||||
],
|
|
||||||
'pem' => [
|
|
||||||
0 => 'application/x-x509-user-cert',
|
|
||||||
1 => 'application/x-pem-file',
|
|
||||||
],
|
|
||||||
'p10' => [
|
|
||||||
0 => 'application/x-pkcs10',
|
|
||||||
1 => 'application/pkcs10',
|
|
||||||
],
|
|
||||||
'p12' => [
|
|
||||||
0 => 'application/x-pkcs12',
|
|
||||||
],
|
|
||||||
'p7a' => [
|
|
||||||
0 => 'application/x-pkcs7-signature',
|
|
||||||
],
|
|
||||||
'p7c' => [
|
|
||||||
0 => 'application/pkcs7-mime',
|
|
||||||
1 => 'application/x-pkcs7-mime',
|
|
||||||
],
|
|
||||||
'p7r' => [
|
|
||||||
0 => 'application/x-pkcs7-certreqresp',
|
|
||||||
],
|
|
||||||
'p7s' => [
|
|
||||||
0 => 'application/pkcs7-signature',
|
|
||||||
],
|
|
||||||
'crt' => [
|
|
||||||
0 => 'application/x-x509-ca-cert',
|
|
||||||
1 => 'application/pkix-cert',
|
|
||||||
],
|
|
||||||
'crl' => [
|
|
||||||
0 => 'application/pkix-crl',
|
|
||||||
1 => 'application/pkcs-crl',
|
|
||||||
],
|
|
||||||
'pgp' => [
|
|
||||||
0 => 'application/pgp',
|
|
||||||
],
|
|
||||||
'gpg' => [
|
|
||||||
0 => 'application/gpg-keys',
|
|
||||||
],
|
|
||||||
'rsa' => [
|
|
||||||
0 => 'application/x-pkcs7',
|
|
||||||
],
|
|
||||||
'ics' => [
|
|
||||||
0 => 'text/calendar',
|
|
||||||
],
|
|
||||||
'zsh' => [
|
|
||||||
0 => 'text/x-scriptzsh',
|
|
||||||
],
|
|
||||||
'cdr' => [
|
|
||||||
0 => 'application/cdr',
|
|
||||||
1 => 'application/coreldraw',
|
|
||||||
2 => 'application/x-cdr',
|
|
||||||
3 => 'application/x-coreldraw',
|
|
||||||
4 => 'image/cdr',
|
|
||||||
5 => 'image/x-cdr',
|
|
||||||
6 => 'zz-application/zz-winassoc-cdr',
|
|
||||||
],
|
|
||||||
'wma' => [
|
|
||||||
0 => 'audio/x-ms-wma',
|
|
||||||
],
|
|
||||||
'vcf' => [
|
|
||||||
0 => 'text/x-vcard',
|
|
||||||
],
|
|
||||||
'srt' => [
|
|
||||||
0 => 'text/srt',
|
|
||||||
],
|
|
||||||
'vtt' => [
|
|
||||||
0 => 'text/vtt',
|
|
||||||
],
|
|
||||||
'ico' => [
|
|
||||||
0 => 'image/x-icon',
|
|
||||||
1 => 'image/x-ico',
|
|
||||||
2 => 'image/vnd.microsoft.icon',
|
|
||||||
],
|
|
||||||
'csv' => [
|
|
||||||
0 => 'text/x-comma-separated-values',
|
|
||||||
1 => 'text/comma-separated-values',
|
|
||||||
2 => 'application/vnd.msexcel',
|
|
||||||
],
|
|
||||||
'json' => [
|
|
||||||
0 => 'application/json',
|
|
||||||
1 => 'text/json',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
public function get_extension_from_mime($mime)
|
public function get_extension_from_mime($mime)
|
||||||
{
|
{
|
||||||
foreach ($this->all_mimes as $key => $value) {
|
foreach (self::ALL_MIMES as $key => $value) {
|
||||||
if (array_search($mime, (array) $value) !== false) {
|
if (array_search($mime, (array) $value) !== false) {
|
||||||
return '.'.$key;
|
return '.'.$key;
|
||||||
}
|
}
|
||||||
|
@ -14,48 +14,6 @@ namespace danog\MadelineProto\TL\Conversion;
|
|||||||
|
|
||||||
trait TD
|
trait TD
|
||||||
{
|
{
|
||||||
protected $td_params_conversion = [
|
|
||||||
'updateNewMessage' => [
|
|
||||||
'_' => 'updateNewMessage',
|
|
||||||
'disable_notification' => ['message', 'silent'],
|
|
||||||
'message' => ['message'],
|
|
||||||
],
|
|
||||||
'message' => [
|
|
||||||
'_' => 'message',
|
|
||||||
'id' => ['id'],
|
|
||||||
'sender_user_id' => ['from_id'],
|
|
||||||
'chat_id' => ['to_id', 'choose_chat_id_from_botapi'],
|
|
||||||
'send_state' => ['choose_incoming_or_sent'],
|
|
||||||
'can_be_edited' => ['choose_can_edit'],
|
|
||||||
'can_be_deleted' => ['choose_can_delete'],
|
|
||||||
'is_post' => ['post'],
|
|
||||||
'date' => ['date'],
|
|
||||||
'edit_date' => ['edit_date'],
|
|
||||||
'forward_info' => ['fwd_info', 'choose_forward_info'],
|
|
||||||
'reply_to_message_id' => ['reply_to_msg_id'],
|
|
||||||
'ttl' => ['choose_ttl'],
|
|
||||||
'ttl_expires_in' => ['choose_ttl_expires_in'],
|
|
||||||
'via_bot_user_id' => ['via_bot_id'],
|
|
||||||
'views' => ['views'],
|
|
||||||
'content' => ['choose_message_content'],
|
|
||||||
'reply_markup' => ['reply_markup'],
|
|
||||||
],
|
|
||||||
|
|
||||||
'messages.sendMessage' => [
|
|
||||||
'chat_id' => ['peer'],
|
|
||||||
'reply_to_message_id' => ['reply_to_msg_id'],
|
|
||||||
'disable_notification' => ['silent'],
|
|
||||||
'from_background' => ['background'],
|
|
||||||
'input_message_content' => ['choose_message_content'],
|
|
||||||
'reply_markup' => ['reply_markup'],
|
|
||||||
],
|
|
||||||
|
|
||||||
];
|
|
||||||
protected $reverse = [
|
|
||||||
'sendMessage'=> 'messages.sendMessage',
|
|
||||||
];
|
|
||||||
protected $ignore = ['updateMessageID'];
|
|
||||||
|
|
||||||
public function tdcli_to_td(&$params, $key = null)
|
public function tdcli_to_td(&$params, $key = null)
|
||||||
{
|
{
|
||||||
if (!$this->is_array($params)) {
|
if (!$this->is_array($params)) {
|
||||||
@ -81,9 +39,9 @@ trait TD
|
|||||||
|
|
||||||
public function td_to_mtproto($params)
|
public function td_to_mtproto($params)
|
||||||
{
|
{
|
||||||
$newparams = ['_' => $this->reverse[$params['_']]];
|
$newparams = ['_' => self::REVERSE[$params['_']]];
|
||||||
|
|
||||||
foreach ($this->td_params_conversion[$newparams['_']] as $td => $mtproto) {
|
foreach (self::TD_PARAMS_CONVERSION[$newparams['_']] as $td => $mtproto) {
|
||||||
if ($this->is_array($mtproto)) {
|
if ($this->is_array($mtproto)) {
|
||||||
switch (end($mtproto)) {
|
switch (end($mtproto)) {
|
||||||
case 'choose_message_content':
|
case 'choose_message_content':
|
||||||
@ -126,10 +84,10 @@ trait TD
|
|||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
$newparams = ['_' => $params['_']];
|
$newparams = ['_' => $params['_']];
|
||||||
if ($this->in_array($params['_'], $this->ignore)) {
|
if ($this->in_array($params['_'], self::TD_IGNORE)) {
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
foreach ($this->td_params_conversion[$params['_']] as $td => $mtproto) {
|
foreach (self::TD_PARAMS_CONVERSION[$params['_']] as $td => $mtproto) {
|
||||||
if (is_string($mtproto)) {
|
if (is_string($mtproto)) {
|
||||||
$newparams[$td] = $mtproto;
|
$newparams[$td] = $mtproto;
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,7 +235,7 @@ trait TL
|
|||||||
return $tl_elem['predicate'] === 'boolTrue';
|
return $tl_elem['predicate'] === 'boolTrue';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize_object($type, $object, $layer = '')
|
public function serialize_object($type, $object, $layer = -1)
|
||||||
{
|
{
|
||||||
switch ($type['type']) {
|
switch ($type['type']) {
|
||||||
case 'int':
|
case 'int':
|
||||||
@ -390,7 +390,7 @@ trait TL
|
|||||||
return $tl['id'].$this->serialize_params($tl, $arguments);
|
return $tl['id'].$this->serialize_params($tl, $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize_params($tl, $arguments, $layer = '')
|
public function serialize_params($tl, $arguments, $layer = -1)
|
||||||
{
|
{
|
||||||
$serialized = '';
|
$serialized = '';
|
||||||
|
|
||||||
|
@ -22,76 +22,74 @@ class TLConstructor extends \Volatile
|
|||||||
public $predicate = [];
|
public $predicate = [];
|
||||||
public $type = [];
|
public $type = [];
|
||||||
public $params = [];
|
public $params = [];
|
||||||
public $layers = [];
|
public $layer = [];
|
||||||
|
public $key = 0;
|
||||||
|
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
return ['id', 'predicate', 'type', 'params', 'layers'];
|
return ['id', 'predicate', 'type', 'params', 'layer', 'key'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($json_dict, $scheme_type)
|
public function add($json_dict, $scheme_type)
|
||||||
{
|
{
|
||||||
$json_dict['id'] = 'a'.$json_dict['id'];
|
$this->id[$this->key] = $json_dict['id'];
|
||||||
$json_dict['predicate'] = (string) ((($scheme_type === 'mtproto' && $json_dict['predicate'] === 'message') ? 'MT' : '').$json_dict['predicate']);
|
$this->predicate[$this->key] = (string) ((($scheme_type === 'mtproto' && $json_dict['predicate'] === 'message') ? 'MT' : '').$json_dict['predicate']);
|
||||||
$json_dict['predicate'] .= $scheme_type === 'secret' ? $json_dict['layer'] : '';
|
$this->type[$this->key] = (($scheme_type === 'mtproto' && $json_dict['type'] === 'Message') ? 'MT' : '').$json_dict['type'];
|
||||||
$this->id[$json_dict['predicate']] = $json_dict['id'];
|
$this->params[$this->key] = $json_dict['params'];
|
||||||
$this->predicate[$json_dict['id']] = $json_dict['predicate'];
|
|
||||||
$this->type[$json_dict['id']] = (($scheme_type === 'mtproto' && $json_dict['type'] === 'Message') ? 'MT' : '').$json_dict['type'];
|
|
||||||
$this->params[$json_dict['id']] = $json_dict['params'];
|
|
||||||
$this->parse_params($json_dict['id'], $scheme_type === 'mtproto');
|
|
||||||
if ($scheme_type === 'secret') {
|
if ($scheme_type === 'secret') {
|
||||||
$this->layers[$json_dict['layer']] = $json_dict['layer'];
|
$this->layer[$this->key] = $json_dict['layer'];
|
||||||
}
|
}
|
||||||
|
$this->parse_params($this->key, $scheme_type === 'mtproto');
|
||||||
|
$this->key++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find_by_type($type)
|
public function find_by_type($type)
|
||||||
{
|
{
|
||||||
$id = array_search($type, (array) $this->type, true);
|
$key = array_search($type, (array) $this->type, true);
|
||||||
|
|
||||||
return ($id === false) ? false : [
|
return ($key === false) ? false : [
|
||||||
'id' => substr($id, 1),
|
'id' => $this->id[$key],
|
||||||
'predicate' => $this->predicate[$id],
|
'predicate' => $this->predicate[$key],
|
||||||
'type' => $this->type[$id],
|
'type' => $this->type[$key],
|
||||||
'params' => $this->array_cast_recursive($this->params[$id]),
|
'params' => $this->array_cast_recursive($this->params[$key]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find_by_predicate($predicate, $layer = '')
|
public function find_by_predicate($predicate, $layer = -1)
|
||||||
{
|
{
|
||||||
if ($layer !== '' && !isset($this->id[$predicate.$layer])) {
|
if ($layer !== -1) {
|
||||||
foreach ($this->layers as $newlayer) {
|
$newlayer = -1;
|
||||||
if (isset($this->id[$predicate.$newlayer]) || $newlayer > $layer) {
|
$keys = array_keys((array) $this->predicate, $predicate);
|
||||||
break;
|
foreach ($keys as $k) {
|
||||||
|
if ($this->layer[$k] <= $layer && $this->layer[$k] > $newlayer) {
|
||||||
|
$key = $k;
|
||||||
|
$newlayer = $this->layer[$k];
|
||||||
|
}
|
||||||
|
if (!isset($key)) {
|
||||||
|
$key = $keys[0];
|
||||||
}
|
}
|
||||||
$nlayer = $newlayer;
|
|
||||||
}
|
}
|
||||||
$layer = $nlayer;
|
} else {
|
||||||
|
$key = array_search($predicate, (array) $this->predicate, true);
|
||||||
}
|
}
|
||||||
if (!isset($this->id[$predicate.$layer])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$id = $this->id[$predicate.$layer];
|
|
||||||
|
|
||||||
return [
|
return ($key === false) ? false : [
|
||||||
'id' => substr($id, 1),
|
'id' => $this->id[$key],
|
||||||
'predicate' => $this->predicate[$id],
|
'predicate' => $this->predicate[$key],
|
||||||
'type' => $this->type[$id],
|
'type' => $this->type[$key],
|
||||||
'params' => $this->array_cast_recursive($this->params[$id]),
|
'params' => $this->array_cast_recursive($this->params[$key]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find_by_id($oid)
|
public function find_by_id($id)
|
||||||
{
|
{
|
||||||
$id = 'a'.$oid;
|
$key = array_search($id, (array) $this->id, true);
|
||||||
if (!isset($this->predicate[$id])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return ($key === false) ? false : [
|
||||||
'id' => $oid,
|
'id' => $this->id[$key],
|
||||||
'predicate' => $this->predicate[$id],
|
'predicate' => $this->predicate[$key],
|
||||||
'type' => $this->type[$id],
|
'type' => $this->type[$key],
|
||||||
'params' => $this->array_cast_recursive($this->params[$id]),
|
'params' => $this->array_cast_recursive($this->params[$key]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,54 +22,49 @@ class TLMethod extends \Volatile
|
|||||||
public $type = [];
|
public $type = [];
|
||||||
public $params = [];
|
public $params = [];
|
||||||
public $method_namespace = [];
|
public $method_namespace = [];
|
||||||
|
public $key = 0;
|
||||||
|
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
return ['id', 'method', 'type', 'params', 'method_namespace'];
|
return ['id', 'method', 'type', 'params', 'method_namespace', 'key'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($json_dict)
|
public function add($json_dict)
|
||||||
{
|
{
|
||||||
$json_dict['id'] = 'a'.$json_dict['id'];
|
$this->id[$this->key] = $json_dict['id'];
|
||||||
$this->id[$json_dict['method']] = $json_dict['id'];
|
$this->method[$this->key] = $json_dict['method'];
|
||||||
$this->method[$json_dict['id']] = $json_dict['method'];
|
$this->type[$this->key] = $json_dict['type'];
|
||||||
$this->type[$json_dict['id']] = $json_dict['type'];
|
$this->params[$this->key] = $json_dict['params'];
|
||||||
$this->params[$json_dict['id']] = $json_dict['params'];
|
|
||||||
$namespace = explode('.', $json_dict['method']);
|
$namespace = explode('.', $json_dict['method']);
|
||||||
if (isset($namespace[1])) {
|
if (isset($namespace[1])) {
|
||||||
$this->method_namespace[$namespace[1]] = $namespace[0];
|
$this->method_namespace[$namespace[1]] = $namespace[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parse_params($json_dict['id']);
|
$this->parse_params($this->key);
|
||||||
|
$this->key++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find_by_method($method)
|
public function find_by_method($method)
|
||||||
{
|
{
|
||||||
if (!isset($this->id[$method])) {
|
$key = array_search($method, (array) $this->method, true);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$id = $this->id[$method];
|
|
||||||
|
|
||||||
return [
|
return ($key === false) ? false : [
|
||||||
'id' => substr($id, 1),
|
'id' => $this->id[$key],
|
||||||
'method' => $this->method[$id],
|
'method' => $this->method[$key],
|
||||||
'type' => $this->type[$id],
|
'type' => $this->type[$key],
|
||||||
'params' => $this->array_cast_recursive($this->params[$id]),
|
'params' => $this->array_cast_recursive($this->params[$key]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find_by_id($oid)
|
public function find_by_id($id)
|
||||||
{
|
{
|
||||||
$id = 'a'.$oid;
|
$key = array_search($id, (array) $this->id, true);
|
||||||
if (!isset($this->method[$id])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return ($key === false) ? false : [
|
||||||
'id' => $oid,
|
'id' => $this->id[$key],
|
||||||
'method' => $this->method[$id],
|
'method' => $this->method[$key],
|
||||||
'type' => $this->type[$id],
|
'type' => $this->type[$key],
|
||||||
'params' => $this->array_cast_recursive($this->params[$id]),
|
'params' => $this->array_cast_recursive($this->params[$key]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loadingโฆ
Reference in New Issue
Block a user