Skip to main content

MessageBuilder

Struct MessageBuilder 

Source
pub struct MessageBuilder { /* private fields */ }
Expand description

Builds a Message from styled spans.

Formatting is expressed as Telegram entities rather than as parse_mode markup, which means interpolated text is never parsed and therefore never needs escaping. A filename, a username, or an arbitrary error string can be passed straight through with no sanitizing step.

Implementations§

Source§

impl MessageBuilder

Source

pub fn text(self, text: impl AsRef<str>) -> Self

Appends unformatted text.

Source

pub fn styled(self, text: impl AsRef<str>, style: Style) -> Self

Appends text carrying an arbitrary combination of inline styles.

Source

pub fn bold(self, text: impl AsRef<str>) -> Self

Appends bold text.

Source

pub fn italic(self, text: impl AsRef<str>) -> Self

Appends italic text.

Source

pub fn underline(self, text: impl AsRef<str>) -> Self

Appends underlined text.

Source

pub fn strikethrough(self, text: impl AsRef<str>) -> Self

Appends struck-through text.

Source

pub fn spoiler(self, text: impl AsRef<str>) -> Self

Appends text hidden behind a spoiler.

Source

pub fn code(self, text: impl AsRef<str>) -> Self

Appends monospaced inline code.

Appends text which links to a URL.

Source

pub fn mention(self, text: impl AsRef<str>, user_id: i64) -> Self

Appends a mention of a user who has no username.

Source

pub fn custom_emoji( self, text: impl AsRef<str>, custom_emoji_id: impl Into<String>, ) -> Self

Appends an inline custom emoji sticker.

Source

pub fn pre(self, text: impl AsRef<str>, language: Option<&str>) -> Self

Appends a preformatted block, optionally tagged with a language.

Only available at the top level: Telegram does not permit pre to be nested inside other entities.

Source

pub fn blockquote( self, build: impl FnOnce(InlineBuilder) -> InlineBuilder, ) -> Self

Appends a block quotation containing inline-formatted content.

Source

pub fn expandable_blockquote( self, build: impl FnOnce(InlineBuilder) -> InlineBuilder, ) -> Self

Appends a block quotation which is collapsed by default.

Source

pub fn photo(self, source: FileSource) -> Self

Attaches a photo, making the accumulated text its caption.

Source

pub fn document(self, source: FileSource) -> Self

Attaches a document, making the accumulated text its caption.

Source

pub const fn disable_notification(self, disable: bool) -> Self

Delivers the message silently, without a notification sound.

Source

pub const fn protect_content(self, protect: bool) -> Self

Prevents the message from being forwarded or saved.

Controls whether a link in the message generates a preview card.

Source

pub const fn message_thread_id(self, thread_id: i64) -> Self

Targets a specific topic within a forum chat.

Source

pub const fn reply_to_message_id(self, message_id: i64) -> Self

Sends the message as a reply to an existing one.

Source

pub fn build(self) -> Message

Finalizes the message.

Trait Implementations§

Source§

impl Clone for MessageBuilder

Source§

fn clone(&self) -> MessageBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MessageBuilder

Source§

fn default() -> MessageBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more