Skip to content

Commit 376ef9d

Browse files
committed
chore: warn command is smarter now
1 parent 6842b5b commit 376ef9d

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/functions/help.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use teloxide::{prelude::*, types::ParseMode};
66
static TEXT: &[(&str, &str)] = &[
77
("help", "ushbu xabarni qayta ko'rsatish"),
88
("rules", "qoidalarni aks ettirish"),
9+
("check", "chaqirilgan joydan parametrlarni ko'rish"),
910
("about", "ushbu botimizning rivojlantirish qismi"),
1011
("group", "rust ga oid guruh va hamjamiyatlar"),
1112
("roadmap", "boshlang'ich o'rganuvchilar uchun"),

src/functions/warn.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ static TEXT_FAIL: &str = "Ha-ha... yaxshi urinish!";
1515
static TEXT_NON_REPLY: &str = "↪ Reply bilan ko'rsatingchi habarni!";
1616
static NON_COMMUNITY: &str = "Ebe hay, biz O'zbek Rust hamjamiyati guruhida emasga o'xshaymiz...";
1717

18+
static FLOSS_CHAT: ChatId = ChatId(-1001303954475);
19+
static RUST_CHAT: ChatId = ChatId(-1001518595284);
20+
1821
pub async fn command(bot: &Bot, msg: &Message, me: &Me, topics: &Topics) -> ResponseResult<()> {
19-
// if chat is not rust uzbekistan, delete
20-
if msg.chat.id != ChatId(-1001518595284) {
22+
// if chat is not community, delete
23+
if msg.chat.id != RUST_CHAT {
2124
return {
2225
bot.send_message_tf(msg.chat.id, NON_COMMUNITY, msg).await?;
2326
Ok(())
@@ -156,7 +159,7 @@ pub async fn callback(
156159
None => {
157160
return {
158161
bot.send_message(
159-
ChatId(-1001518595284),
162+
RUST_CHAT,
160163
"Qaysidir thread da xabarni tushuna olmadim, akalar meni loglarim qarab ko'rasizlarmi?",
161164
)
162165
.message_thread_id(ThreadId(MessageId(255895)))
@@ -242,9 +245,15 @@ pub async fn callback(
242245
}
243246
};
244247

245-
let forward = bot.forward_message(message.chat.id, message.chat.id, replied_message);
248+
// select where to forward message
249+
let forward = match c {
250+
0 => bot.forward_message(FLOSS_CHAT.to_string(), message.chat.id, replied_message),
251+
_ => bot.forward_message(message.chat.id, message.chat.id, replied_message),
252+
};
253+
254+
// if it has topic, appoint it
246255
match parsed_topic {
247-
1 => {
256+
0..1 => {
248257
forward.await?;
249258
}
250259
_ => {
@@ -292,7 +301,7 @@ pub fn view_detail(from: (&str, &str), topic: String) -> String {
292301
{} guruhimizda ushbu mavzuga oid narsalar haqida suhbatlashish ruxsat etiladi. \
293302
Boshqalarga halaqit qilmayliga 😉\
294303
\n\n\
295-
<b>Hurmat ila, Rustacean</b>",
304+
<b>Hurmat ila, Rustacean Menejer</b>",
296305
from.0,
297306
from.1,
298307
topic,
@@ -314,7 +323,7 @@ where
314323

315324
for (index, topic) in list.iter().enumerate() {
316325
keyboard.text(
317-
&topic.capitalize(),
326+
topic,
318327
&format!(
319328
"warn_{}_{}_{}_{}_{}",
320329
owner.0, topic, replied.0, name, replied_message

0 commit comments

Comments
 (0)