* Author(s): * * © 2015 Kasra Madadipouya <*****@*****.**> * */ require 'vendor/autoload.php'; $client = new Zelenin\Telegram\Bot\Api(''); // Set your access token $url = ''; // URL RSS feed $update = json_decode(file_get_contents('php://input')); //your app try { if ($update->message->text == '/email') { $response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']); $response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => "You can send email to : Kasra@madadipouya.com"]); } else { if ($update->message->text == '/help') { $response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']); $response = $client->sendMessage(['chat_id' => $update->message->chat->id, 'text' => "List of commands :\n /email -> Get email address of the owner \n /latest -> Get latest posts of the blog \n \t\t/help -> Shows list of available commands"]); } else { if ($update->message->text == '/latest') { Feed::$cacheDir = __DIR__ . '/cache'; Feed::$cacheExpire = '5 hours'; $rss = Feed::loadRss($url); $items = $rss->item; $lastitem = $items[0]; $lastlink = $lastitem->link; $lasttitle = $lastitem->title; $message = $lasttitle . " \n " . $lastlink; $response = $client->sendChatAction(['chat_id' => $update->message->chat->id, 'action' => 'typing']);
$client = new Zelenin\Telegram\Bot\Api($token); //$site = "https://api.telegram.org/bot".$token; $data = json_decode(file_get_contents('php://input'), true); $chatid = $data['message']['chat']['id']; $text = $data['message']['text']; $messageid = $data['message']['message_id']; $updateid = $data['update_id']; $senderid = $data['message']['from']['id']; $zaman = $data['message']['date']; if ($text == '/tatili' || $text == '/tatili@BeheshtiNotifierBot') { $news_page = HtmlDomParser::file_get_html("http://p-karaj.tvu.ac.ir/"); $elems = $news_page->find("#simple-list_11643 ", 0); $message = $elems->plaintext; $params = array('chat_id' => $chatid, 'action' => 'typing'); $response = $client->sendChatAction($params); $response = $client->sendMessage(array('chat_id' => $chatid, 'text' => $message, 'reply_to_message_id' => $messageid)); } if ($text == '/akhbar' || $text == '/akhbar@BeheshtiNotifierBot') { $news_page = HtmlDomParser::file_get_html("http://p-karaj.tvu.ac.ir/"); $elems = $news_page->find(".full-list article header a "); $link = $elems[0]->href; $fixLink = str_replace('./', '/', $link); //echo $fixLink; $behe = "http://p-karaj.tvu.ac.ir"; $url = $behe . $fixLink; //echo $url; $dom = HtmlDomParser::file_get_html($url); $elems = $dom->find("#content article div", 0); $message = $elems->plaintext; $params = array('chat_id' => $chatid, 'action' => 'typing'); $response = $client->sendChatAction($params);
// // $stmt->bindParam(':NAME',$user , PDO::PARAM_STR); // // $stmt->bindParam(':chatid', $chatid, PDO::PARAM_INT); // // if($stmt->execute()) // // { // // $response = $client -> sendMessage(array('chat_id' => '50408323', 'text' => $chatid.$user, 'reply_to_message_id' => $messageid)); // // } // break; case 'تعطیلی کلاس ها': case '/akhbar': case '/tatili@BeheshtiNotifierBot': $params = array('chat_id' => $chatid, 'action' => 'typing'); $response = $client->sendChatAction($params); $news_page = HtmlDomParser::file_get_html("http://p-karaj.tvu.ac.ir/"); $elems = $news_page->find("#simple-list_11643 ", 0); $message = $elems->plaintext; $response = $client->sendMessage(array('chat_id' => $chatid, 'text' => $message, 'reply_to_message_id' => $messageid)); break; case 'اخبار': case '/akhbar': case '/akhbar@BeheshtiNotifierBot': $params = array('chat_id' => $chatid, 'action' => 'typing'); $response = $client->sendChatAction($params); $news_page = HtmlDomParser::file_get_html("http://p-karaj.tvu.ac.ir/"); $elems = $news_page->find(".full-list article header a "); $link = $elems[0]->href; $fixLink = str_replace('./', '/', $link); $behe = "http://p-karaj.tvu.ac.ir"; $url = $behe . $fixLink; $dom = HtmlDomParser::file_get_html($url); $elems = $dom->find("#content article div", 0); $message = $elems->plaintext;