Created
November 21, 2019 18:28
-
-
Save Cvar1984/d10f2122c3066133875b66145f0b44dc to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
* Masukin @abcdtest_bot ke group telegram lu | |
* jadi in admin | |
* jalanin script ini | |
* kalo ga tau caranya modar aja lu tolol | |
* auto bantai siapa aja yg nge chat di group | |
* do with your own risk | |
* salam ubur - ubur | |
*/ | |
system('stty cbreak -echo'); // buat nonaktifin echo ya anjink biar terminal bersih | |
class Telegram { | |
public function __construct() | |
{ | |
set_time_limit(0); | |
ignore_user_abort(0); | |
ini_set('max_execution_time', 0); //exec time | |
ini_set('memory_limit', '999999999M'); //memmory limit | |
define('BOT_TOKEN', '983615954:AAGX1Q7NSNHnx7aLAdfmKrVB0oAlJ0JXxDo'); | |
} | |
public function bot($method, $datas = []) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'https://api.telegram.org/bot'.BOT_TOKEN.'/'.$method); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $datas); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); | |
$res = curl_exec($ch); | |
curl_close($ch); | |
return json_decode($res, 1); | |
} | |
public function getupdates($up_id) { | |
$get=$this->bot('getupdates', ['offset' => $up_id]); | |
return @end($get['result']); | |
} | |
} | |
$telegram=new Telegram(); | |
$last_up=0; | |
while (true) { | |
$last_up=$telegram->getupdates($last_up['update_id'] + 1); | |
$msg = $last_up['message']; | |
if(empty($msg['text'])) { | |
continue; | |
} | |
else { | |
if(empty($msg['chat']['title'])) { | |
$msg['chat']['title']=null; | |
} | |
if(empty($msg['from']['username'])) { | |
$msg['from']['username']=null; | |
} | |
echo 'Chat Title : '.$msg['chat']['title']."\n"; | |
echo 'Chat ID : '.$msg['chat']['id']."\n"; | |
echo 'Name : '.$msg['from']['first_name']."\n"; | |
echo 'Username: '.$msg['from']['username']."\n"; | |
echo 'Text : '.$msg['text']."\n"; | |
echo 'Date : '.date('d/m/Y H:i:s',$msg['date'])."\n\n"; | |
$data=array( | |
'username'=>$msg['from']['username'], | |
'chat_title'=>isset($msg['chat']['title']), | |
'chat_id'=>$msg['chat']['id'], | |
'name'=>$msg['from']['first_name'], | |
'username'=>$msg['from']['username'], | |
'text'=>$msg['text'], | |
'date'=>date('d/m/Y H:i:s', $msg['date']) | |
); | |
$tulis=fopen('chat_logs.json','a'); // nulis chat logger | |
fwrite($tulis, json_encode($data)."\n"); | |
fclose($tulis); | |
if(preg_match('/^\/debug/',strtolower($msg['text']))) { | |
$telegram->bot('sendMessage', | |
['chat_id'=>$msg['chat']['id'], | |
'parse_mode'=>'markdown', | |
'text'=>'`'.json_encode($msg).'`' | |
]); | |
} | |
$telegram->bot('deleteMessage', | |
['chat_id' => $msg['chat']['id'], | |
'message_id'=> $msg['message_id'] | |
]); | |
$telegram->bot('exportChatInviteLink', | |
['chat_id' => $msg['chat']['id']]); | |
$telegram->bot('kickChatMember', | |
['chat_id' => $msg['chat']['id'], | |
'user_id' => $msg['from']['id'] | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment