1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 10:19:00 +01:00
This commit is contained in:
Daniil Gentili 2017-03-12 13:57:23 +01:00
parent ada0fc7df9
commit de815fd84f
4 changed files with 171819 additions and 7 deletions

6
.env.calls Normal file
View File

@ -0,0 +1,6 @@
MTPROTO_NUMBER=+39373739
MTPROTO_SETTINGS={"app_info":{"api_id":6,"api_hash":"eb06d4abfb49dc3eeb1aeb98ae0f581e"}, "connection_settings":{"all":{"test_mode":true}}}
TEST_USERNAME=@danogentili
TEST_DESTINATION_GROUPS=["@danogentili"]
BOT_TOKEN=299050432:AAGMdcyfqGTpwCo0bJkmlomHwMUieXRs8GY

47
callbot.php Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env php
<?php
/*
Copyright 2016-2017 Daniil Gentili
(https://daniil.it)
This file is part of MadelineProto.
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU General Public License along with MadelineProto.
If not, see <http://www.gnu.org/licenses/>.
*/
require 'vendor/autoload.php';
$settings = [];
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('calls.madeline');
} catch (\danog\MadelineProto\Exception $e) {
}
$offset = 0;
while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
var_dump($updates);
foreach ($updates as $update) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
//var_dump($update);
switch ($update['update']['_']) {
case 'updateNewMessage':
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
}
try {
//var_dump($update);
if ($update['update']['message']['message'] === 'callstorm') {
$MadelineProto->messages->sendMessage(['peer' => $update['update']['message']['from_id'], 'message' => 'callstorming you', 'reply_to_msg_id' => $update['update']['message']['id']]);
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL;
shell_exec('php calls.php '.escapeshellarg($update['update']['message']['from_id']).' 100 >>calls 2>>calls & ');
}
} catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $e->getCode().': '.$e->getMessage().PHP_EOL.$e->getTraceAsString()]);
} catch (\danog\MadelineProto\Exception $e) {
}
}
}
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL;
}

171757
calls Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,10 +15,10 @@ if (file_exists('web_data.php')) {
require_once 'web_data.php';
}
echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL;
echo 'Deserializing MadelineProto from calls.madeline...'.PHP_EOL;
$MadelineProto = false;
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('calls.madeline');
} catch (\danog\MadelineProto\Exception $e) {
}
if (file_exists('.env')) {
@ -57,14 +57,16 @@ if ($MadelineProto === false) {
\danog\MadelineProto\Logger::log(['Registering new user'], \danog\MadelineProto\Logger::NOTICE);
$authorization = $MadelineProto->complete_signup($code, readline('Please enter your first name: '), readline('Please enter your last name (can be empty): '));
}
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL;
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
echo 'Serializing MadelineProto to calls.madeline...'.PHP_EOL;
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL;
} else {
$MadelineProto->bot_login(getenv('BOT_TOKEN'));
}
}
$MadelineProto->request_call('@manuel15');
while (true) {
for ($x = 0; $x < $argv[2]; $x++) {
$MadelineProto->request_call($argv[1]);
$MadelineProto->get_updates_difference();
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('calls.madeline', $MadelineProto).' bytes'.PHP_EOL;
}
$MadelineProto->messages->sendMessage(['peer' => $argv[1], 'message' => '[Powered by MadelineProto](https://github.com/danog/MadelineProto)', 'parse_mode' => 'markdown']);