MadelineProto/tools/build_docs/layerUpgrade.php

43 lines
1.1 KiB
PHP
Raw Normal View History

2020-06-16 17:52:55 +02:00
<?php
/**
* Upgrade layer number.
*
* @param integer $layer Layer number
*
* @return void
*/
function layerUpgrade(int $layer): void
{
$doc = \file_get_contents('docs/docs/docs/USING_METHODS.md');
$doc = \preg_replace('|here \(layer \d+\)|', "here (layer $layer)", $doc);
\file_put_contents('docs/docs/docs/USING_METHODS.md', $doc);
\array_map(unlink::class, \glob('src/danog/MadelineProto/*.tl'));
foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret', 'TL_botAPI'] as $schema) {
\copy("schemas/$schema.tl", "src/danog/MadelineProto/$schema.tl");
}
2020-09-24 20:49:34 +02:00
$doc = \file_get_contents('src/danog/MadelineProto/Settings/TLSchema.php');
\preg_match("/layer = (\d+)/", $doc, $matches);
2020-06-16 17:52:55 +02:00
$prevLayer = (int) $matches[1];
if ($prevLayer === $layer) {
return;
}
$doc = \str_replace(
[
2020-09-24 20:49:34 +02:00
"layer = $prevLayer",
2020-10-01 18:02:54 +02:00
"TL_telegram_v$prevLayer",
2020-06-16 17:52:55 +02:00
],
[
2020-09-24 20:49:34 +02:00
"layer = $layer",
2020-10-01 18:02:54 +02:00
"TL_telegram_v$layer",
2020-06-16 17:52:55 +02:00
],
$doc
);
2020-10-01 18:02:54 +02:00
\file_put_contents('src/danog/MadelineProto/Settings/TLSchema.php', $doc);
2020-06-16 17:52:55 +02:00
}