Skip to content

Commit

Permalink
grant help for group
Browse files Browse the repository at this point in the history
  • Loading branch information
fadhil-riyanto committed Feb 3, 2021
1 parent 7753824 commit ec732ea
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 31 deletions.
19 changes: 19 additions & 0 deletions APIs2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
if (isset($_GET['method'])) {
$method = @$_GET['method'];
$dns = @$_GET['dns'];
if ($method == 'corona_provinsi') {
$a_provinsi_corona = file_get_contents('https://api.kawalcorona.com/indonesia/provinsi'); //get json ke server
$b_provinsi_corona = json_decode($a_provinsi_corona); //lalu decode
foreach ($b_provinsi_corona as $bb_b_provinsi_corona) { //loop sampai menemukan yg pas
if (strtolower($bb_b_provinsi_corona->attributes->Provinsi) == $dns) { //jika nama provinsi sama maka
$reply = 'Provinsi : ' . $bb_b_provinsi_corona->attributes->Provinsi . PHP_EOL . PHP_EOL .
'😊 Total sembuh : ' . $bb_b_provinsi_corona->attributes->Kasus_Semb . PHP_EOL .
'😞 Total positif : ' . $bb_b_provinsi_corona->attributes->Kasus_Posi . PHP_EOL .
'😢 Total meninggal : ' . $bb_b_provinsi_corona->attributes->Kasus_Meni . PHP_EOL;
header('type: text/plain');
echo $reply;
}
}
}
}
31 changes: 16 additions & 15 deletions command/help.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
if (detect_grup() == true) {
$reply = 'Hai ' . $username . ', Maaf, menu ini hanya bisa diakses via PM';
$option = array(
//First row
// array($telegram->buildInlineKeyBoardButton("Button 1", $url = "http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url = "http://link2.com")),
// //Second row
// array($telegram->buildInlineKeyBoardButton("Button 3", $url = "http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url = "http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url = "http://link5.com")),
// //Third row
array($telegram->buildInlineKeyBoardButton("PM", $url = 'https://t.me/fadhil_riyanto_bot'))
);
$keyb = $telegram->buildInlineKeyBoard($option);
// if (detect_grup() == true) {
// $reply = 'Hai ' . $username . ', Maaf, menu ini hanya bisa diakses via PM';
// $option = array(
// //First row
// // array($telegram->buildInlineKeyBoardButton("Button 1", $url = "http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url = "http://link2.com")),
// // //Second row
// // array($telegram->buildInlineKeyBoardButton("Button 3", $url = "http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url = "http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url = "http://link5.com")),
// // //Third row
// array($telegram->buildInlineKeyBoardButton("PM", $url = 'https://t.me/fadhil_riyanto_bot'))
// );
// $keyb = $telegram->buildInlineKeyBoard($option);

$content = array('chat_id' => $chat_id, 'text' => $reply, 'disable_web_page_preview' => true, 'reply_markup' => $keyb, 'reply_to_message_id' => $message_id, 'disable_web_page_preview' => true);
$telegram->sendMessage($content);
exit;
} else {
// $content = array('chat_id' => $chat_id, 'text' => $reply, 'disable_web_page_preview' => true, 'reply_markup' => $keyb, 'reply_to_message_id' => $message_id, 'disable_web_page_preview' => true);
// $telegram->sendMessage($content);
// exit;
// }
if (true) {
require __DIR__ . '/../include/help_menu.php';

$file = __DIR__ . "/../json_data/editMsgIDdelete.json";
Expand Down
31 changes: 16 additions & 15 deletions command/help_i.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
if (detect_grup() == true) {
$reply = 'Hai ' . $username . ', Maaf, menu ini hanya bisa diakses via PM';
$option = array(
//First row
// array($telegram->buildInlineKeyBoardButton("Button 1", $url = "http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url = "http://link2.com")),
// //Second row
// array($telegram->buildInlineKeyBoardButton("Button 3", $url = "http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url = "http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url = "http://link5.com")),
// //Third row
array($telegram->buildInlineKeyBoardButton("PM", $url = 'https://t.me/fadhil_riyanto_bot'))
);
$keyb = $telegram->buildInlineKeyBoard($option);
// if (detect_grup() == true) {
// $reply = 'Hai ' . $username . ', Maaf, menu ini hanya bisa diakses via PM';
// $option = array(
// //First row
// // array($telegram->buildInlineKeyBoardButton("Button 1", $url = "http://link1.com"), $telegram->buildInlineKeyBoardButton("Button 2", $url = "http://link2.com")),
// // //Second row
// // array($telegram->buildInlineKeyBoardButton("Button 3", $url = "http://link3.com"), $telegram->buildInlineKeyBoardButton("Button 4", $url = "http://link4.com"), $telegram->buildInlineKeyBoardButton("Button 5", $url = "http://link5.com")),
// // //Third row
// array($telegram->buildInlineKeyBoardButton("PM", $url = 'https://t.me/fadhil_riyanto_bot'))
// );
// $keyb = $telegram->buildInlineKeyBoard($option);

$content = array('chat_id' => $chat_id, 'text' => $reply, 'disable_web_page_preview' => true, 'reply_markup' => $keyb, 'reply_to_message_id' => $message_id, 'disable_web_page_preview' => true);
$telegram->sendMessage($content);
exit;
} else {
// $content = array('chat_id' => $chat_id, 'text' => $reply, 'disable_web_page_preview' => true, 'reply_markup' => $keyb, 'reply_to_message_id' => $message_id, 'disable_web_page_preview' => true);
// $telegram->sendMessage($content);
// exit;
// }
if (true) {
require __DIR__ . '/../include/help_menu.php';

$file = __DIR__ . "/../json_data/editMsgIDdelete.json";
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function tracking_user($userID)
} elseif ('/help_i' == $adanParse[0] || '/help_i@fadhil_riyanto_bot' == $adanParse[0]) {
require __DIR__ . '/command/help_i.php';
exit;
} elseif ('/help' == $adanParse[0] || '/help_i@fadhil_riyanto_bot' == $adanParse[0]) {
} elseif ('/help' == $adanParse[0] || '/help@fadhil_riyanto_bot' == $adanParse[0]) {
require __DIR__ . '/command/help.php';
exit;
} elseif ('/callback_q' == $adanParse[0] || '/callback_q@fadhil_riyanto_bot' == $adanParse[0]) {
Expand Down
22 changes: 22 additions & 0 deletions test/corona.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
$headers = array('Accept' => 'application/json');
$options = array('auth' => array('user', 'pass'));
$request = Requests::get('https://api.kawalcorona.com/indonesia/provinsi/', $headers, $options);


$a_provinsi_corona = $request->body;
$dns = 'DKI Jakarta';
// persiapkan curl

$b_provinsi_corona = json_decode($a_provinsi_corona); //lalu decode
foreach ($b_provinsi_corona as $bb_b_provinsi_corona) { //loop sampai menemukan yg pas
if (strtolower($bb_b_provinsi_corona->attributes->Provinsi) == $dns) { //jika nama provinsi sama maka
$reply = 'Provinsi : ' . $bb_b_provinsi_corona->attributes->Provinsi . PHP_EOL . PHP_EOL .
'😊 Total sembuh : ' . $bb_b_provinsi_corona->attributes->Kasus_Semb . PHP_EOL .
'😞 Total positif : ' . $bb_b_provinsi_corona->attributes->Kasus_Posi . PHP_EOL .
'😢 Total meninggal : ' . $bb_b_provinsi_corona->attributes->Kasus_Meni . PHP_EOL;
header('type: text/plain');
echo $reply;
}
}

0 comments on commit ec732ea

Please sign in to comment.