nasus

Crates.ionasus
lib.rsnasus
version0.2.1
sourcesrc
created_at2023-02-16 20:23:16.85808
updated_at2023-05-15 21:19:34.469825
descriptionnasus is a blazing fast osu BanchoBot handler 📬
homepage
repositoryhttps://github.com/AuracleTech/nasus/
max_upload_size
id787036
size28,701
A (AuracleTech)

documentation

README

nasus

nasus is a osu BanchoBot handler 📬

Example

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    use nasus::{BanchoConfig, CmdIn, CmdOut, Nasus};

    let config = BanchoConfig {
        username: "Auracle".to_string(),
        irc_token: "IRC Token".to_string(),
        host: "irc.ppy.sh".to_string(),
        port: 6667,
        bot: false,
    };
    let mut nasus = Nasus::new(config).await?;

    loop {
        nasus.work().await?;

        match nasus.inputs.pop() {
            Some(cmd_in) => match cmd_in {
                CmdIn::AuthSuccess { message } => println!("{}", message),
                CmdIn::AuthFailure { message } => println!("{}", message),
                CmdIn::ReceivePM {
                    sender,
                    receiver,
                    message,
                    action,
                } => {
                    println!("{}: {}", sender, message);

                    let replies = match action {
                        true => "I see what you did there",
                        false => "I'm not a bot, I swear!",
                    };
                    let cmd_out = CmdOut::SendPM {
                        receiver: sender,
                        message: replies.to_string(),
                    };
                    nasus.write_command(cmd_out).await?;
                    println!("{}: {}", receiver, replies);
                }
                _ => {}
            },
            None => {}
        };

        match nasus.outputs.pop() {
            Some(cmd_out) => match cmd_out {
                CmdOut::SendPM { receiver, message } => println!("{}: {}", receiver, message),
                _ => {}
            },
            None => {}
        };
    }
}

Commands

Commands we receive from BanchoBot are CmdIn

AuthSuccess { message: String }
AuthFailure { message: String }
MOTDStart { message: String }
MOTDMiddle { message: String }
MOTDEnd { message: String }
Quit { user: String }
UserNotFound
ReceivePM {
    sender: String
    receiver: String
    message: String
    action: bool
}
Ping
Pong

Commands we send to BanchoBot are CmdOut

Login { username: String, irc_token: String }
SendPM { receiver: String, message: String }
Ping
Pong
Commit count: 32

cargo fmt