use super::{
Command,
dox_impl::{dox, get_full_info, get_user_full},
};
use frankenstein::{client_reqwest::Bot, types::{Message, MessageOrigin}};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Dox {
pub doxee: Option<String>,
}
impl Command for Dox {
const TRIGGER: &'static str = "dox";
const HELP: &'static str = "盒盒盒";
async fn execute(self, bot: &Bot, msg: Message) -> String {
let doxer = match msg.from {
None => {
return include_str!("../messages/doxer-identification-failed.html")
.to_string();
}
Some(doxer) => *doxer,
};
let doxer_info = match get_full_info(bot, doxer.id).await {
None => {
return include_str!("../messages/doxer-identification-failed.html")
.to_string();
}
Some(full_info) => full_info,
};
let (doxee, doxee_info) = match self.doxee {
None => match msg.reply_to_message {
None => match msg.external_reply {
None => (doxer, Some(doxer_info)),
Some(external) => match external.origin {
MessageOrigin::User(user) => {
let sender = user.sender_user;
let full_info = get_full_info(bot, sender.id).await;
(sender, full_info)
}
_ => {
return include_str!("../messages/invalid-origin.html").to_string();
}
},
}
Some(reply) => match reply.from {
None => {
return include_str!("../messages/doxee-identification-failed.html")
.to_string();
}
Some(sender) => {
let full_info = get_full_info(bot, sender.id).await;
(*sender, full_info)
},
},
},
Some(doxee) => match get_user_full(bot, &doxee).await {
Some(user_and_info) => user_and_info,
None => {
return include_str!("../messages/doxee-identification-failed.html").to_string();
}
},
};
dox(&doxee, doxee_info.as_ref())
}
}