Example #1
0
 /**
  * sendChatAction
  * Use this method when you need to tell the user that something is happening on the bot's side.
  *
  * @param Chat|string $chat Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  * @param string $action One of StatusActions::* constants
  */
 public function sendChatAction($chat, $action = StatusActions::TYPING)
 {
     $params = ['chat_id' => $chat instanceof Chat ? $chat->getId() : $chat, 'action' => $action];
     $this->getNet()->doRequest('/sendChatAction', $params);
 }
Example #2
0
 /**
  * sendChatAction
  * Use this method when you need to tell the user that something is happening on the bot's side.
  *
  * @param Chat   $chat
  * @param string $action One of StatusActions::* constants
  */
 public function sendChatAction(Chat $chat, $action = StatusActions::TYPING)
 {
     $params = ['chat_id' => $chat->getId(), 'action' => $action];
     $this->Telegram->getNet()->doRequest('/sendChatAction', $params);
 }
Example #3
0
 /**
  * @param Chat $chat
  *
  * @return string
  */
 protected function getCurrentState(Chat $chat)
 {
     if (isset($this->currentState[$chat->getId()])) {
         return $this->currentState[$chat->getId()];
     }
     $cacheKey = sprintf('state_%s', $chat->getId());
     if ($this->telegram->getCache()->contains($cacheKey)) {
         return $this->telegram->getCache()->fetch($cacheKey);
     } else {
         $this->setCurrentState($chat, State::INITIAL);
         return State::INITIAL;
     }
 }