Files
baibot-withmcp/src/controller/utils/mod.rs

30 lines
774 B
Rust
Raw Normal View History

2024-09-12 13:44:06 +03:00
use mxlink::MessageResponseType;
use crate::{
Bot,
2025-02-27 07:46:16 +02:00
entity::{MessageContext, MessagePayload},
2024-09-12 13:44:06 +03:00
};
pub mod agent;
pub mod text_to_speech;
2024-09-12 13:44:06 +03:00
pub async fn get_text_body_or_complain<'a>(
bot: &Bot,
message_context: &'a MessageContext,
) -> Option<&'a str> {
match &message_context.payload() {
MessagePayload::Text(text_message_content) => Some(&text_message_content.body),
_ => {
bot.messaging()
.send_text_markdown_no_fail(
message_context.room(),
"This command only works with text messages.".to_owned(),
MessageResponseType::InThread(message_context.thread_info().clone()),
)
.await;
None
}
}
}