mara/src/commands/furbooru.rs

31 lines
718 B
Rust

use furbooru::Client;
use robespierre::framework::standard::{macros::command, CommandResult, FwContext};
use std::sync::Arc;
use tokio::sync::Mutex;
pub struct ClientKey;
impl robespierre::typemap::Key for ClientKey {
type Value = Arc<Mutex<Client>>;
}
pub fn make(username: String, api_key: String) -> Arc<Mutex<Client>> {
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(ctx: &FWContext, msg: &Message, args: &str) -> CommandResult {
Ok(())
}