-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
55 lines (49 loc) · 1.67 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
set_time_limit(15);
use \danog\MadelineProto\API;
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$settings = ['logger'=>['logger'=>0],'app_info'=> ['api_id'=>'xxx_ID_xxx','api_hash'=> 'xxx_HASH_xxx']];
$MadelineProto = new API('LampStack.session',$settings);
$MadelineProto->async(true);
$MadelineProto->loop(function() use ($MadelineProto){
yield $MadelineProto->start();
if(!isset($_REQUEST['peer']) or !isset($_REQUEST['type']) or ($_REQUEST['type'] === 'search' and !isset($_REQUEST['q']))){
echo 'You need to enter all inputs. (see https://github.com/LampStack/TelegramSearchEngine';
return;
}
try{
$get_full_info = yield $MadelineProto->get_full_info($_REQUEST['peer']);
}catch ( \Throwable $e ) {
echo $e->getMessage();
return;
}
switch($_REQUEST['type']){
case 'search' :
try{
$searchGlobal = yield $MadelineProto->messages->search([
'peer' => $_REQUEST['peer'],
'q' => $_REQUEST['q'],
'limit' => 10 ,
'min_id' => 0 ,
'max_id' => 0 ,
'min_date' => 0 ,
'max_date' => 0 ,
'offset_id' => 0 ,
'add_offset' => 0 ,
'filter' => ['_' => 'inputMessagesFilterEmpty'],
])['messages'];
}catch ( \Throwable $e ) {
echo $e->getMessage();
return;
}
echo json_encode(($searchGlobal),true);
default :
echo json_encode(($get_full_info),true);
}
@unlink('error_log');
return;
}
);