-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtele.php
116 lines (109 loc) · 4.72 KB
/
tele.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
$tokenBot = "";
$tokenGopay = "";
$pinGopay = "";
function sendRequest($token, $method, $postdata = null) {
$url = "https://api.telegram.org/bot$token/$method";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($postdata) {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-type: application/x-www-form-urlencodedrn'
]);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
}
$exec = curl_exec($ch);
return json_decode($exec);
curl_close($ch);
}
function sendMessage($chat_id, $message_id, $text) {
global $tokenBot;
$data = array(
'chat_id' => $chat_id,
'text' => $text,
'reply_to_message_id' => $message_id
);
$data = http_build_query($data);
return sendRequest($tokenBot, "sendMessage", $data);
}
function saveFile($filename, $string) {
file_put_contents($filename, $string."\n", FILE_APPEND | LOCK_EX);
}
function curl($url, $fields = null, $headers = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($fields !== null) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
}
if ($headers !== null) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return array(
$result,
$httpcode
);
}
$send = rand(10,20) ;
$file_name = "telegram-logs-update-id.txt";
$file_open = file_get_contents($file_name);
while(true) {
$pool = sendRequest($tokenBot, "getUpdates");
foreach($pool->result as $result) {
$update_id = $result->update_id;
$file_open = file_get_contents($file_name);
$file_expl = explode(PHP_EOL, $file_open);
if(!in_array($update_id, $file_expl)) {
saveFile($file_name, $update_id);
$from = $result->message->from->username;
$text = $result->message->text;
$chat_id = $result->message->chat->id;
$message_id = $result->message->message_id;
echo "@$from => $text\n";
if(preg_match('#/#', $text) > 0) {
$cm = explode("/", $text);
$mc = explode(" ", $cm[1]);
if($mc[0] == "gopaysender") {
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-AppVersion: 3.27.0';
$headers[] = "X-Uniqueid: ac94e5d0e7f3f".rand(111,999);
$headers[] = 'X-Location: -6.405821,106.064193';
$headers[] = 'Authorization: Bearer '.$tokenGopay;
$nomor_hp = $mc[1];
$first = substr($nomor_hp, 0, 1);
$getqrid = curl('https://api.gojekapi.com/wallet/qr-code?phone_number=%2B'.str_replace($first, '', $nomor_hp).'', null, $headers);
$jsqrid = json_decode($getqrid[0]);
$qrid = $jsqrid->data->qr_id;
$headertf = array();
$headertf[] = 'Content-Type: application/json';
$headertf[] = 'X-AppVersion: 3.27.0';
$headertf[] = "X-Uniqueid: ac94e5d0e7f3f".rand(111,999);
$headertf[] = 'X-Location: -6.405821,106.64193';
$headertf[] ='Authorization: Bearer '.$tokenGopay;
$headertf[] = 'pin:'.$pinGopay.'';
$tf = curl('https://api.gojekapi.com/v2/fund/transfer', '{"amount":"'.$send.'","description":"SOROPATEN ZONE SEND","qr_id":"'.$qrid.'"}', $headertf);
$jstf = json_decode($tf[0]);
$tfref = $jstf->data->transaction_ref;
$detail = curl('https://api.gojekapi.com/wallet/profile/detailed', null, $headertf);
$saldoo = json_decode($detail[0]);
$saldo = $saldoo->data->balance;
sendMessage($chat_id, $message_id, "Response : \n{$detail[0]}");
} else if($mc[0] == "help") {
sendMessage($chat_id, $message_id, "Saya adalah bot!");
} else if($mc[0] == "creator") {
sendMessage($chat_id, $message_id, "Bot ini dibuat oleh Wildan Fajriansyah");
}
}
}
}
}