Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('log_errors', 'On');
- ini_set('error_log', 'php_errors.log');
- include('config.php'); // подключаем настройки бота
- include('functions.php'); // подключаем функции бота
- include('mysql.php'); // подключаем функциями
- echo get($url.'setWebhook?url='.$webhook); // вывод на экран echo
- if (($json = valid()) == false) { exit();} //занесли функцию valid в переменную
- if ($json['message']) {
- $uid = $json['message']['from']['id'];
- $first_name = $json['message']['from']['first_name'];
- $username = $json['message']['from']['username'];
- $date = $json['message']["date"];
- $msgid = $json['message']['message_id'];
- $text = $json['message']['text'];
- }
- else if ($json['callback_query']) {
- $callback_data = $json['callback_query']['data'];
- $uid = $json['callback_query']['message']['chat']['id'];
- $text = $json['callback_query']['message']['text'];
- $first_name = $json['callback_query']['from']['first_name'];
- $username = $json['callback_query']['from']['username'];
- $date = $json['callback_query']["date"];
- $msgid = $json['callback_query']['message_id'];
- }
- switch($text){
- ////////////mailing settings//////////////
- case ($text == '/send' and $uid == '1234567'):
- $ANSWER = 'Пришлите текст для рассылки.';
- $keyboard = keyboard_cancel();
- break;
- case 'cancel button':
- $ANSWER = 'remove keyboard';
- $keyboard = delete_keyboard();
- break;
- case '/start':
- $photo= 'MyIMAGE.jpg';
- $ANSWER = "best list";
- $keyboard = inline_keyboard();
- break;
- }
- if(isset($callback_data)){
- switch ($callback_data){
- case '/in_zero':
- $ANSWER = "Next list";
- break;
- }
- }
- if ($photo) {sendPhoto($uid,$photo,$ANSWER,$keyboard); exit();}
- sendMessage($uid,$ANSWER,$keyboard);
- /////////////////////////////////////////////main send functions///////////////////////////
- function inline_keyboard(){
- $inline_button1 = array("text"=>"Show all list","callback_data"=>'/in_zero');
- $inline_keyboard = [
- [$inline_button1]
- ];
- $keyboard=json_encode(array("inline_keyboard"=>$inline_keyboard));
- return $keyboard;
- }
- function sendMessage($chat_id,$text,$markup=null) {
- if (isset($chat_id))
- {
- $url = $GLOBALS['url'].'sendMessage?chat_id='.$chat_id.'&text='.urlencode($text).'&reply_markup='.$markup.'&parse_mode=Markdown';
- $url .= '&disable_web_page_preview=true';
- return get($url);
- }
- }
- function sendPhoto($chat_id,$photo,$caption,$post_fields=null){
- $url = $GLOBALS['url']."sendPhoto?chat_id=".$chat_id.'&reply_markup='.$post_fields.'&parse_mode=Markdown';
- $post_fields = array('chat_id' => $chat_id,
- 'photo' => new CURLFile(realpath($photo)),
- 'caption' => $caption
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- "Content-Type:multipart/form-data"
- ));
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
- $output = curl_exec($ch);
- return $output;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment