Implement gettitles command

This commit is contained in:
2025-12-18 16:05:47 -06:00
parent 14871b336a
commit 5ff8efbe42
2 changed files with 22 additions and 4 deletions
+21 -3
View File
@@ -121,12 +121,30 @@ pub async fn suggest(
pub async fn get_titles(
event: &OriginalSyncRoomMessageEvent,
room: &Room,
text: &str,
ctx: Ctx<MagbotContext>,
) -> anyhow::Result<()> {
// sends all the titles with an initial reaction to be used for voting
// save the message ids into context for count_votes()?
todo!()
let user = event.sender.to_string();
match ctx.0.status {
MagbotStatus::Running => {
for title in ctx.0.titles {
let msg = RoomMessageEventContent::text_plain(format!(
"{} : {}",
title.title, title.user
));
let response = room.send(msg).await?;
// save the message ids into context for count_votes()?
let reaction =
ReactionEventContent::new(Annotation::new(response.event_id, "👍".to_string()));
room.send(reaction).await?;
}
}
MagbotStatus::Sleeping => {
let msg = RoomMessageEventContent::text_plain(format!("{user} Magbot is not running"));
room.send(msg).await?;
}
}
Ok(())
}
/// Counts the votes of title suggestions
+1 -1
View File
@@ -75,7 +75,7 @@ async fn on_room_message(
// retrieve list of titles
s if s.to_lowercase().starts_with("!gettitles") => {
commands::get_titles(&event, &room, s, ctx).await?;
commands::get_titles(&event, &room, ctx).await?;
}
// count upvotes on posted suggestions