Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- error_log(E_ALL);
- $token = 'xxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
- $api = 'https://api.telegram.org/bot' . $token . '/';
- $db = new mysqli('localhost', 'xxx', 'xxx');
- $db->select_db('tb_lazy');
- $db->query("SET NAMES utf8");
- $result = $db->query("SELECT * FROM staff");
- while($row = $result->fetch_array(MYSQLI_ASSOC)) {
- $staff = $row;
- }
- $data = json_decode(file_get_contents($api . 'getUpdates?offset=' . $staff['offset']));
- foreach($data->result as $unit) {
- $message = $unit->message;
- $chat_id = $message->from->id;
- if(isset($message->chat)) {
- $chat_id = $message->chat->id;
- }
- if(isset($message->text)) {
- $text = trim($message->text);
- if(preg_match('/\/lazy/', $text)) {
- $text = urldecode($text);
- $expltext = explode(" ", $text);
- $service = preg_replace('/(.+?)(@.+)*/', '$1', $expltext[0]);
- if(count($expltext) > 1) {
- $param = '';
- for($i = 1; $i < count($expltext); $i++) {
- $param .= $expltext[$i] . ' ';
- }
- $param = trim($param);
- }
- else {
- $param = false;
- }
- switch($service) {
- case '/lazywiki': {
- include('modules/lazywiki.php');
- break;
- }
- case '/lazycurr': {
- include('modules/lazycurr.php');
- break;
- }
- case '/lazy': {
- include('modules/lazyhelp.php');
- break;
- }
- default: {
- $response = '/lazy';
- }
- }
- $response = urlencode($response);
- file_get_contents($api . 'sendMessage?chat_id=' . $chat_id . '&text=' . $response);
- }
- }
- $update_id = $unit->update_id + 1;
- $db->query("UPDATE staff SET offset = $update_id WHERE id = 1");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement