use furbooru::Client; use robespierre::framework::standard::{macros::command, CommandResult, FwContext}; use robespierre::model::MessageExt; use robespierre::UserData; use robespierre_models::channel::Message; use std::sync::Arc; use tokio::sync::Mutex; pub struct ClientKey; impl robespierre::typemap::Key for ClientKey { type Value = Arc>; } pub fn make(username: String, api_key: String) -> Arc> { Arc::new(Mutex::new( Client::new(user_agent(username), api_key).unwrap(), )) } pub fn user_agent(username: String) -> String { format!( "{}/{} (owner: {})", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"), username, ) } // #[command] // pub async fn search_impl(ctx: &FwContext, msg: &Message) -> CommandResult { // let data = ctx.data_lock_read().await; // let client = data.get::().unwrap().clone(); // let client = client.lock().await; // let mut imgs = client.image_search(args, 0_u64).await?; // let mut response = String::new(); // imgs.truncate(3); // for mut post in imgs.into_iter() { // post.tags.sort(); // post.tags.truncate(8); // response.push_str(&format!( // "<{}> - {} - <{}>\n", // format!("http://furbooru.org/{}", post.id), // post.tags.join(", "), // post.view_url, // )); // } // msg.reply(ctx, response).await?; // Ok(()) // }