public function sendAttachment(Chat $chat, User $recipient, Attachment $attachment): void
    {
        $type = $attachment->getType();

        $request = null;

        switch ($type) {
            case Attachment::TYPE_FILE:
                $request = new SendDocument();
                $request->document = new InputFile($attachment->getPath());
                $request->caption = $attachment->getParameters()->get('caption');
                break;

            case Attachment::TYPE_IMAGE:
                $request = new SendPhoto();
                $request->caption = $attachment->getParameters()->get('caption');
                break;

            case Attachment::TYPE_AUDIO:
                $request = new SendAudio();
                $request->chat_id = $chat->getId();
                $request->caption = $attachment->getParameters()->get('caption');
                $request->duration = $attachment->getParameters()->get('duration');
                $request->performer = $attachment->getParameters()->get('performer');
                $request->title = $attachment->getParameters()->get('title');

                break;

            case Attachment::TYPE_VIDEO:
                $request = new SendVideo();
                $request->duration = $attachment->getParameters()->get('duration');
                $request->width = $attachment->getParameters()->get('width');
                $request->height = $attachment->getParameters()->get('height');
                $request->caption = $attachment->getParameters()->get('caption');
                break;
        }

        if ($request) {
            $request->chat_id = $chat->getId();
            $request->disable_notification = $attachment->getParameters()->get('disable_notification');
            $request->reply_to_message_id = $attachment->getParameters()->get('reply_to_message_id');
            $request->reply_markup = $attachment->getParameters()->get('reply_markup');

            $this->client->performApiRequest($request);
            $this->loop->run();
        }
    }
public function sendAttachment(Chat $chat, User $recipient, Attachment $attachment): void
    {
        $type = $attachment->getType();

        $request = null;

        switch ($type) {
            case Attachment::TYPE_FILE:
                $request = new SendDocument();
                $request->document = new InputFile($attachment->getPath());
                $request->caption = $attachment->getParameters()->get('caption');
                break;

            case Attachment::TYPE_IMAGE:
                $request = new SendPhoto();
                $request->caption = $attachment->getParameters()->get('caption');
                break;

            case Attachment::TYPE_AUDIO:
                $request = new SendAudio();
                $request->chat_id = $chat->getId();
                $request->caption = $attachment->getParameters()->get('caption');
                $request->duration = $attachment->getParameters()->get('duration');
                $request->performer = $attachment->getParameters()->get('performer');
                $request->title = $attachment->getParameters()->get('title');

                break;

            case Attachment::TYPE_VIDEO:
                $request = new SendVideo();
                $request->duration = $attachment->getParameters()->get('duration');
                $request->width = $attachment->getParameters()->get('width');
                $request->height = $attachment->getParameters()->get('height');
                $request->caption = $attachment->getParameters()->get('caption');
                break;
        }

        if ($request) {
            $request->chat_id = $chat->getId();
            $request->disable_notification = $attachment->getParameters()->get('disable_notification');
            $request->reply_to_message_id = $attachment->getParameters()->get('reply_to_message_id');
            $request->reply_markup = $attachment->getParameters()->get('reply_markup');

            $this->client->performApiRequest($request);
            $this->loop->run();
        }
    }
public function sendAttachment ( Chat $ chat , User $ recipient , Attachment $ attachment ) : void { $ type = $ attachment -> getType ( ) ; $ request = null ; switch ( $ type ) { case Attachment :: TYPE_FILE : $ request = new SendDocument ( ) ; $ request -> document = new InputFile ( $ attachment -> getPath ( ) ) ; $ request -> caption = $ attachment -> getParameters ( ) -> get ( 'caption' ) ; break ; case Attachment :: TYPE_IMAGE : $ request = new SendPhoto ( ) ; $ request -> caption = $ attachment -> getParameters ( ) -> get ( 'caption' ) ; break ; case Attachment :: TYPE_AUDIO : $ request = new SendAudio ( ) ; $ request -> chat_id = $ chat -> getId ( ) ; $ request -> caption = $ attachment -> getParameters ( ) -> get ( 'caption' ) ; $ request -> duration = $ attachment -> getParameters ( ) -> get ( 'duration' ) ; $ request -> performer = $ attachment -> getParameters ( ) -> get ( 'performer' ) ; $ request -> title = $ attachment -> getParameters ( ) -> get ( 'title' ) ; break ; case Attachment :: TYPE_VIDEO : $ request = new SendVideo ( ) ; $ request -> duration = $ attachment -> getParameters ( ) -> get ( 'duration' ) ; $ request -> width = $ attachment -> getParameters ( ) -> get ( 'width' ) ; $ request -> height = $ attachment -> getParameters ( ) -> get ( 'height' ) ; $ request -> caption = $ attachment -> getParameters ( ) -> get ( 'caption' ) ; break ; } if ( $ request ) { $ request -> chat_id = $ chat -> getId ( ) ; $ request -> disable_notification = $ attachment -> getParameters ( ) -> get ( 'disable_notification' ) ; $ request -> reply_to_message_id = $ attachment -> getParameters ( ) -> get ( 'reply_to_message_id' ) ; $ request -> reply_markup = $ attachment -> getParameters ( ) -> get ( 'reply_markup' ) ; $ this -> client -> performApiRequest ( $ request ) ; $ this -> loop -> run ( ) ; } }
Send attachment.

@param Chat $chat
@param User $recipient
@param Attachment $attachment
Send attachment .