ferogram 0.6.5

A native, elegant, and asynchronous MTProto framework in Rust for Telegram clients, bots, and applications.
Documentation
/*
 * Copyright (c) 2026 Ankit Chaubey <ankitchaubey.dev@gmail.com>
 * https://github.com/ankit-chaubey
 *
 * Project: ferogram
 * Website: https://ferogram.dev
 *
 * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
 * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
 * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
 * This file may not be copied, modified, or distributed except according
 * to those terms.
 */

use ferogram_tl_types::{self as tl, enums::Reaction};

/// A set of reactions to apply to a message.
///
/// Construct with [`InputReactions::emoticon`], [`InputReactions::custom_emoji`],
/// [`InputReactions::remove`], or `From<Vec<Reaction>>`.
#[derive(Clone, Debug, Default)]
pub struct InputReactions {
    pub(crate) reactions: Vec<Reaction>,
    pub(crate) add_to_recent: bool,
    pub(crate) big: bool,
}

impl InputReactions {
    // Constructors

    /// React with a standard Unicode emoji (e.g. `"👍"`).
    pub fn emoticon<S: Into<String>>(emoticon: S) -> Self {
        Self {
            reactions: vec![Reaction::Emoji(tl::types::ReactionEmoji {
                emoticon: emoticon.into(),
            })],
            ..Self::default()
        }
    }

    /// React with a custom (premium) emoji identified by its `document_id`.
    pub fn custom_emoji(document_id: i64) -> Self {
        Self {
            reactions: vec![Reaction::CustomEmoji(tl::types::ReactionCustomEmoji {
                document_id,
            })],
            ..Self::default()
        }
    }

    /// Remove all reactions from the message.
    pub fn remove() -> Self {
        Self::default()
    }

    // Modifiers

    /// Play the reaction with a large animated effect.
    pub fn big(mut self) -> Self {
        self.big = true;
        self
    }

    /// Add this reaction to the user's recent reactions list.
    pub fn add_to_recent(mut self) -> Self {
        self.add_to_recent = true;
        self
    }
}

// From impls

impl From<&str> for InputReactions {
    fn from(s: &str) -> Self {
        InputReactions::emoticon(s)
    }
}

impl From<String> for InputReactions {
    fn from(s: String) -> Self {
        InputReactions::emoticon(s)
    }
}

impl From<Vec<Reaction>> for InputReactions {
    fn from(reactions: Vec<Reaction>) -> Self {
        Self {
            reactions,
            ..Self::default()
        }
    }
}

impl From<InputReactions> for Vec<Reaction> {
    fn from(r: InputReactions) -> Self {
        r.reactions
    }
}