1use super::{push_opt, push_opt_str, Bot, ChatId, Result};
2use crate::request::request_parameter::RequestParameter;
3use crate::types::forum_topic;
4
5#[allow(dead_code)]
6impl Bot {
7 pub async fn create_forum_topic_raw(
15 &self,
16 chat_id: ChatId,
17 name: &str,
18 icon_color: Option<i64>,
19 icon_custom_emoji_id: Option<&str>,
20 ) -> Result<forum_topic::ForumTopic> {
21 let mut params = vec![
22 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
23 RequestParameter::new("name", serde_json::Value::String(name.to_owned())),
24 ];
25 push_opt(&mut params, "icon_color", &icon_color)?;
26 push_opt_str(&mut params, "icon_custom_emoji_id", icon_custom_emoji_id);
27 self.do_post("createForumTopic", params).await
28 }
29
30 pub async fn edit_forum_topic_raw(
34 &self,
35 chat_id: ChatId,
36 message_thread_id: i64,
37 name: Option<&str>,
38 icon_custom_emoji_id: Option<&str>,
39 ) -> Result<bool> {
40 let mut params = vec![
41 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
42 RequestParameter::new(
43 "message_thread_id",
44 serde_json::to_value(message_thread_id)?,
45 ),
46 ];
47 push_opt_str(&mut params, "name", name);
48 push_opt_str(&mut params, "icon_custom_emoji_id", icon_custom_emoji_id);
49 self.do_post("editForumTopic", params).await
50 }
51
52 pub async fn close_forum_topic_raw(
56 &self,
57 chat_id: ChatId,
58 message_thread_id: i64,
59 ) -> Result<bool> {
60 let params = vec![
61 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
62 RequestParameter::new(
63 "message_thread_id",
64 serde_json::to_value(message_thread_id)?,
65 ),
66 ];
67 self.do_post("closeForumTopic", params).await
68 }
69
70 pub async fn reopen_forum_topic_raw(
74 &self,
75 chat_id: ChatId,
76 message_thread_id: i64,
77 ) -> Result<bool> {
78 let params = vec![
79 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
80 RequestParameter::new(
81 "message_thread_id",
82 serde_json::to_value(message_thread_id)?,
83 ),
84 ];
85 self.do_post("reopenForumTopic", params).await
86 }
87
88 pub async fn delete_forum_topic_raw(
92 &self,
93 chat_id: ChatId,
94 message_thread_id: i64,
95 ) -> Result<bool> {
96 let params = vec![
97 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
98 RequestParameter::new(
99 "message_thread_id",
100 serde_json::to_value(message_thread_id)?,
101 ),
102 ];
103 self.do_post("deleteForumTopic", params).await
104 }
105
106 pub async fn unpin_all_forum_topic_messages_raw(
110 &self,
111 chat_id: ChatId,
112 message_thread_id: i64,
113 ) -> Result<bool> {
114 let params = vec![
115 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
116 RequestParameter::new(
117 "message_thread_id",
118 serde_json::to_value(message_thread_id)?,
119 ),
120 ];
121 self.do_post("unpinAllForumTopicMessages", params).await
122 }
123
124 pub async fn unpin_all_general_forum_topic_messages_raw(
128 &self,
129 chat_id: ChatId,
130 ) -> Result<bool> {
131 let params = vec![RequestParameter::new(
132 "chat_id",
133 serde_json::to_value(&chat_id)?,
134 )];
135 self.do_post("unpinAllGeneralForumTopicMessages", params)
136 .await
137 }
138
139 pub async fn edit_general_forum_topic_raw(&self, chat_id: ChatId, name: &str) -> Result<bool> {
143 let params = vec![
144 RequestParameter::new("chat_id", serde_json::to_value(&chat_id)?),
145 RequestParameter::new("name", serde_json::Value::String(name.to_owned())),
146 ];
147 self.do_post("editGeneralForumTopic", params).await
148 }
149
150 pub async fn close_general_forum_topic_raw(&self, chat_id: ChatId) -> Result<bool> {
154 let params = vec![RequestParameter::new(
155 "chat_id",
156 serde_json::to_value(&chat_id)?,
157 )];
158 self.do_post("closeGeneralForumTopic", params).await
159 }
160
161 pub async fn reopen_general_forum_topic_raw(&self, chat_id: ChatId) -> Result<bool> {
165 let params = vec![RequestParameter::new(
166 "chat_id",
167 serde_json::to_value(&chat_id)?,
168 )];
169 self.do_post("reopenGeneralForumTopic", params).await
170 }
171
172 pub async fn hide_general_forum_topic_raw(&self, chat_id: ChatId) -> Result<bool> {
176 let params = vec![RequestParameter::new(
177 "chat_id",
178 serde_json::to_value(&chat_id)?,
179 )];
180 self.do_post("hideGeneralForumTopic", params).await
181 }
182
183 pub async fn unhide_general_forum_topic_raw(&self, chat_id: ChatId) -> Result<bool> {
187 let params = vec![RequestParameter::new(
188 "chat_id",
189 serde_json::to_value(&chat_id)?,
190 )];
191 self.do_post("unhideGeneralForumTopic", params).await
192 }
193}