telegram: /reply_{id}

This commit is contained in:
Lewis Wynne 2026-04-10 20:16:11 +01:00
parent b3f5f403aa
commit 0b5456e398
2 changed files with 59 additions and 1 deletions

View file

@ -141,6 +141,28 @@ pub async fn bot_task(bot: Bot, chat_id: ChatId, data_dir: PathBuf) {
bot.send_message(msg.chat.id, e).await?;
}
}
} else if let Some(rest) = text.strip_prefix("/reply_") {
let (id, reply) = match rest.split_once('\n') {
Some((id, reply)) => (id.trim(), reply),
None => {
bot.send_message(msg.chat.id, "Usage: /reply_ID\\nYour reply text")
.await?;
return respond(());
}
};
if reply.trim().is_empty() {
bot.send_message(msg.chat.id, "Reply text is empty.").await?;
return respond(());
}
match entries::append_reply(&entries_dir, id, reply) {
Ok(name) => {
bot.send_message(msg.chat.id, format!("Reply added to {name}'s entry."))
.await?;
}
Err(e) => {
bot.send_message(msg.chat.id, e).await?;
}
}
} else if let Some(id) = text.strip_prefix("/delete_") {
match entries::delete_entry(&data_dir, id) {
Ok(name) => {