Now the default example works with bots, too
This commit is contained in:
parent
7aafde0d8d
commit
33af309f7a
20
README.md
20
README.md
@ -27,15 +27,21 @@ $api_hash = '';
|
|||||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
||||||
$MadelineProto->start();
|
$MadelineProto->start();
|
||||||
|
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
$me = $MadelineProto->get_self();
|
||||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
|
||||||
|
|
||||||
try {
|
\danog\MadelineProto\Logger::log($me);
|
||||||
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
if (!$me['bot']) {
|
||||||
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||||
|
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
||||||
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
|
||||||
echo 'OK, done!'.PHP_EOL;
|
echo 'OK, done!'.PHP_EOL;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -31,15 +31,21 @@ $api_hash = '';
|
|||||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
||||||
$MadelineProto->start();
|
$MadelineProto->start();
|
||||||
|
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
$me = $MadelineProto->get_self();
|
||||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
|
||||||
|
|
||||||
try {
|
\danog\MadelineProto\Logger::log($me);
|
||||||
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
if (!$me['bot']) {
|
||||||
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||||
|
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
||||||
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
|
||||||
echo 'OK, done!'.PHP_EOL;
|
echo 'OK, done!'.PHP_EOL;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -5,15 +5,20 @@ require 'vendor/autoload.php';
|
|||||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => false]]);
|
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => 6, 'api_hash' => 'eb06d4abfb49dc3eeb1aeb98ae0f581e'], 'updates' => ['handle_updates' => false]]);
|
||||||
$me = $MadelineProto->start();
|
$me = $MadelineProto->start();
|
||||||
|
|
||||||
echo 'MadelineProto was started!';
|
|
||||||
|
$me = $MadelineProto->get_self();
|
||||||
|
|
||||||
|
\danog\MadelineProto\Logger::log($me);
|
||||||
|
|
||||||
if (!$me['bot']) {
|
if (!$me['bot']) {
|
||||||
|
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'Testing MadelineProto from a browser :D']);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
$MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
|
||||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
||||||
}
|
}
|
||||||
|
echo 'OK, done!'.PHP_EOL;
|
||||||
|
Loading…
Reference in New Issue
Block a user