Skip to main content

rustigram_types/
forum.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4/// A topic in a Telegram forum supergroup.
5///
6/// Forum topics are the individual discussion threads inside a supergroup
7/// with `is_forum = true`. Returned by [`createForumTopic`](https://core.telegram.org/bots/api#createforumtopic).
8pub struct ForumTopic {
9    /// Unique identifier of the forum topic thread.
10    pub message_thread_id: i64,
11    /// Name of the topic (1–128 characters).
12    pub name: String,
13    /// Color of the topic icon as an RGB integer.
14    pub icon_color: u32,
15    /// Custom emoji identifier used as the topic icon.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub icon_custom_emoji_id: Option<String>,
18    /// `true` if the topic name was derived from the first message rather than
19    /// set explicitly.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub is_name_implicit: Option<bool>,
22}
23
24// ─── Service messages ────────────────────────────────────────────────────────
25//
26// Telegram delivers forum lifecycle events as service messages on [`Message`].
27// Four of the six carry no data at all — their presence is the entire signal —
28// but they are still objects on the wire, so each is an empty struct rather
29// than a unit struct: a unit struct deserializes from `null`, not from `{}`.
30//
31// [`Message`]: crate::message::Message
32
33/// Service message: a forum topic was created.
34#[derive(Debug, Clone, Default, Serialize, Deserialize)]
35#[non_exhaustive]
36pub struct ForumTopicCreated {
37    /// Name of the topic.
38    pub name: String,
39    /// Color of the topic icon as an RGB integer.
40    pub icon_color: u32,
41    /// Custom emoji identifier used as the topic icon.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub icon_custom_emoji_id: Option<String>,
44    /// `true` if the topic name was derived from the first message rather than
45    /// set explicitly.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub is_name_implicit: Option<bool>,
48}
49
50/// Service message: a forum topic was closed.
51#[derive(Debug, Clone, Default, Serialize, Deserialize)]
52#[non_exhaustive]
53pub struct ForumTopicClosed {}
54
55/// Service message: a forum topic was edited.
56#[derive(Debug, Clone, Default, Serialize, Deserialize)]
57#[non_exhaustive]
58pub struct ForumTopicEdited {
59    /// New name of the topic, if it was changed.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub name: Option<String>,
62    /// New icon emoji identifier, if it was changed. An empty string means the
63    /// custom icon was removed.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub icon_custom_emoji_id: Option<String>,
66}
67
68/// Service message: a forum topic was reopened.
69#[derive(Debug, Clone, Default, Serialize, Deserialize)]
70#[non_exhaustive]
71pub struct ForumTopicReopened {}
72
73/// Service message: the "General" forum topic was hidden.
74#[derive(Debug, Clone, Default, Serialize, Deserialize)]
75#[non_exhaustive]
76pub struct GeneralForumTopicHidden {}
77
78/// Service message: the "General" forum topic was unhidden.
79#[derive(Debug, Clone, Default, Serialize, Deserialize)]
80#[non_exhaustive]
81pub struct GeneralForumTopicUnhidden {}