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.
getDialogIds
$dialogs = $MadelineProto->getDialogIds();
foreach ($dialogs as $peer) {
$MadelineProto->messages->sendMessage(peer: $peer, message: 'Hi! Testing MadelineProto broadcasting!');
}
getDialogIds
will return a full list of the bot API IDs of all users/chats/channels known by the bot, see here for the parameters and the result.
Note: this method will take a very long time to return the first time when used with bots: to avoid incurring in timeouts, run the method via CLI (not web) OR use the async background broadcast API, instead.
After the first broadcast with the broadcast API (i.e. $id = $MadelineProto->broadcastMessages(...)
) is completed in the background (i.e. $MadelineProto->getBroadcastProgress($id) === null
), the result of getDialogIds
will be cached and will be returned immediately.
getFullDialogs
$dialogs = $MadelineProto->getFullDialogs();
foreach ($dialogs as $dialog) {
$MadelineProto->logger($dialog);
}
getFullDialogs
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