MadelineProtoDocs/docs/docs/DIALOGS.md

33 lines
1.5 KiB
Markdown
Raw Normal View History

2018-04-11 14:17:45 +02:00
---
title: Getting all chats (dialogs)
description: There are two ways to get a list of all chats, depending if you logged in as a user, or as a bot.
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
2018-04-01 13:19:25 +02:00
# Getting all chats (dialogs)
There are two ways to get a list of all chats, depending if you logged in as a user, or as a bot.
2019-06-04 23:39:00 +02:00
* [Dialog list](#get_dialogs-now-fully-async)
* [Full dialog info](#get_full_dialogs-now-fully-async)
2018-04-01 13:19:25 +02:00
2019-06-04 23:39:00 +02:00
## get_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html))
2018-04-01 13:19:25 +02:00
```php
2019-10-29 22:23:35 +01:00
$dialogs = yield $MadelineProto->getDialogs();
2018-04-01 13:19:25 +02:00
foreach ($dialogs as $peer) {
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => $peer, 'message' => 'Hi! Testing MadelineProto broadcasting!']);
2018-04-01 13:19:25 +02:00
}
```
2019-10-29 22:23:35 +01:00
`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/getDialogs.html)
2018-04-01 13:19:25 +02:00
2019-06-04 23:39:00 +02:00
## get_full_dialogs ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html))
2019-06-01 17:42:45 +02:00
```php
2019-10-29 22:23:35 +01:00
$dialogs = yield $MadelineProto->getFullDialogs();
2019-06-01 17:42:45 +02:00
foreach ($dialogs as $dialog) {
2019-06-04 23:39:00 +02:00
$MadelineProto->logger($dialog);
2019-06-01 17:42:45 +02:00
}
```
2019-10-29 22:23:35 +01:00
`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/getFullDialogs.html)
2019-06-01 17:42:45 +02:00
2019-06-05 12:04:07 +02:00
<a href="https://docs.madelineproto.xyz/docs/INLINE_BUTTONS.html">Next section</a>