2017-08-18 18:10:30 +02:00
< ? php
2018-02-24 17:54:13 +01:00
Merge alpha into master (async, huge bugfixes and more) (#546)
* Implement async and lots of bugfixes
* Implement more async
* Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr
* Apply fixes from StyleCI
* Bugfixes
* Apply fixes from StyleCI
* Bugfixes, implement combined promises
* Apply fixes from StyleCI
* Support passing method arguments as callable
* Starting to write async upload logic
* Apply fixes from StyleCI
* Start implementing async file upload
* Apply fixes from StyleCI
* bugfix
* Apply fixes from StyleCI
* Start rewriting connection module
* Add PHP file docblocks for all classes
* Start working on new async stream API
* Finish writing stream API
* More stream API fixes
* Apply fixes from StyleCI
* Rewrite DataCenter and Connection modules
* Clean up stream API documentation
* Fixes
* Apply fixes from StyleCI
* Add referenced parameter to get length of buffer to read in getReadBuffer API
* Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar
* Start fixing reads
* Fix all protocol stream wrappers
* Apply fixes from StyleCI
* Implement disconnection, and remove end function
* Working async RPC
* Implement async file upload
* Bugfix
* Method recall bugfixes
* Bugfixes
* Trait bugfixes
* Fix FIFO buffer
* Bugfixes and speedtests
* Async logging
* Implement websocket streams
* Implement loop API, signal API, clean closing and start changing layer
* Small magna, websocket and HTTP fixes
* Clean up loop API
* Improved stack traces, 2FA and async
* Login fixes
* Added instructions for manual verification
* Small fixes
* More app info improvements
* More app info improvements
* TL and 2FA fixes
* Update to layer 89
* More bugfixes
* Implement broken media reporting
* Remove debug comments
* PHP 7.2 backwards compatibility
* Bugfixes
* Async key generation
* Some simplifications
* Transport fixes
* Cleanup
* async API
* Performance fixes
* Fixes to async API
* Bugfixes
* Implement one-time async loop
* Authorization and logging fixes
* Update to layer 91
* 7to5 fix
* Null coalesce conversion
* Implement socks5 proxy
* Implement HTTP proxy
* Fixes to HTTP proxy
* MTProxy and socks5 fixes
* Disable PHP 5 conversion
* Proxies have higher priority
* Avoid error handling in vendor
* Override composer dependencies
* Fix travis build
* Final composer fixes
* Proxy logic fixes
* Fix get_updates update handling
* Do not use parallel file driver if not supported
* Refactor loader and implement HTTP fixes
* Suppress errors in loader
* HTTP and authorization fixes
* HTTP fixes
* Improved peer management
* Use HTTP protocol on altervista
* Small bugfixes
* Minor fixes
* Docufix
* Docufix
* Legacy fixes
* Fix message queue
* Avoid updating if using MTProxy
* Improve logs and examples
* Trim final newlines while converting parse mode
* Reimplement noResponse flag
* Async combined event handler and APIFactory fixes
* Actually return config
* Case-insensitive methods
* Bugfix
* Apply fixes from StyleCI (#545)
* MTProxy fixes
* PHP 5 warning
* Improved PHP 5 warning
* Use <br> along with newlines in web logs
* Update docs
2018-12-26 20:51:14 +01:00
/**
* Constructors module .
*
* This file is part of MadelineProto .
* MadelineProto is free software : you can redistribute it and / or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation , either version 3 of the License , or ( at your option ) any later version .
* MadelineProto is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
* See the GNU Affero General Public License for more details .
* You should have received a copy of the GNU General Public License along with MadelineProto .
* If not , see < http :// www . gnu . org / licenses />.
*
* @ author Daniil Gentili < daniil @ daniil . it >
2020-02-17 14:13:46 +01:00
* @ copyright 2016 - 2020 Daniil Gentili < daniil @ daniil . it >
Merge alpha into master (async, huge bugfixes and more) (#546)
* Implement async and lots of bugfixes
* Implement more async
* Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr
* Apply fixes from StyleCI
* Bugfixes
* Apply fixes from StyleCI
* Bugfixes, implement combined promises
* Apply fixes from StyleCI
* Support passing method arguments as callable
* Starting to write async upload logic
* Apply fixes from StyleCI
* Start implementing async file upload
* Apply fixes from StyleCI
* bugfix
* Apply fixes from StyleCI
* Start rewriting connection module
* Add PHP file docblocks for all classes
* Start working on new async stream API
* Finish writing stream API
* More stream API fixes
* Apply fixes from StyleCI
* Rewrite DataCenter and Connection modules
* Clean up stream API documentation
* Fixes
* Apply fixes from StyleCI
* Add referenced parameter to get length of buffer to read in getReadBuffer API
* Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar
* Start fixing reads
* Fix all protocol stream wrappers
* Apply fixes from StyleCI
* Implement disconnection, and remove end function
* Working async RPC
* Implement async file upload
* Bugfix
* Method recall bugfixes
* Bugfixes
* Trait bugfixes
* Fix FIFO buffer
* Bugfixes and speedtests
* Async logging
* Implement websocket streams
* Implement loop API, signal API, clean closing and start changing layer
* Small magna, websocket and HTTP fixes
* Clean up loop API
* Improved stack traces, 2FA and async
* Login fixes
* Added instructions for manual verification
* Small fixes
* More app info improvements
* More app info improvements
* TL and 2FA fixes
* Update to layer 89
* More bugfixes
* Implement broken media reporting
* Remove debug comments
* PHP 7.2 backwards compatibility
* Bugfixes
* Async key generation
* Some simplifications
* Transport fixes
* Cleanup
* async API
* Performance fixes
* Fixes to async API
* Bugfixes
* Implement one-time async loop
* Authorization and logging fixes
* Update to layer 91
* 7to5 fix
* Null coalesce conversion
* Implement socks5 proxy
* Implement HTTP proxy
* Fixes to HTTP proxy
* MTProxy and socks5 fixes
* Disable PHP 5 conversion
* Proxies have higher priority
* Avoid error handling in vendor
* Override composer dependencies
* Fix travis build
* Final composer fixes
* Proxy logic fixes
* Fix get_updates update handling
* Do not use parallel file driver if not supported
* Refactor loader and implement HTTP fixes
* Suppress errors in loader
* HTTP and authorization fixes
* HTTP fixes
* Improved peer management
* Use HTTP protocol on altervista
* Small bugfixes
* Minor fixes
* Docufix
* Docufix
* Legacy fixes
* Fix message queue
* Avoid updating if using MTProxy
* Improve logs and examples
* Trim final newlines while converting parse mode
* Reimplement noResponse flag
* Async combined event handler and APIFactory fixes
* Actually return config
* Case-insensitive methods
* Bugfix
* Apply fixes from StyleCI (#545)
* MTProxy fixes
* PHP 5 warning
* Improved PHP 5 warning
* Use <br> along with newlines in web logs
* Update docs
2018-12-26 20:51:14 +01:00
* @ license https :// opensource . org / licenses / AGPL - 3.0 AGPLv3
*
2019-10-31 15:07:35 +01:00
* @ link https :// docs . madelineproto . xyz MadelineProto documentation
Merge alpha into master (async, huge bugfixes and more) (#546)
* Implement async and lots of bugfixes
* Implement more async
* Implement async, implement bugfixes for the connection module, for the datacenter module, huge bugfixes, huge perfomance improvements, media DCs for https, advanced selecting, custom var_dump, totally rewritten IOLoop and response mechanism, promises, improvements to the TL parser, custom mb_substr
* Apply fixes from StyleCI
* Bugfixes
* Apply fixes from StyleCI
* Bugfixes, implement combined promises
* Apply fixes from StyleCI
* Support passing method arguments as callable
* Starting to write async upload logic
* Apply fixes from StyleCI
* Start implementing async file upload
* Apply fixes from StyleCI
* bugfix
* Apply fixes from StyleCI
* Start rewriting connection module
* Add PHP file docblocks for all classes
* Start working on new async stream API
* Finish writing stream API
* More stream API fixes
* Apply fixes from StyleCI
* Rewrite DataCenter and Connection modules
* Clean up stream API documentation
* Fixes
* Apply fixes from StyleCI
* Add referenced parameter to get length of buffer to read in getReadBuffer API
* Moved all MessageHandler code in the Connection module, added a PHP version warning in the phar
* Start fixing reads
* Fix all protocol stream wrappers
* Apply fixes from StyleCI
* Implement disconnection, and remove end function
* Working async RPC
* Implement async file upload
* Bugfix
* Method recall bugfixes
* Bugfixes
* Trait bugfixes
* Fix FIFO buffer
* Bugfixes and speedtests
* Async logging
* Implement websocket streams
* Implement loop API, signal API, clean closing and start changing layer
* Small magna, websocket and HTTP fixes
* Clean up loop API
* Improved stack traces, 2FA and async
* Login fixes
* Added instructions for manual verification
* Small fixes
* More app info improvements
* More app info improvements
* TL and 2FA fixes
* Update to layer 89
* More bugfixes
* Implement broken media reporting
* Remove debug comments
* PHP 7.2 backwards compatibility
* Bugfixes
* Async key generation
* Some simplifications
* Transport fixes
* Cleanup
* async API
* Performance fixes
* Fixes to async API
* Bugfixes
* Implement one-time async loop
* Authorization and logging fixes
* Update to layer 91
* 7to5 fix
* Null coalesce conversion
* Implement socks5 proxy
* Implement HTTP proxy
* Fixes to HTTP proxy
* MTProxy and socks5 fixes
* Disable PHP 5 conversion
* Proxies have higher priority
* Avoid error handling in vendor
* Override composer dependencies
* Fix travis build
* Final composer fixes
* Proxy logic fixes
* Fix get_updates update handling
* Do not use parallel file driver if not supported
* Refactor loader and implement HTTP fixes
* Suppress errors in loader
* HTTP and authorization fixes
* HTTP fixes
* Improved peer management
* Use HTTP protocol on altervista
* Small bugfixes
* Minor fixes
* Docufix
* Docufix
* Legacy fixes
* Fix message queue
* Avoid updating if using MTProxy
* Improve logs and examples
* Trim final newlines while converting parse mode
* Reimplement noResponse flag
* Async combined event handler and APIFactory fixes
* Actually return config
* Case-insensitive methods
* Bugfix
* Apply fixes from StyleCI (#545)
* MTProxy fixes
* PHP 5 warning
* Improved PHP 5 warning
* Use <br> along with newlines in web logs
* Update docs
2018-12-26 20:51:14 +01:00
*/
2018-02-24 17:54:39 +01:00
2017-08-18 18:10:30 +02:00
namespace danog\MadelineProto\DocsBuilder ;
2020-06-16 17:52:55 +02:00
use danog\MadelineProto\StrTools ;
2019-10-31 15:06:25 +01:00
use danog\MadelineProto\Tools ;
2017-08-18 18:10:30 +02:00
trait Constructors
{
2019-10-29 21:33:23 +01:00
public function mkConstructors ()
2017-08-18 18:11:04 +02:00
{
2020-04-05 22:22:47 +02:00
foreach ( \glob ( 'constructors/' . $this -> any ) as $unlink ) {
2019-09-02 17:08:36 +02:00
\unlink ( $unlink );
2017-08-18 18:10:30 +02:00
}
2019-09-02 17:08:36 +02:00
if ( \file_exists ( 'constructors' )) {
\rmdir ( 'constructors' );
2017-08-18 18:10:30 +02:00
}
2019-09-02 17:08:36 +02:00
\mkdir ( 'constructors' );
2017-08-18 18:10:30 +02:00
$this -> docs_constructors = [];
2018-04-08 19:53:30 +02:00
$this -> logger -> logger ( 'Generating constructors documentation...' , \danog\MadelineProto\Logger :: NOTICE );
2017-08-18 18:10:30 +02:00
$got = [];
2019-10-31 20:48:06 +01:00
foreach ( $this -> TL -> getConstructors ( $this -> td ) -> by_predicate_and_layer as $predicate => $id ) {
$data = $this -> TL -> getConstructors ( $this -> td ) -> by_id [ $id ];
2017-08-18 18:10:30 +02:00
if ( isset ( $got [ $id ])) {
$data [ 'layer' ] = '' ;
}
$got [ $id ] = '' ;
2020-04-05 22:22:47 +02:00
$layer = isset ( $data [ 'layer' ]) && $data [ 'layer' ] !== '' ? '_' . $data [ 'layer' ] : '' ;
2020-06-16 17:52:55 +02:00
$type = $data [ 'type' ];
$constructor = $data [ 'predicate' ];
$php_type = Tools :: typeEscape ( $type );
$php_constructor = Tools :: typeEscape ( $constructor );
2017-08-18 18:10:30 +02:00
if ( ! isset ( $this -> types [ $php_type ])) {
$this -> types [ $php_type ] = [ 'constructors' => [], 'methods' => []];
}
2019-09-02 17:08:36 +02:00
if ( ! \in_array ( $data , $this -> types [ $php_type ][ 'constructors' ])) {
2017-08-18 18:10:30 +02:00
$this -> types [ $php_type ][ 'constructors' ][] = $data ;
}
$params = '' ;
foreach ( $data [ 'params' ] as $param ) {
2019-09-02 17:08:36 +02:00
if ( \in_array ( $param [ 'name' ], [ 'flags' , 'random_id' , 'random_bytes' ])) {
2017-08-18 18:10:30 +02:00
continue ;
}
2017-09-28 19:38:43 +02:00
if ( $type === 'EncryptedMessage' && $param [ 'name' ] === 'bytes' && ! isset ( $this -> settings [ 'td' ])) {
2017-08-18 18:10:30 +02:00
$param [ 'name' ] = 'decrypted_message' ;
$param [ 'type' ] = 'DecryptedMessage' ;
}
$type_or_subtype = isset ( $param [ 'subtype' ]) ? 'subtype' : 'type' ;
2019-10-31 15:06:25 +01:00
$type_or_bare_type = \ctype_upper ( Tools :: end ( \explode ( '.' , $param [ $type_or_subtype ]))[ 0 ]) || \in_array ( $param [ $type_or_subtype ], [ '!X' , 'X' , 'bytes' , 'true' , 'false' , 'double' , 'string' , 'Bool' , 'int53' , 'int' , 'long' , 'int128' , 'int256' , 'int512' ]) ? 'types' : 'constructors' ;
2019-12-27 18:26:47 +01:00
$param [ $type_or_subtype ] = \str_replace ([ 'true' , 'false' ], [ 'Bool' , 'Bool' ], $param [ $type_or_subtype ]);
2019-09-02 17:08:36 +02:00
if ( \preg_match ( '/%/' , $param [ $type_or_subtype ])) {
2019-10-31 20:48:06 +01:00
$param [ $type_or_subtype ] = $this -> TL -> getConstructors ( $this -> td ) -> findByType ( \str_replace ( '%' , '' , $param [ $type_or_subtype ]))[ 'predicate' ];
2017-08-18 18:10:30 +02:00
}
2019-09-02 17:08:36 +02:00
if ( \substr ( $param [ $type_or_subtype ], - 1 ) === '>' ) {
$param [ $type_or_subtype ] = \substr ( $param [ $type_or_subtype ], 0 , - 1 );
2017-09-29 15:50:59 +02:00
}
2020-04-05 22:22:47 +02:00
$params .= " ' " . $param [ 'name' ] . " ' => " ;
$param [ $type_or_subtype ] = '[' . Tools :: markdownEscape ( $param [ $type_or_subtype ]) . '](../' . $type_or_bare_type . '/' . $param [ $type_or_subtype ] . '.md)' ;
$params .= ( isset ( $param [ 'subtype' ]) ? '\\[' . $param [ $type_or_subtype ] . '\\]' : $param [ $type_or_subtype ]) . ', ' ;
2017-08-18 18:10:30 +02:00
}
2020-06-16 17:52:55 +02:00
$md_constructor = StrTools :: markdownEscape ( $constructor . $layer );
2020-04-05 22:22:47 +02:00
$this -> docs_constructors [ $constructor ] = '[$' . $md_constructor . '](../constructors/' . $php_constructor . $layer . '.md) = \\[' . $params . '\\];<a name="' . $constructor . $layer . ' " ></a>
2017-08-18 18:10:30 +02:00
' ;
$table = empty ( $data [ 'params' ]) ? '' : ' ### Attributes:
| Name | Type | Required |
2017-08-20 11:05:56 +02:00
|----------|---------------|----------|
2017-08-18 18:10:30 +02:00
' ;
2020-06-16 17:52:55 +02:00
if ( ! isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ])) {
$this -> addToLang ( 'object_' . $constructor );
if ( \danog\MadelineProto\Lang :: $lang [ 'en' ][ 'object_' . $constructor ] !== '' ) {
$this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'description' ] = \danog\MadelineProto\Lang :: $lang [ 'en' ][ 'object_' . $constructor ];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
}
2020-06-16 17:52:55 +02:00
if ( isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ]) && ! empty ( $data [ 'params' ])) {
2017-08-18 18:10:30 +02:00
$table = ' ### Attributes:
| Name | Type | Required | Description |
2017-08-20 11:05:56 +02:00
|----------|---------------|----------|-------------|
2017-08-18 18:10:30 +02:00
' ;
}
$params = '' ;
$lua_params = '' ;
$pwr_params = '' ;
$hasreplymarkup = false ;
$hasentities = false ;
foreach ( $data [ 'params' ] as $param ) {
2019-09-02 17:08:36 +02:00
if ( \in_array ( $param [ 'name' ], [ 'flags' , 'random_id' , 'random_bytes' ])) {
2017-08-18 18:10:30 +02:00
continue ;
}
2017-09-28 19:38:43 +02:00
if ( $type === 'EncryptedMessage' && $param [ 'name' ] === 'bytes' && ! isset ( $this -> settings [ 'td' ])) {
2017-08-18 18:10:30 +02:00
$param [ 'name' ] = 'decrypted_message' ;
$param [ 'type' ] = 'DecryptedMessage' ;
}
2019-09-02 17:08:36 +02:00
if ( $type === 'DecryptedMessageMedia' && \in_array ( $param [ 'name' ], [ 'key' , 'iv' ])) {
2020-06-16 17:52:55 +02:00
unset ( \danog\MadelineProto\Lang :: $lang [ 'en' ][ 'object_' . $constructor . '_param_' . $param [ 'name' ] . '_type_' . $param [ 'type' ]]);
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
continue ;
}
2019-12-27 18:26:47 +01:00
$ptype = $param [ isset ( $param [ 'subtype' ]) ? 'subtype' : 'type' ];
2019-09-02 17:08:36 +02:00
if ( \preg_match ( '/%/' , $ptype )) {
2019-10-31 20:48:06 +01:00
$ptype = $this -> TL -> getConstructors ( $this -> td ) -> findByType ( \str_replace ( '%' , '' , $ptype ))[ 'predicate' ];
2017-08-18 18:10:30 +02:00
}
2019-10-31 15:06:25 +01:00
$type_or_bare_type = ( \ctype_upper ( Tools :: end ( \explode ( '_' , $ptype ))[ 0 ]) || \in_array ( $ptype , [ '!X' , 'X' , 'bytes' , 'true' , 'false' , 'double' , 'string' , 'Bool' , 'int53' , 'int' , 'long' , 'int128' , 'int256' , 'int512' ])) && $ptype !== 'MTmessage' ? 'types' : 'constructors' ;
2019-09-02 17:08:36 +02:00
if ( \substr ( $ptype , - 1 ) === '>' ) {
$ptype = \substr ( $ptype , 0 , - 1 );
2017-09-29 15:50:59 +02:00
}
2017-08-18 18:10:30 +02:00
switch ( $ptype ) {
case 'true' :
case 'false' :
$ptype = 'Bool' ;
}
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
$human_ptype = $ptype ;
2019-09-02 17:08:36 +02:00
if ( \strpos ( $type , 'Input' ) === 0 && \in_array ( $ptype , [ 'User' , 'InputUser' , 'Chat' , 'InputChannel' , 'Peer' , 'InputDialogPeer' , 'DialogPeer' , 'NotifyPeer' , 'InputNotifyPeer' , 'InputPeer' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'Username, chat ID, Update, Message or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2019-09-02 17:08:36 +02:00
if ( \strpos ( $type , 'Input' ) === 0 && \in_array ( $ptype , [ 'InputMedia' , 'InputDocument' , 'InputPhoto' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'MessageMedia, Message, Update or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2019-09-02 17:08:36 +02:00
if ( \in_array ( $ptype , [ 'InputMessage' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'Message ID or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2019-09-02 17:08:36 +02:00
if ( \in_array ( $ptype , [ 'InputEncryptedChat' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'Secret chat ID, Update, EncryptedMessage or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2019-09-02 17:08:36 +02:00
if ( \in_array ( $ptype , [ 'InputFile' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'File path or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2019-09-02 17:08:36 +02:00
if ( \in_array ( $ptype , [ 'InputEncryptedFile' ]) && ! isset ( $this -> settings [ 'td' ])) {
2020-04-05 22:22:47 +02:00
$human_ptype = 'File path or ' . $ptype ;
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
2020-06-16 17:52:55 +02:00
$table .= '|' . StrTools :: markdownEscape ( $param [ 'name' ]) . '|' . ( isset ( $param [ 'subtype' ]) ? 'Array of ' : '' ) . '[' . StrTools :: markdownEscape ( $human_ptype ) . '](../' . $type_or_bare_type . '/' . $ptype . '.md) | ' . ( isset ( $param [ 'pow' ]) || $this -> TL -> getConstructors ( $this -> td ) -> findByPredicate ( \lcfirst ( $param [ 'type' ]) . 'Empty' ) || $data [ 'type' ] === 'InputMedia' && $param [ 'name' ] === 'mime_type' || $data [ 'type' ] === 'DocumentAttribute' && \in_array ( $param [ 'name' ], [ 'w' , 'h' , 'duration' ]) ? 'Optional' : 'Yes' ) . '|' ;
if ( ! isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'params' ][ $param [ 'name' ]])) {
$this -> addToLang ( 'object_' . $constructor . '_param_' . $param [ 'name' ] . '_type_' . $param [ 'type' ]);
if ( isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'description' ])) {
$this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'params' ][ $param [ 'name' ]] = \danog\MadelineProto\Lang :: $lang [ 'en' ][ 'object_' . $constructor . '_param_' . $param [ 'name' ] . '_type_' . $param [ 'type' ]];
Documentation rework (#349)
* Documentation rework
* Apply fixes from StyleCI
* Documentation fixes
* Login as bot through web/cli API, allow using invite links in joinChannel, full invite links in importChatInvite and checkChatInvite, non-invite links in importChatInvite
* Apply fixes from StyleCI
* Logging fixes
* Build docs
* Add methods to modify start template, bugfix to logging and keyboard conversion
* Add TL documentator
* Document MTProto methods
* Documenting methods...
* 7% documented
* Bugfixes
* Update docs
* Update docs
* Simplify file management
* Implement automatic object conversion for media, and more awesome stuff
* Implement automatic object conversion for media, and more awesome stuff
* Implement event update handler and file upload/download callback
* Auto-detect mime type, duration, width and height of media
* Update docs
* Document new file functions
* Fix links
* Fix links
* Update bot.php to use event loop
* Implement webhook update handler and forking in main loop
* Build docs
* Better docs
* Fixes to secret chats
* Almost finished updating docs
* Bugfixes, implemented infinite loop for loop() method, almost finished docs
* Finish writing docs
* Add automatic documentation builder script
* Finished writing docs
2018-03-20 12:48:05 +01:00
}
}
2020-06-16 17:52:55 +02:00
if ( isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'params' ][ $param [ 'name' ]]) && $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'params' ][ $param [ 'name' ]]) {
$table .= $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'params' ][ $param [ 'name' ]] . '|' ;
2017-08-18 18:10:30 +02:00
}
$table .= PHP_EOL ;
2020-04-05 22:22:47 +02:00
$pptype = \in_array ( $ptype , [ 'string' , 'bytes' ]) ? " ' " . $ptype . " ' " : $ptype ;
$ppptype = \in_array ( $ptype , [ 'string' ]) ? '"' . $ptype . '"' : $ptype ;
$ppptype = \in_array ( $ptype , [ 'bytes' ]) ? '{"_": "bytes", "bytes":"base64 encoded ' . $ptype . '"}' : $ppptype ;
$params .= " , ' " . $param [ 'name' ] . " ' => " ;
$params .= isset ( $param [ 'subtype' ]) ? '[' . $pptype . ', ' . $pptype . ']' : $pptype ;
$lua_params .= ', ' . $param [ 'name' ] . '=' ;
$lua_params .= isset ( $param [ 'subtype' ]) ? '{' . $pptype . '}' : $pptype ;
$pwr_params .= ', "' . $param [ 'name' ] . '": ' . ( isset ( $param [ 'subtype' ]) ? '[' . $ppptype . ']' : $ppptype );
2017-08-18 18:10:30 +02:00
if ( $param [ 'name' ] === 'reply_markup' ) {
$hasreplymarkup = true ;
}
}
2020-06-16 17:52:55 +02:00
$params = " ['_' => ' " . $constructor . " ' " . $params . ']' ;
$lua_params = " { _=' " . $constructor . " ' " . $lua_params . '}' ;
$pwr_params = '{"_": "' . $constructor . '"' . $pwr_params . '}' ;
$description = isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ]) ? $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'description' ] : $constructor . ' attributes, type and example' ;
2020-04-05 22:22:47 +02:00
$symFile = \str_replace ( '.' , '_' , $constructor . $layer );
$redir = $symFile !== $constructor . $layer ? " \n redirect_from: /API_docs/constructors/ { $symFile } .html " : '' ;
2020-10-01 20:48:22 +02:00
$description = \rtrim ( \explode ( " \n " , $description )[ 0 ], ':' );
2017-08-18 18:10:30 +02:00
$header = ' ---
2020-06-16 17:52:55 +02:00
title : '.$constructor.'
2020-04-05 22:22:47 +02:00
description : '.$description.'
image : https :// docs . madelineproto . xyz / favicons / android - chrome - 256 x256 . png '.$redir.'
2017-08-18 18:10:30 +02:00
---
2020-06-16 17:52:55 +02:00
# Constructor: '.StrTools::markdownEscape($constructor.$layer).'
2017-08-18 18:10:30 +02:00
[ Back to constructors index ]( index . md )
' ;
$table .= '
' ;
2020-06-16 17:52:55 +02:00
if ( isset ( $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ])) {
$header .= $this -> TL -> getDescriptions ()[ 'constructors' ][ $constructor ][ 'description' ] . PHP_EOL . PHP_EOL ;
2017-08-18 18:10:30 +02:00
}
2020-06-16 17:52:55 +02:00
$type = '### Type: [' . StrTools :: markdownEscape ( $php_type ) . '](../types/' . $php_type . ' . md )
2017-08-18 18:10:30 +02:00
' ;
2017-08-25 14:43:29 +02:00
$example = '' ;
if ( ! isset ( $this -> settings [ 'td' ])) {
2020-06-16 17:52:55 +02:00
$example = $this -> template ( 'constructor-example' , $constructor . $layer , $params , $lua_params );
2017-08-25 14:43:50 +02:00
if ( $hasreplymarkup ) {
2020-06-16 17:52:55 +02:00
$example .= $this -> template ( 'reply_markup' );
2017-08-25 14:43:50 +02:00
}
if ( $hasentities ) {
2020-06-16 17:52:55 +02:00
$example .= $this -> template ( 'parse_mode' );
2017-08-25 14:43:50 +02:00
}
}
2020-04-05 22:22:47 +02:00
\file_put_contents ( 'constructors/' . $constructor . $layer . '.md' , $header . $table . $type . $example );
2017-08-18 18:10:30 +02:00
}
2018-04-08 19:53:30 +02:00
$this -> logger -> logger ( 'Generating constructors index...' , \danog\MadelineProto\Logger :: NOTICE );
2019-09-02 17:08:36 +02:00
\ksort ( $this -> docs_constructors );
2017-08-18 18:10:30 +02:00
$last_namespace = '' ;
foreach ( $this -> docs_constructors as $constructor => & $value ) {
2019-09-02 17:08:36 +02:00
$new_namespace = \preg_replace ( '/_.*/' , '' , $constructor );
2020-06-16 17:52:55 +02:00
$br = $new_namespace != $last_namespace ? " *** \n <br><br> " : '' ;
2020-04-05 22:22:47 +02:00
$value = $br . $value ;
2017-08-18 18:10:30 +02:00
$last_namespace = $new_namespace ;
}
2020-06-16 17:52:55 +02:00
\file_put_contents ( 'constructors/' . $this -> index , $this -> template ( 'constructors-index' , \implode ( '' , $this -> docs_constructors )));
2017-08-18 18:10:30 +02:00
}
2018-02-24 17:54:39 +01:00
}