Ejemplo n.º 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;
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getLocation());
 }
Ejemplo n.º 5
0
 /**
  * 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);
 }
Ejemplo n.º 6
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getAudio());
 }
Ejemplo n.º 7
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getDocument());
 }
Ejemplo n.º 8
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return (bool) preg_match($this->expect, trim($message->getText()));
 }
Ejemplo n.º 9
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getForwardFrom());
 }
Ejemplo n.º 10
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getVoice());
 }
Ejemplo n.º 11
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getReplyToMessage());
 }
Ejemplo n.º 12
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getSticker());
 }
Ejemplo n.º 13
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function match(Message $message)
 {
     return boolval($message->getContact());
 }