async fn message(&self, ctx: Context, msg: Message) {
        if msg.is_own(&ctx.cache).await {
            return;
        }
        lazy_static! {
            static ref WOOF_RE: Regex = Regex::new(
                r"^((oua+f+\s*)+|(w(a|o|0|u|🌕)+r*f\s*)+|(aw+(o|0|🌕)+\s*)+|(b(a|o)+rk\s*)+|(汪\s*)+|(ワン\s*)+|(わん\s*)+|(гав\s*)+|(uowhf\s*)+)+(!|！)*$"
            )
            .unwrap();
            static ref WEATHER_RE: Regex = Regex::new(r"^puppy weather\s\w+").unwrap();
            static ref STONK_RE: Regex = Regex::new(r"^puppy stonk\s\w+").unwrap();
            static ref CHESS_RE: Regex = Regex::new(r"^puppy chess\s\w*").unwrap();
        }
        let content = &msg.content;
        let lower = content.to_lowercase();
        if WOOF_RE.is_match(&lower) {
            if let Err(why) = msg.reply(&ctx.http, content).await {
                println!("Error sending message: {:?}", why);
            }
        } else if lower == "puppy why" {
            if let Err(why) = msg.reply(&ctx.http, puppywhy::why()).await {
                println!("Error sending message: {:?}", why);
            }
        } else if lower == "puppy how" {
            if let Err(why) = msg
                .reply(&ctx.http, "https://github.com/dllu/discord-woofer-rust")
                .await
            {
                println!("Error sending message: {:?}", why);
            }
        } else if STONK_RE.is_match(&lower) {
            let ticker = &lower[12..];
            let stonk = puppystonk::stonk(&ticker).await.unwrap();
            if let Err(why) = msg.reply(&ctx.http, &stonk).await {
                println!("Error sending message: {:?}", why);
            }
        } else if WEATHER_RE.is_match(&lower) {
            let address = &lower[14..];
            // TODO: error handlin
            let location = puppyweather::geocode(address.to_string(), &self.google_maps_token)
                .await
                .unwrap();
            let weather = puppyweather::weather(&location, &self.openweather_token)
                .await
                .unwrap();
            let response = puppyweather::weather_string(address.to_string(), &location, weather);
            if let Err(why) = msg.reply(&ctx.http, response).await {
                println!("Error sending message: {:?}", why);
            }
        } else if CHESS_RE.is_match(&lower) {
            let res = chess(&ctx, &msg).await;
            match res {
                Ok(s) => {
                    if let Err(why) = msg.reply(&ctx.http, s).await {
                        println!("Error sending message: {:?}", why);
                    }
                }
                Err(_) => {
                    if let Err(why) = msg.reply(&ctx.http, "Illegal move!!!!!").await {
                        println!("Error sending message: {:?}", why);
                    }
                }
            }
        }
    }
// Set a handler for the `message` event - so that whenever a new message
// is received - the closure (or function) passed will be called.
//
// Event handlers are dispatched through a threadpool, and so multiple
// events can be dispatched simultaneously.
Set a handler for the `message` event - so that whenever a new message
is received - the closure (or function) passed will be called.

