matrix-bot/src/commands/help.rs

20 lines
592 B
Rust

use anyhow::Result;
use enum_iterator::IntoEnumIterator;
use matrix_sdk::room::Joined;
use matrix_sdk::ruma::events::room::message::RoomMessageEventContent;
use super::BotCommand;
pub async fn help(room: Joined) -> Result<()> {
let mut msg = "List of commands:\n\n".to_owned();
for command in BotCommand::into_enum_iter() {
msg.push_str(&command.to_string());
msg.push_str(" - ");
msg.push_str(command.help_text());
msg.push('\n');
}
let content = RoomMessageEventContent::notice_plain(msg);
room.send(content, None).await?;
Ok(())
}