Exemple #1
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     $text = trim($message->getText());
     if (substr($text, 0, 1) == '/') {
         if (strpos($text, '@') > 0) {
             list($text, $to) = explode('@', $text, 2) + ['', ''];
             //@TODO check $to
         }
     }
     return $text === $this->expect;
 }
Exemple #2
0
 /**
  * Handle incomming message.
  *
  * @internal
  *
  * @param Message $message
  *
  * @return bool
  */
 public function executeScript(Message $message)
 {
     $current = $this->findCurrentState($message->getChat());
     foreach ($current->getActions() as $actionLine) {
         /**
          * @var AbstractCondition
          * @var string|array|callable $action
          */
         list($condition, $action) = $actionLine;
         if ($condition->match($message)) {
             return $this->execute($action, $message);
         }
     }
 }
Exemple #3
0
 /**
  * forwardMessage
  * Use this method to forward messages of any kind. On success, the sent Message is returned.
  *
  * @param Chat    $chat
  * @param Chat    $fromChat
  * @param Message $message
  *
  * @return Message
  */
 public function forwardMessage(Chat $chat, Chat $fromChat, Message $message)
 {
     $params = ['chat_id' => $chat->getId(), 'from_chat_id' => $fromChat->getId(), 'message_id' => $message->getMessageId()];
     $message = $this->Telegram->getNet()->doRequest('/forwardMessage', $params);
     return new Message($message);
 }
Exemple #4
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getLocation());
 }
 /**
  * forwardMessage
  * Use this method to forward messages of any kind. On success, the sent Message is returned.
  *
  * @param Chat|string $chat Unique identifier for the target chat or username of the target channel (in the format @channelusername)
  * @param Chat|string $fromChat Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
  * @param bool $disableNotification Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
  * @param Message $message Unique message identifier
  *
  * @return Message
  */
 public function forwardMessage($chat, $fromChat, $disableNotification, Message $message)
 {
     $params = ['chat_id' => $chat instanceof Chat ? $chat->getId() : $chat, 'from_chat_id' => $fromChat instanceof Chat ? $fromChat->getId() : $chat, 'disable_notification' => $disableNotification, 'message_id' => $message->getMessageId()];
     $message = $this->getNet()->doRequest('/forwardMessage', $params);
     return new Message($message);
 }
Exemple #6
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getAudio());
 }
Exemple #7
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getDocument());
 }
Exemple #8
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return (bool) preg_match($this->expect, trim($message->getText()));
 }
Exemple #9
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getForwardFrom());
 }
Exemple #10
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getVoice());
 }
Exemple #11
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getReplyToMessage());
 }
Exemple #12
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getSticker());
 }
Exemple #13
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getContact());
 }