2024-09-12 13:44:06 +03:00
|
|
|
use mxlink::MessageResponseType;
|
|
|
|
|
|
2025-02-27 07:46:16 +02:00
|
|
|
use crate::{Bot, entity::MessageContext, strings};
|
2024-09-12 13:44:06 +03:00
|
|
|
|
|
|
|
|
pub async fn handle_get<T>(
|
|
|
|
|
bot: &Bot,
|
|
|
|
|
message_context: &MessageContext,
|
|
|
|
|
value: &Option<T>,
|
|
|
|
|
) -> anyhow::Result<()>
|
|
|
|
|
where
|
|
|
|
|
T: std::fmt::Display,
|
|
|
|
|
{
|
|
|
|
|
match value {
|
|
|
|
|
Some(value) => {
|
|
|
|
|
bot.messaging()
|
|
|
|
|
.send_text_markdown_no_fail(
|
|
|
|
|
message_context.room(),
|
|
|
|
|
strings::cfg::value_currently_set_to(value),
|
|
|
|
|
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
|
|
|
|
)
|
|
|
|
|
.await;
|
|
|
|
|
}
|
|
|
|
|
None => {
|
|
|
|
|
bot.messaging()
|
|
|
|
|
.send_text_markdown_no_fail(
|
|
|
|
|
message_context.room(),
|
|
|
|
|
strings::cfg::value_currently_unset(),
|
|
|
|
|
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
|
|
|
|
)
|
|
|
|
|
.await;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|