Now the default example works with bots, too
This commit is contained in:
parent
7aafde0d8d
commit
33af309f7a
@ -27,6 +27,11 @@ $api_hash = '';
|
||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
||||
$MadelineProto->start();
|
||||
|
||||
$me = $MadelineProto->get_self();
|
||||
|
||||
\danog\MadelineProto\Logger::log($me);
|
||||
|
||||
if (!$me['bot']) {
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||
|
||||
@ -36,6 +41,7 @@ try {
|
||||
}
|
||||
|
||||
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
||||
}
|
||||
echo 'OK, done!'.PHP_EOL;
|
||||
```
|
||||
|
||||
|
@ -31,6 +31,11 @@ $api_hash = '';
|
||||
$MadelineProto = new \danog\MadelineProto\API('session.madeline', ['app_info' => ['api_id' => $api_id, 'api_hash' => $api_hash]]);
|
||||
$MadelineProto->start();
|
||||
|
||||
$me = $MadelineProto->get_self();
|
||||
|
||||
\danog\MadelineProto\Logger::log($me);
|
||||
|
||||
if (!$me['bot']) {
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||
|
||||
@ -40,6 +45,7 @@ try {
|
||||
}
|
||||
|
||||
$MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
|
||||
}
|
||||
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]]);
|
||||
$me = $MadelineProto->start();
|
||||
|
||||
echo 'MadelineProto was started!';
|
||||
|
||||
$me = $MadelineProto->get_self();
|
||||
|
||||
\danog\MadelineProto\Logger::log($me);
|
||||
|
||||
if (!$me['bot']) {
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
|
||||
$MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
|
||||
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'Testing MadelineProto from a browser :D']);
|
||||
|
||||
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!']);
|
||||
}
|
||||
echo 'OK, done!'.PHP_EOL;
|
||||
|
Loading…
Reference in New Issue
Block a user