forked from nolan/titlebot-ng-ng
Implement the start command
This commit is contained in:
@@ -4,17 +4,32 @@ use matrix_sdk::{
|
||||
ruma::events::room::message::{OriginalSyncRoomMessageEvent, RoomMessageEventContent},
|
||||
};
|
||||
|
||||
use crate::MagbotContext;
|
||||
use crate::{MagbotContext, config::MagbotStatus};
|
||||
|
||||
/// Sets up the bot to listen for title suggestions
|
||||
pub async fn start(
|
||||
event: &OriginalSyncRoomMessageEvent,
|
||||
room: &Room,
|
||||
ctx: Ctx<MagbotContext>,
|
||||
mut ctx: Ctx<MagbotContext>,
|
||||
) -> anyhow::Result<()> {
|
||||
let user = event.sender.to_string();
|
||||
// set to listening
|
||||
// send message that magbot is listening
|
||||
todo!()
|
||||
match ctx.0.status {
|
||||
MagbotStatus::Running => {
|
||||
let msg = RoomMessageEventContent::text_plain(format!(
|
||||
"{user} Magbot is already listening for titles!"
|
||||
));
|
||||
room.send(msg).await?;
|
||||
}
|
||||
MagbotStatus::Sleeping => {
|
||||
ctx.0.status = MagbotStatus::Running;
|
||||
let msg = RoomMessageEventContent::text_plain(format!(
|
||||
"{user} Magbot is now listening for titles!"
|
||||
));
|
||||
room.send(msg).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Stops the bot from listening for title suggestions
|
||||
|
||||
Reference in New Issue
Block a user