1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// WARNING: THIS CODE IS AUTOGENERATED.
// DO NOT EDIT!!!
#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::ForumTopic;
use crate::Bot;
impl Bot {
/// Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.
/// <https://core.telegram.org/bots/api#createforumtopic>
pub fn create_forum_topic(&self, chat_id: i64, name: String) -> CreateForumTopicBuilder {
CreateForumTopicBuilder::new(self, chat_id, name)
}
}
#[derive(Serialize)]
pub struct CreateForumTopicBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
/// Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
pub chat_id: i64,
/// Topic name, 1-128 characters
pub name: String,
/// Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F)
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_color: Option<i64>,
/// Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_custom_emoji_id: Option<String>,
}
impl<'a> CreateForumTopicBuilder<'a> {
pub fn new(bot: &'a Bot, chat_id: i64, name: String) -> Self {
Self {
bot,
chat_id,
name,
icon_color: None,
icon_custom_emoji_id: None,
}
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = chat_id;
self
}
pub fn name(mut self, name: String) -> Self {
self.name = name;
self
}
pub fn icon_color(mut self, icon_color: i64) -> Self {
self.icon_color = Some(icon_color);
self
}
pub fn icon_custom_emoji_id(mut self, icon_custom_emoji_id: String) -> Self {
self.icon_custom_emoji_id = Some(icon_custom_emoji_id);
self
}
pub async fn send(self) -> Result<ForumTopic> {
let form = serde_json::to_value(&self)?;
self.bot.get("createForumTopic", Some(&form)).await
}
}