pub struct InputMessage { /* private fields */ }
Expand description

Construct and send rich text messages with various options.

Implementations

Whether to “send this message as a background message”.

This description is taken from https://core.telegram.org/method/messages.sendMessage.

Whether the draft in this chat, if any, should be cleared.

The formatting entities within the message (such as bold, italics, etc.).

Whether the link preview be shown for the message.

This has no effect when sending media, which cannot contain a link preview.

Defines the suggested reply markup for the message (such as adding inline buttons). This will be displayed below the message.

Only bot accounts can make use of the reply markup feature (a user attempting to send a message with a reply markup will result in the markup being ignored by Telegram).

The user is free to ignore the markup and continue sending usual text messages.

See crate::reply_markup for the different available markups along with how they behave.

The message identifier to which this message should reply to, if any.

Otherwise, this message will not be a reply to any other.

If set to a distant enough future time, the message won’t be sent immediately, and instead it will be scheduled to be automatically sent at a later time.

This scheduling is done server-side, and may not be accurate to the second.

Bot accounts cannot schedule messages.

Schedule the message to be sent once the person comes online.

This only works in private chats, and only if the person has their last seen visible.

Bot accounts cannot schedule messages.

Whether the message should notify people or not.

Defaults to false, which means it will notify them. Set it to true to alter this behaviour.

Include the uploaded file as a photo in the message.

The Telegram server will compress the image and convert it to JPEG format if necessary.

The text will be the caption of the photo, which may be empty for no caption.

Include an external photo in the message.

The Telegram server will download and compress the image and convert it to JPEG format if necessary.

The text will be the caption of the photo, which may be empty for no caption.

Include the uploaded file as a document in the message.

You can use this to send videos, stickers, audios, or uncompressed photos.

The text will be the caption of the document, which may be empty for no caption.

Include an external file as a document in the message.

You can use this to send videos, stickers, audios, or uncompressed photos.

The Telegram server will be the one that downloads and includes the document as media.

The text will be the caption of the document, which may be empty for no caption.

Add additional attributes to the message.

This must be called after setting a file.

Examples
use std::time::Duration;
use grammers_client::{types::Attribute, InputMessage};

let message = InputMessage::text("").document(audio).attribute(
   Attribute::Audio {
       duration: Duration::new(123, 0),
       title: Some("Hello".to_string()),
       performer: Some("World".to_string()),
   }
);

Copy media from an existing message.

You can use this to send media from another message without re-uploading it.

Include the uploaded file as a document file in the message.

You can use this to send any type of media as a simple document file.

The text will be the caption of the file, which may be empty for no caption.

Change the media’s Time To Live (TTL).

For example, this enables you to send a photo that can only be viewed for a certain amount of seconds before it expires.

Not all media supports this feature.

This method should be called before setting any media, else it won’t have any effect.

Change the media’s mime type.

This method will override the mime type that would otherwise be automatically inferred from the extension of the used file

If no mime type is set and it cannot be inferred, the mime type will be “application/octet-stream”.

This method should be called before setting any media, else it won’t have any effect.

Builds a new message using the given plaintext as the message contents.

Trait Implementations

Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.