1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-02 21:47:49 +01:00
MadelineProto/tools/build_docs/layerUpgrade.php

42 lines
1.0 KiB
PHP
Raw Normal View History

2022-12-29 20:40:06 +01:00
<?php declare(strict_types=1);
2020-06-16 17:52:55 +02:00
/**
* Upgrade layer number.
*
* @param integer $layer Layer number
2023-08-13 15:47:21 +02:00
* @internal
2020-06-16 17:52:55 +02:00
*/
function layerUpgrade(int $layer): void
{
2022-12-08 20:16:40 +01:00
$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);
2020-06-16 17:52:55 +02:00
2023-01-27 14:20:47 +01:00
array_map(unlink::class, glob('src/*.tl'));
2023-09-06 17:45:58 +02:00
foreach (['TL_mtproto_v1', "TL_telegram_v$layer", 'TL_secret'] as $schema) {
2023-01-27 14:20:47 +01:00
copy("schemas/$schema.tl", "src/$schema.tl");
2020-06-16 17:52:55 +02:00
}
2023-01-27 14:20:47 +01:00
$doc = file_get_contents('src/Settings/TLSchema.php');
2022-12-08 20:16:40 +01:00
preg_match("/layer = (\d+)/", $doc, $matches);
2020-06-16 17:52:55 +02:00
$prevLayer = (int) $matches[1];
if ($prevLayer === $layer) {
return;
}
2022-12-08 20:16:40 +01:00
$doc = str_replace(
2020-06-16 17:52:55 +02:00
[
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
2023-01-27 14:20:47 +01:00
file_put_contents('src/Settings/TLSchema.php', $doc);
2020-06-16 17:52:55 +02:00
}