'; /** * @var string */ protected $version = '1.2.0'; /** * Main command execution * * @return ServerResponse * @throws TelegramException */ public function execute(): ServerResponse { $message = $this->getMessage(); $text = $message->getText(true); $sender = '@' . $message->getFrom()->getUsername(); // Username validation (simply checking for `@something` in the text) if (0 === preg_match('/@[\w_]{5,}/', $text)) { return $this->replyToChat('Sorry, no one to slap around...'); } return $this->replyToChat($sender . ' slaps ' . $text . ' around a bit with a large trout'); } }