3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $curl=curl_init(); $update = '{"update_id":249657259, "message":{"message_id":469,"from":{"id":89093089,"first_name":"Yoily","username":"YoilyL"},"chat":{"id":-1001068646424,"title":"Bot test","type":"supergroup"},"date":1468506747,"voice":{"duration":1,"mime_type":"audio\/ogg","file_id":"AwADBAADyQQAAuFzTwVPB2Vyea2ZXQI","file_size":3542}}}'; $upar = json_decode($update, TRUE); $chatid = $upar['message']['chat']['id']; $mid = $upar['message']['message_id']; $mtxt = ''; $sender = $upar['message']['from']['id']; $name = $upar['message']['from']['first_name']; $isc = false; if (isset($upar['message']['entities'])){ foreach ($upar['message']['entities'] as $ent){ if ($ent['type']=='mention'){ $ment = substr($upar['message']['text'], $ent['offset'], $ent['length']); $chch = json_decode(file_get_contents("https://api.telegram.org/bot247854284:AAFrc7srTVzCVSMrxtMpQxtqLxMpbznCcPM/getChat?chat_id=$ment"), true); print_r($chch); if ($chch['ok'] && $chch['result']['type']!== 'private' && !stripos($ment, 'smartechgroup')) { $isc = true; break;} } } } if (isset($upar['message']['text'])) $mtxt = $upar['message']['text']; $link = (stripos( $mtxt, 'telegram.me')!==false && stripos($mtxt, smartechgroup, 15 )=== false); If (isset($upar['message']['new_chat_member'])) { if ( strripos($upar['message']['new_chat_member']['username'], 'bot', -3) ){ $botid = $upar['message']['new_chat_member']['id']; header('Content-Type: application/json'); echo json_encode(array( 'method'=>'kickChatMember', 'chat_id'=>$chatid, 'user_id'=>$botid, )); } else { $name = $upar['message']['new_chat_member']['first_name']; header('Content-Type: application/json'); echo json_encode(array( 'method'=>'sendMessage', 'chat_id'=>$chatid, 'text'=> "*Hi $name*, and welcome to the smartech group!\n\nWe are glad you joined our group! \n\n_Please be aware of these rules:_\n-* only English* may be used\n- discussing *only about technology *issues.\n- no voice notes\n-* no ads *(including telegram links to groups/channels)\nThank you for understanding and cooperation \n*The SmarTech Team *\n\n_(Please note: if you break any of these rules I will personally (...) remove you from this group.)_", 'parse_mode' => 'markdown', )); } } elseif ($upar['message']['chat']['type'] === 'private'){ header('Content-Type: application/json'); echo json_encode(array( 'method'=>'sendMessage', 'chat_id'=>$chatid, 'parse_mode' => 'markdown', 'text'=>'sorry, this bot can only be used in the [smartech group](https://telegram.me/smartechgroup)', )); } elseif (isset($upar['message']['voice']) || $link || $isc ){ $msg1 = "*Attention $name! %0A*this message is against the group rules.%0Aif you don't delete it within*"; $msg2 = ' seconds* you will get kicked from the group.'; $i= 15; $a = json_decode(file_get_contents("https://api.telegram.org/bot209583373:AAEADqY65IgVpjRqAG7unTDVwfGGdiUJ-oU/sendMessage?chat_id=$chatid&text=$msg1 ".$i.$msg2."&reply_to_message_id=$mid&parse_mode=markdown"), true); $botmid = $a['result']['message_id']; print_r($a); usleep(500000); for ( --$i; $i >= 0 ; $i-- ) { curl_setopt($curl, CURLOPT_URL, 'https://api.telegram.org/bot209583373:AAEADqY65IgVpjRqAG7unTDVwfGGdiUJ-oU/editMessageText?chat_id=$chatid&message_id=$botmid&&parse_mode=markdown&text=$msg1 ".$i.$msg2'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $b = json_decode(curl_exec($curl), true); print_r($b); if (!isset($b['result']['reply_to_message'])){ file_get_contents("https://api.telegram.org/bot209583373:AAEADqY65IgVpjRqAG7unTDVwfGGdiUJ-oU/editMessageText?chat_id=$chatid&message_id=$botmid&text=$name, next time you should make sure your message complies with the group rules."); break; } elseif ($i === 0){ $name = (isset($upar['message']['from']['last_name']))?"$name {$upar['message']['from']['last_name']}": $name; $c = json_decode(file_get_contents("https://api.telegram.org/bot209583373:AAEADqY65IgVpjRqAG7unTDVwfGGdiUJ-oU/kickChatMember?chat_id=$chatid&user_id=$sender"), true); $last = ($c['ok'])?"$name has been kicked because his message was against the group rules.":"$name couldn't be kicked, but his message is against group rules."; file_get_contents("https://api.telegram.org/bot209583373:AAEADqY65IgVpjRqAG7unTDVwfGGdiUJ-oU/editMessageText?chat_id=$chatid&message_id=$botmid&text=$last"); } usleep(560000); }} curl_close($curl);
based on CgWCL
Output for 7.0.0 - 7.2.8
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/bf4eo:2 Stack trace: #0 {main} thrown in /in/bf4eo on line 2
Process exited with code 255.
Output for 5.5.38 - 5.6.24
Fatal error: Call to undefined function curl_init() in /in/bf4eo on line 2
Process exited with code 255.