/** * @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; }
/** * 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); } } }
/** * 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); }
/** * @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); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getAudio()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getDocument()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return (bool) preg_match($this->expect, trim($message->getText())); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getForwardFrom()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getVoice()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getReplyToMessage()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getSticker()); }
/** * @param Message $message * * @return bool */ public function match(Message $message) { return boolval($message->getContact()); }