Просмотр исходного кода

[Telegram] /edit_item command added to full item list

Slava Barinov 1 год назад
Родитель
Сommit
c037491140
1 измененных файлов с 12 добавлено и 2 удалено
  1. 12 2
      src/telegram.rs

+ 12 - 2
src/telegram.rs

@@ -291,12 +291,22 @@ async fn handle_idle(bot: Bot, dialogue: QIFDialogue, msg: Message) -> HandlerRe
     Ok(())
     Ok(())
 }
 }
 
 
+/// List all the items' categories when the all the ticket is processed
 fn format_categories(catitems: &HashMap<String, String>) -> String {
 fn format_categories(catitems: &HashMap<String, String>) -> String {
     catitems
     catitems
         .iter()
         .iter()
-        .fold(String::new(), |mut acc, (item, category)| {
+        .enumerate()
+        .fold(String::new(), |mut acc, (index, (item, category))| {
             use std::fmt::Write;
             use std::fmt::Write;
-            writeln!(&mut acc, "{}: {}", item, category).unwrap();
+            writeln!(
+                &mut acc,
+                "{}. [{}: {}](/edit_{})",
+                index + 1,
+                item,
+                category,
+                item
+            )
+            .unwrap();
             acc
             acc
         })
         })
 }
 }