From 7421e6182d27da2f1cc9239047eaf4b1050e4fe6 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 4 Jun 2019 23:39:00 +0200 Subject: [PATCH] More docs --- docs/docs/CHAT_INFO.md | 8 ++++---- docs/docs/DIALOGS.md | 27 ++++++--------------------- docs/docs/LOGIN.md | 2 +- docs/docs/SECRET_CHATS.md | 10 +++++----- docs/get_full_dialogs.md | 23 +++++++++++++++++++++++ docs/update_2FA.md | 22 ++++++++++++++++++++++ 6 files changed, 61 insertions(+), 31 deletions(-) create mode 100644 docs/get_full_dialogs.md create mode 100644 docs/update_2FA.md diff --git a/docs/docs/CHAT_INFO.md b/docs/docs/CHAT_INFO.md index 938db4f9..3345e9d2 100644 --- a/docs/docs/CHAT_INFO.md +++ b/docs/docs/CHAT_INFO.md @@ -7,9 +7,9 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png There are various methods that can be used to fetch info about chats, based on bot API id, tg-cli ID, Peer, User, Chat objects. -* [Full chat info with full list of participants](#get_pwr_chat) -* [Full chat info](#get_full_info) -* [Reduced chat info (very fast)](#get_info) +* [Full chat info with full list of participants](#get_pwr_chat-now-fully-async) +* [Full chat info](#get_full_info-now-fully-async) +* [Reduced chat info (very fast)](#get_info-now-fully-async) ## get_pwr_chat ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) ```php @@ -47,4 +47,4 @@ You can also use `get_info` to get chat info, see [here for the parameters and t * Speed: very fast * Caching: full -Next section \ No newline at end of file +Next section diff --git a/docs/docs/DIALOGS.md b/docs/docs/DIALOGS.md index ff55e291..c0e0f00d 100644 --- a/docs/docs/DIALOGS.md +++ b/docs/docs/DIALOGS.md @@ -7,11 +7,10 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png There are two ways to get a list of all chats, depending if you logged in as a user, or as a bot. -* [As user](#user-get_dialogs) - * [Full dialog info](#user-get_full_dialogs) -* [As bot](#bot-internal-peer-database) +* [Dialog list](#get_dialogs-now-fully-async) +* [Full dialog info](#get_full_dialogs-now-fully-async) -## User: get_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) +## get_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) ```php $dialogs = yield $MadelineProto->get_dialogs(); foreach ($dialogs as $peer) { @@ -21,28 +20,14 @@ foreach ($dialogs as $peer) { `get_dialogs` will return a full list of all chats you're member of, see [here for the parameters and the result](https://docs.madelineproto.xyz/get_dialogs.html) -## User: get_full_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) +## get_full_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) ```php $dialogs = yield $MadelineProto->get_full_dialogs(); foreach ($dialogs as $dialog) { - \danog\MadelineProto\Logger::log($dialog); + $MadelineProto->logger($dialog); } ``` `get_full_dialogs` will return a full list of all chats you're member of, including dialog info (such as the pinned/last message ID, unread count, tag count, notification settings and message drafts) see [here for the parameters and the result](https://docs.madelineproto.xyz/get_full_dialogs.html) -## Bot: internal peer database -```php -foreach ($MadelineProto->API->chats as $bot_api_id => $chat) { - try { - yield $MadelineProto->messages->sendMessage(['peer' => $chat, 'message' => "Hi $bot_api_id! Testing MadelineProto broadcasting!"]); - } catch (\danog\MadelineProto\RPCErrorException $e) { - echo $e; - } -} -``` - -Since bots cannot run `get_dialogs`, you must make use of the internal MadelineProto database to get a list of all users, chats and channels MadelineProto has seen. -`$MadelineProto->API->chats` contains a list of [Chat](../API_docs/types/Chat.html) and [User](../API_docs/types/User.html) objects, indexed by bot API id. - -Next section \ No newline at end of file +Next section diff --git a/docs/docs/LOGIN.md b/docs/docs/LOGIN.md index 59ea48f0..276570e8 100644 --- a/docs/docs/LOGIN.md +++ b/docs/docs/LOGIN.md @@ -7,7 +7,7 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png There are many ways you can login with MadelineProto. -* [Automatic](#automatic) +* [Automatic](#automatic-now-fully-async) * [Manual (user)](#manual-user) * [Manual (bot)](#manual-bot) * [Logout](#logout) diff --git a/docs/docs/SECRET_CHATS.md b/docs/docs/SECRET_CHATS.md index 683e7dc1..3b42df83 100644 --- a/docs/docs/SECRET_CHATS.md +++ b/docs/docs/SECRET_CHATS.md @@ -7,10 +7,10 @@ image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png MadelineProto provides wrappers to work with secret chats. -* [Requesting secret chats](#requesting-secret-chats) -* [Accepting secret chats](#accepting-secret-chats) -* [Checking secret chat status](#checking-secret-chat-status) -* [Sending secret messages](#sending-secret-messages) +* [Requesting secret chats](#requesting-secret-chats-now-fully-async) +* [Accepting secret chats](#accepting-secret-chats-now-fully-async) +* [Checking secret chat status](#checking-secret-chat-status-now-fully-async) +* [Sending secret messages](#sending-secret-messages-now-fully-async) ## Requesting secret chats ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)) @@ -71,4 +71,4 @@ $secret_chat = yield $MadelineProto->get_secret_chat($chat); This method gets info about a certain chat. -Next section \ No newline at end of file +Next section diff --git a/docs/get_full_dialogs.md b/docs/get_full_dialogs.md new file mode 100644 index 00000000..d3431fbb --- /dev/null +++ b/docs/get_full_dialogs.md @@ -0,0 +1,23 @@ +--- +title: get_full_dialogs +description: get_full_dialogs parameters, return type and example +--- +## Method: get_dialogs + +Gets full list of dialogs + +### Return type: Array of [Dialog objects](API_docs/types/Dialog.md) + +### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)): + + +```php +$Dialogs = yield $MadelineProto->get_full_dialogs(); +``` + +Or, if you're into Lua: + +```lua +Dialogs = get_full_dialogs() +``` + diff --git a/docs/update_2FA.md b/docs/update_2FA.md new file mode 100644 index 00000000..c416acf5 --- /dev/null +++ b/docs/update_2FA.md @@ -0,0 +1,22 @@ +--- +title: update_2fa +description: Update 2FA password +--- +## Method: update_2fa + +The params array can contain password (current password), new_password, email (optional) and hint params. + +### Parameters: + +| Name | Type | +|----------|---------------| +|params|An array of parameters| + +### Return type: [Bool](API_docs/types/Bool.md) + +### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)): + + +```php +$result = yield $MadelineProto->update_2fa(['password' => 'current password', 'new_password' => 'New password', 'email' => 'daniil@daniil.it', 'hint' => 'ponies']); +```