Dialogs represent your conversations in Telegram, including private chats, groups, channels, and supergroups. MadelineProto provides different methods for bots and users to efficiently retrieve dialog information.
For bot accounts, use getDialogIds() to efficiently retrieve all dialog IDs:
$dialogIds = $MadelineProto->getDialogIds();foreach ($dialogIds as $id) { echo "Dialog ID: $id\n"; // Get info for specific dialog if needed $info = $MadelineProto->getInfo($id); echo "Type: " . $info['type'] . "\n";}
Bot accounts should use getDialogIds() instead of getFullDialogs() for better performance. The method automatically caches all bot users using the updates.getDifference API.
MadelineProto can automatically cache all dialogs on startup:
use danog\MadelineProto\Settings;use danog\MadelineProto\Settings\Peer;$settings = new Settings;$settings->getPeer()->setCacheAllPeersOnStartup(true);$MadelineProto = new API('session.madeline', $settings);
Enabling setCacheAllPeersOnStartup(true) will fetch all dialogs during login, which may take time for accounts with many chats.
// Force refresh dialogs (ignore cache)$dialogs = $MadelineProto->getFullDialogs();// For bots, re-cache all users$dialogIds = $MadelineProto->getDialogIds();
When bot accounts encounter updates.differenceTooLong, MadelineProto performs a binary search to find the correct PTS (Persistent Timestamp):
// This is handled automatically by MadelineProto// Source: /home/daytona/workspace/source/src/Wrappers/DialogHandler.php:102-138// The algorithm:// 1. Set bottomPts and topPts bounds// 2. Try middle PTS value// 3. If differenceTooLong, adjust bottomPts up// 4. If success, adjust topPts down// 5. Repeat until correct PTS is found