Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function buttons($data, $ch, $ch2)
- {
- $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' => 777,
- '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);
- /*
- $paramsStr = http_build_query($response2);
- $result = file_get_contents('https://api.telegram.org/bot' . $token . '/forwardMessage?' . $paramsStr);
- */
- //begin
- /*
- $re = curl_getinfo ($ch2 , CURLINFO_EFFECTIVE_URL);
- ob_start();
- print_r($re);
- $out = ob_get_clean();
- file_put_contents(__DIR__ . '/message.txt', $out);
- */
- //end
- //return $options;
- }
- function operator()
- {
- $response = array(
- 'chat_id' => 759159824, //ид оператора 759159824
- 'from_chat_id' => $text, //ид чата
- 'message_id' => $message_id
- );
- }
- $token = '777';
- $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