Skip to content

Instantly share code, notes, and snippets.

@amirhp-com
Last active July 9, 2020 19:35
Show Gist options
  • Save amirhp-com/1159ba4c0c384b95b559aabcff6119c8 to your computer and use it in GitHub Desktop.
Save amirhp-com/1159ba4c0c384b95b559aabcff6119c8 to your computer and use it in GitHub Desktop.
Madelineproto Test, get channel or user's info by giving IDs ..
<?php
echo "<title>Madelineproto Test by KING HPV</title>";
/**
* check for required modules and if not installed_
* install them and include into current project
*/
file_exists('madeline.php') OR copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
include 'madeline.php';
/**
* initiate MadelineProto once and set parallel processing (async) to ON
*/
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
print highlight_string("<?php\n\t# πŸ’» Programmed by Amirhosseinhpv\n\t# πŸ€™ Social: https://hpv.im/\n\t# 🌍 Blog: https://amirhosseinhpv.ir/\n\t# βœ… MadelineProto Loop Started\n?>\n\n\n",true);
$data_pro = "";
yield $MadelineProto->start();
foreach (array(
'digikala',
'gizmiztel',
'amirhosseinhpv',
'irrolex',
'blackswanlab' ) as $channel){
try {
/**
* get channel information
*/
$chat = yield $MadelineProto->getFullInfo("@$channel");
/**
* print out information in php highlighted syntax
*/
switch ($chat['type']) {
case 'user':
$data_pro = "\n\t\$channel_id = '@$channel';\n\t\$username_info = 'Chat type is: {$chat['type']}';\n\t\$user_first_name: '{$chat['User']['first_name']}';";
break;
case 'channel':
$data_pro = "\n\t\$channel_id = '@$channel';\n\t\$username_info = 'Chat type is: {$chat['type']}';\n\t\$channel_title: '{$chat['Chat']['title']}';";
break;
// case 'supergroup':
// case 'bot':
// case 'chat':
default:
$data_pro = "\n\t\$channel_id = '@$channel';\n\t\$username_info = 'Chat type is: {$chat['type']}';\n\t\$chat_info: 'Retrive More info here';";
break;
}
print highlight_string("<?php\n\t//-----------------------------------{$data_pro}\n\t//-----------------------------------\n?>\n\n\n",true);
} catch (\danog\MadelineProto\RPCErrorException $e) {
/**
* if error occured, log it into /MadelineProto.log
*/
$MadelineProto->logger($e);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment