Send Chat Action.
public sendChatAction ( integer $chat_id, string $action ) : Array | ||
$chat_id | integer | |
$action | string | |
return | Array |
} elseif ($message == "/stop") { $k = array_search($chatId, $authDialogs); if ($k !== false) { unset($authDialogs[$k]); $f = fopen($fileOfAuth, "w+"); foreach ($authDialogs as $i => $item) { if (trim($item) != null) { fwrite($f, $item . "\r\n"); } } fclose($f); //$bot->SendMessage($chatId,"Вы успешно вышли из системы!"); $tg->sendMessage($chatId, 'Вы вышли из режима наблюдения!'); } } elseif ($message == "/photo") { $tg->sendChatAction($chatId, 'upload_photo'); $tg->sendMessage($chatId, 'Эта функция пока не реализована!'); /* $name=uniqid().".jpg"; exec("service motion stop"); exec("fswebcam -r 1024x800 --jpeg 99 -D 1 ".$dir."/photos/".$name); exec("service motion start"); sleep(1); if(is_file($dir."/photos/".$name)){ $tg->sendPhoto($chatId, $dir."/photos/".$name); unlink($dir."/photos/".$name); }else{ $tg->sendMessage($chatId, 'Проблемы с камерой!...'); }
echo json_encode($updates) . "\n"; // Custom keyboard $customKeyboard = [['7', '8', '9'], ['4', '5', '6'], ['1', '2', '3'], ['0']]; $reply_markup = $tg->replyKeyboardMarkup($customKeyboard, true, true); do { // Get updates the bot has received // Offset to confirm previous updates $updates = $tg->pollUpdates($offset); if ($updates['ok'] && count($updates['result']) > 0) { foreach ($updates['result'] as $data) { if (is_null($chat_id)) { $chat_id = $data['message']['chat']['id']; } if (!$sendQuestion) { // sends an action 'typing' $tg->sendChatAction($chat_id, 'typing'); // send message with a custom reply markup $tg->sendMessage($chat_id, 'Guess the number', null, false, null, $reply_markup); $sendQuestion = true; } if ($data['message']['text'] == 5) { $tg->sendChatAction($chat_id, 'typing'); $tg->sendMessage($chat_id, 'You did it! :)'); $tg->sendChatAction($chat_id, 'upload_photo'); $tg->sendPhoto($chat_id, 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/fa/718smiley.png/220px-718smiley.png'); $guessed = true; } else { $tg->sendMessage($chat_id, 'Wrong number :/ try again', null, false, null, $reply_markup); } } $offset = $updates['result'][count($updates['result']) - 1]['update_id'] + 1;