Event handlers are dispatched through a threadpool, and so multiple
events can be dispatched simultaneously.
Set a handler for the ` message ` event - so that whenever a new message is received - the closure ( or function ) passed will be called . Event handlers are dispatched through a threadpool and so multiple events can be dispatched simultaneously .
async fn message(&self, ctx: Context, msg: Message) {
        if msg.is_own(&ctx.cache).await {
            return;
        }
        lazy_static! {
            static ref WOOF_RE: Regex = Regex::new(
                r"^((oua+f+\s*)+|(w(a|o|0|u|🌕)+r*f\s*)+|(aw+(o|0|🌕)+\s*)+|(b(a|o)+rk\s*)+|(汪\s*)+|(ワン\s*)+|(わん\s*)+|(гав\s*)+|(uowhf\s*)+)+(!|！)*$"
            )
            .unwrap();
            static ref WEATHER_RE: Regex = Regex::new(r"^puppy weather\s\w+").unwrap();
            static ref STONK_RE: Regex = Regex::new(r"^puppy stonk\s\w+").unwrap();
            static ref CHESS_RE: Regex = Regex::new(r"^puppy chess\s\w*").unwrap();
        }
        let content = &msg.content;
        let lower = content.to_lowercase();
        if WOOF_RE.is_match(&lower) {
            if let Err(why) = msg.reply(&ctx.http, content).await {
                println!("Error sending message: {:?}", why);
            }
        } else if lower == "puppy why" {
            if let Err(why) = msg.reply(&ctx.http, puppywhy::why()).await {
                println!("Error sending message: {:?}", why);
            }
        } else if lower == "puppy how" {
            if let Err(why) = msg
                .reply(&ctx.http, "https://github.com/dllu/discord-woofer-rust")
                .await
            {
                println!("Error sending message: {:?}", why);
            }
        } else if STONK_RE.is_match(&lower) {
            let ticker = &lower[12..];
            let stonk = puppystonk::stonk(&ticker).await.unwrap();
            if let Err(why) = msg.reply(&ctx.http, &stonk).await {
                println!("Error sending message: {:?}", why);
            }
        } else if WEATHER_RE.is_match(&lower) {
            let address = &lower[14..];
            // TODO: error handlin
            let location = puppyweather::geocode(address.to_string(), &self.google_maps_token)
                .await
                .unwrap();
            let weather = puppyweather::weather(&location, &self.openweather_token)
                .await
                .unwrap();
            let response = puppyweather::weather_string(address.to_string(), &location, weather);
            if let Err(why) = msg.reply(&ctx.http, response).await {
                println!("Error sending message: {:?}", why);
            }
        } else if CHESS_RE.is_match(&lower) {
            let res = chess(&ctx, &msg).await;
            match res {
                Ok(s) => {
                    if let Err(why) = msg.reply(&ctx.http, s).await {
                        println!("Error sending message: {:?}", why);
                    }
                }
                Err(_) => {
                    if let Err(why) = msg.reply(&ctx.http, "Illegal move!!!!!").await {
                        println!("Error sending message: {:?}", why);
                    }
                }
            }
        }
    }
async fn message ( & self , ctx : Context , msg : Message ) { if msg . is_own ( & ctx . cache ) . await { return ; } lazy_static ! { static ref WOOF_RE Regex Regex new ( r"^((oua+f+\s*)+|(w(a|o|0|u|🌕)+r*f\s*)+|(aw+(o|0|🌕)+\s*)+|(b(a|o)+rk\s*)+|(汪\s*)+|(ワン\s*)+|(わん\s*)+|(гав\s*)+|(uowhf\s*)+)+(!|！)*$" ) unwrap ( ) static ref WEATHER_RE Regex Regex new ( r"^puppy weather\s\w+" ) unwrap ( ) static ref STONK_RE Regex Regex new ( r"^puppy stonk\s\w+" ) unwrap ( ) static ref CHESS_RE Regex Regex new ( r"^puppy chess\s\w*" ) unwrap ( ) } let content = & msg . content ; let lower = content . to_lowercase ( ) ; if WOOF_RE . is_match ( & lower ) { if let Err ( why ) = msg . reply ( & ctx . http , content ) . await { println ! ( " " why ) ; } } else if lower == " " { if let Err ( why ) = msg . reply ( & ctx . http , puppywhy :: why ( ) ) . await { println ! ( " " why ) ; } } else if lower == " " { if let Err ( why ) = msg . reply ( & ctx . http , " " ) . await { println ! ( " " why ) ; } } else if STONK_RE . is_match ( & lower ) { let ticker = & lower [ 12 .. ] ; let stonk = puppystonk :: stonk ( & ticker ) . await . unwrap ( ) ; if let Err ( why ) = msg . reply ( & ctx . http , & stonk ) . await { println ! ( " " why ) ; } } else if WEATHER_RE . is_match ( & lower ) { let address = & lower [ 14 .. ] ; // TODO: error handlin let location = puppyweather :: geocode ( address . to_string ( ) , & self . google_maps_token ) . await . unwrap ( ) ; let weather = puppyweather :: weather ( & location , & self . openweather_token ) . await . unwrap ( ) ; let response = puppyweather :: weather_string ( address . to_string ( ) , & location , weather ) ; if let Err ( why ) = msg . reply ( & ctx . http , response ) . await { println ! ( " " why ) ; } } else if CHESS_RE . is_match ( & lower ) { let res = chess ( & ctx , & msg ) . await ; match res { Ok ( s ) => { if let Err ( why ) = msg . reply ( & ctx . http , s ) . await { println ! ( " " why ) ; } } Err ( _ ) => { if let Err ( why ) = msg . reply ( & ctx . http , " " ) . await { println ! ( " " why ) ; } } } } }
Set a handler for the `message` event - so that whenever a new message
is received - the closure (or function) passed will be called.
Set a handler for the ` message ` event - so that whenever a new message is received - the closure ( or function ) passed will be called .
&self
ctx
Context
msg
Message
&self
ctx
Context
msg
Message