Last active
July 9, 2020 19:35
-
-
Save amirhp-com/1159ba4c0c384b95b559aabcff6119c8 to your computer and use it in GitHub Desktop.
Madelineproto Test, get channel or user's info by giving IDs ..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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