Sending a photo, video and other media
Sending a media by url or path
Send photo
If you want to send photo as message, you can use Photo class and pass it as content to answer.send
or MessageSend
Photo class take arguments:
Type how you want to upload the photo. Pass 'path' if you want to upload local file, or pass 'url' if you want to upload file by url
Required
Content. Pass path to the file if you passed 'path' as 1st argument, or pass url if you passed 'url' as 1st argument
Required
Optional
Cache. Pass false
to disable the cache
Optional
Send other media
You can also use other classes to send various media files. For example, use another class instead of the Photo class
:
Photo
Video
Audio
Document
Animation
Voice
VideoNote
Set thumb
You can set the thumb for some media files. Just use the .setThumb
method on the media class
.setThumb method takes argument: new instance of the Thumb class
Set caption
To set caption, use .setCaption
media class method
.setCaption method takes argument: caption you want to set (string)
Media caches
When you upload a new media file, its ID is stored in the nestgram/media.json
file so that when you resubmit this media file, you don't upload it again
If you want to disable cache for the same file, pass false
as 4th argument to the media class
Last updated