Prechádzať zdrojové kódy

[Telegram] /edit_item command added to full item list

Slava Barinov 1 rok pred
rodič
commit
c037491140
1 zmenil súbory, kde vykonal 12 pridanie a 2 odobranie
  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(())
 }
 
+/// List all the items' categories when the all the ticket is processed
 fn format_categories(catitems: &HashMap<String, String>) -> String {
     catitems
         .iter()
-        .fold(String::new(), |mut acc, (item, category)| {
+        .enumerate()
+        .fold(String::new(), |mut acc, (index, (item, category))| {
             use std::fmt::Write;
-            writeln!(&mut acc, "{}: {}", item, category).unwrap();
+            writeln!(
+                &mut acc,
+                "{}. [{}: {}](/edit_{})",
+                index + 1,
+                item,
+                category,
+                item
+            )
+            .unwrap();
             acc
         })
 }