diff --git a/README.md b/README.md index 444bb57a9..3b45fa6c0 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,21 @@ $me = $MadelineProto->getSelf(); $MadelineProto->logger($me); if (!$me['bot']) { - $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]); - $MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']); + // This example uses PHP 8.0+ syntax with named arguments + $MadelineProto->messages->sendMessage(peer: '@danogentili', message: "Hi!\nThanks for creating MadelineProto (PHP 8)! <3"]); + + // This example uses PHP 7.1+ syntax with arrays + $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto (PHP 7)! <3"]); + + $MadelineProto->channels->joinChannel(channel: '@MadelineProto'); try { - $MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']); + $MadelineProto->messages->importChatInvite(hash: 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg'); } catch (\danog\MadelineProto\RPCErrorException $e) { $MadelineProto->logger($e); } - $MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']); + $MadelineProto->messages->sendMessage(peer: 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', message: 'Testing MadelineProto!'); } $MadelineProto->echo('OK, done!'); ``` @@ -186,7 +191,7 @@ You can find examples for nearly every MadelineProto function in * [Async sleep](https://docs.madelineproto.xyz/docs/ASYNC.html#async-sleep-does-not-block-the-main-thread) * [Async readline](https://docs.madelineproto.xyz/docs/ASYNC.html#async-readline-does-not-block-the-main-thread) * [Async echo](https://docs.madelineproto.xyz/docs/ASYNC.html#async-echo-does-not-block-the-main-thread) - * [MadelineProto artax HTTP client](https://docs.madelineproto.xyz/docs/ASYNC.html#madelineproto-artax-http-client) + * [MadelineProto HTTP client](https://docs.madelineproto.xyz/docs/ASYNC.html#madelineproto-http-client) * [Async forking](https://docs.madelineproto.xyz/docs/ASYNC.html#async-forking-does-green-thread-forking) * [Async flock](https://docs.madelineproto.xyz/docs/ASYNC.html#async-flock) * [Combining async operations](https://docs.madelineproto.xyz/docs/ASYNC.html#combining-async-operations) @@ -198,6 +203,16 @@ You can find examples for nearly every MadelineProto function in * [GenericLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#genericloop) * [PeriodicLoop](https://docs.madelineproto.xyz/docs/ASYNC.html#periodicloop) * [Using methods](https://docs.madelineproto.xyz/docs/USING_METHODS.html) + * [Named arguments (PHP 8+)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#named-arguments) + * [Peers](https://docs.madelineproto.xyz/docs/USING_METHODS.html#peers) + * [Files](https://docs.madelineproto.xyz/docs/FILES.html) + * [Secret chats](https://docs.madelineproto.xyz/docs/USING_METHODS.html#secret-chats) + * [Entities (Markdown & HTML)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#entities) + * [reply_markup (keyboards & inline keyboards)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#reply_markup) + * [bot API objects](https://docs.madelineproto.xyz/docs/USING_METHODS.html#bot-api-objects) + * [No result](https://docs.madelineproto.xyz/docs/USING_METHODS.html#no-result) + * [Queues](https://docs.madelineproto.xyz/docs/USING_METHODS.html#queues) + * [Multiple method calls](https://docs.madelineproto.xyz/docs/USING_METHODS.html#multiple-method-calls) * [FULL API Documentation with descriptions](https://docs.madelineproto.xyz/API_docs/methods/) * [Logout](https://docs.madelineproto.xyz/logout.html) * [Login](https://docs.madelineproto.xyz/docs/LOGIN.html) @@ -595,15 +610,6 @@ You can find examples for nearly every MadelineProto function in * When client-side passcode lock feature is enabled, will not show message texts in incoming PUSH notifications: account.updateDeviceLocked * Whether the user will receive notifications when contacts sign up: account.getContactSignUpNotification * Unpin all pinned messages: messages.unpinAllMessages - * [Peers](https://docs.madelineproto.xyz/docs/USING_METHODS.html#peers) - * [Files](https://docs.madelineproto.xyz/docs/FILES.html) - * [Secret chats](https://docs.madelineproto.xyz/docs/USING_METHODS.html#secret-chats) - * [Entities (Markdown & HTML)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#entities) - * [reply_markup (keyboards & inline keyboards)](https://docs.madelineproto.xyz/docs/USING_METHODS.html#reply_markup) - * [bot API objects](https://docs.madelineproto.xyz/docs/USING_METHODS.html#bot-api-objects) - * [No result](https://docs.madelineproto.xyz/docs/USING_METHODS.html#no-result) - * [Queues](https://docs.madelineproto.xyz/docs/USING_METHODS.html#queues) - * [Multiple method calls](https://docs.madelineproto.xyz/docs/USING_METHODS.html#multiple-method-calls) * [Contributing](https://docs.madelineproto.xyz/docs/CONTRIB.html) * [Translation](https://docs.madelineproto.xyz/docs/CONTRIB.html#translation) * [Contribution guide](https://docs.madelineproto.xyz/docs/CONTRIB.html#contribution-guide) diff --git a/docs b/docs index d42533632..66534a555 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit d42533632b84d3c1ac4b121b2462b2797cb7b5b0 +Subproject commit 66534a555ecf7967127876d21cb84b2e300db6d9 diff --git a/src/danog/MadelineProto/DocsBuilder.php b/src/danog/MadelineProto/DocsBuilder.php index b6946d8ae..1ea3ddf33 100644 --- a/src/danog/MadelineProto/DocsBuilder.php +++ b/src/danog/MadelineProto/DocsBuilder.php @@ -27,6 +27,7 @@ class DocsBuilder { const DEFAULT_TEMPLATES = [ 'User' => ['User', 'InputUser', 'Chat', 'InputChannel', 'Peer', 'InputDialogPeer', 'DialogPeer', 'InputPeer', 'NotifyPeer', 'InputNotifyPeer'], + 'ReplyMarkup' => ['ReplyMarkup'], 'InputFile' => ['InputFile', 'InputEncryptedFile'], 'InputEncryptedChat' => ['InputEncryptedChat'], 'PhoneCall' => ['PhoneCall'], diff --git a/src/danog/MadelineProto/DocsBuilder/Constructors.php b/src/danog/MadelineProto/DocsBuilder/Constructors.php index ab13e1997..f0bb17062 100644 --- a/src/danog/MadelineProto/DocsBuilder/Constructors.php +++ b/src/danog/MadelineProto/DocsBuilder/Constructors.php @@ -203,13 +203,13 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png'.$redi '; $example = ''; if (!isset($this->settings['td'])) { - $example = $this->template('constructor-example', \str_replace('.', '_', $constructor.$layer), $params, $lua_params); if ($hasreplymarkup) { - $example .= $this->template('reply_markup'); + $example = $this->template('reply_markup'); } if ($hasentities) { - $example .= $this->template('parse_mode'); + $example = $this->template('parse_mode'); } + $example .= $this->template('constructor-example', \str_replace('.', '_', $constructor.$layer), $params, $lua_params); } \file_put_contents('constructors/'.$constructor.$layer.'.md', $header.$table.$type.$example); } diff --git a/src/danog/MadelineProto/DocsBuilder/Methods.php b/src/danog/MadelineProto/DocsBuilder/Methods.php index 4b838082a..18a65999b 100644 --- a/src/danog/MadelineProto/DocsBuilder/Methods.php +++ b/src/danog/MadelineProto/DocsBuilder/Methods.php @@ -82,7 +82,7 @@ trait Methods $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', 'int', 'long', 'int128', 'int256', 'int512', 'int53']) ? 'types' : 'constructors'; $param[$type_or_subtype] = \str_replace(['true', 'false'], ['Bool', 'Bool'], $param[$type_or_subtype]); $param[$type_or_subtype] = '['.StrTools::markdownEscape($param[$type_or_subtype]).'](/API_docs/'.$type_or_bare_type.'/'.$param[$type_or_subtype].'.md)'; - $params .= "'".$param['name']."' => ".(isset($param['subtype']) ? '\\['.$param[$type_or_subtype].'\\]' : $param[$type_or_subtype]).', '; + $params .= $param['name'].": ".(isset($param['subtype']) ? '\\['.$param[$type_or_subtype].'\\]' : $param[$type_or_subtype]).', '; } if (!isset($this->tdDescriptions['methods'][$method])) { $this->addToLang('method_'.$method); @@ -178,7 +178,7 @@ trait Methods $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 .= $param['name'].": "; $params .= (isset($param['subtype']) ? '['.$pptype.', '.$pptype.']' : $pptype).', '; $json_params .= '"'.$param['name'].'": '.(isset($param['subtype']) ? '['.$ppptype.']' : $ppptype).', '; $pwr_params .= $param['name'].' - Json encoded '.(isset($param['subtype']) ? ' array of '.$ptype : $ptype)."\n\n"; @@ -194,7 +194,7 @@ trait Methods $hasentities = true; $table .= '|parse\\_mode| [string](/API_docs/types/string.md) | Whether to parse HTML or Markdown markup in the message| Optional | '; - $params .= "'parse_mode' => 'string', "; + $params .= "parse_mode: 'string', "; $lua_params .= "parseMode='string', "; $json_params .= '"parseMode": "string"'; $pwr_params = "parseMode - string\n";