Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function buttons($data, $ch)
- {
- $m = ['inline_keyboard' => [[
- ['text' => 'ok', 'callback_data' => 1],
- ['text' => 'подключить оператора', 'callback_data' => 4],
- ['text' => 'cancel', 'callback_data' => 0]]]];
- $m2 = ['inline_keyboard' => [[
- ['text' => 'вперед', 'callback_data' => 2],
- ['text' => 'назад', 'callback_data' => 3]]]];
- if(array_key_exists("callback_query", $data)):
- $chat_id = $data['callback_query']['message']['chat']['id'];
- $m = ($data['callback_query'][data]==1) ? $m2 : $m;
- $text = $data['callback_query'][data];
- $message_id = $data['callback_query']['message']['message_id'];
- else:
- $text = 'empty';
- $chat_id = $data['message']['chat']['id'];
- $message_id = $data['message']['message_id'];
- endif;
- $response = array(
- 'chat_id' => $chat_id,
- 'text' => json_encode($response2, JSON_PRETTY_PRINT),
- 'reply_markup' => json_encode($m)
- );
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $response);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_exec($ch);
- curl_close($ch);
- //пересылка
- $response2 = array(
- 'chat_id' => 759159824,
- 'from_chat_id' => $chat_id,
- 'message_id' => $message_id
- );
- curl_setopt($ch2, CURLOPT_POST, 1);
- curl_setopt($ch2, CURLOPT_POSTFIELDS, $response2);
- curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch2, CURLOPT_HEADER, false);
- curl_exec($ch2);
- curl_close($ch2);
- }
- function operator()
- {
- $response = array(
- 'chat_id' => 777, //ид оператора 759159824
- 'from_chat_id' => $text, //ид чата
- 'message_id' => $message_id
- );
- }
- $token = '1407357186:-Nd21Gy-4v9I';
- $data = file_get_contents('php://input');
- $data = json_decode($data, true);
- $ch = curl_init('https://api.telegram.org/bot' . $token . '/sendMessage');
- $ch2 = curl_init('https://api.telegram.org/bot' . $token . '/forwardMessage');
- buttons($data, $ch, $ch2);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement