Longman\TelegramBot\Commands\UserCommands\SlapCommand::execute PHP Method

execute() public method

Command execute method
public execute ( ) : mixed
return mixed
    public function execute()
    {
        $message = $this->getMessage();
        $chat_id = $message->getChat()->getId();
        $text = $message->getText(true);
        $sender = '@' . $message->getFrom()->getUsername();
        //username validation
        $test = preg_match('/@[\\w_]{5,}/', $text);
        if ($test === 0) {
            $text = $sender . ' sorry no one to slap around..';
        } else {
            $text = $sender . ' slaps ' . $text . ' around a bit with a large trout';
        }
        $data = ['chat_id' => $chat_id, 'text' => $text];
        return Request::sendMessage($data);
    }
SlapCommand