make the bot more bettererererererer
This commit is contained in:
parent
805fb82a98
commit
f1909ecad8
26
src/bot.rs
26
src/bot.rs
|
@ -2,6 +2,7 @@ use std::error::Error;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::{Arc};
|
use std::sync::{Arc};
|
||||||
|
use std::thread;
|
||||||
use serenity::prelude::*;
|
use serenity::prelude::*;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable};
|
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable};
|
||||||
|
@ -117,13 +118,24 @@ async fn handle_packet(e: Event, config: &Arc<RwLock<Config>>, reciever: &Receiv
|
||||||
let re = Regex::new(r"@[a-z0-9_-]+:").unwrap();
|
let re = Regex::new(r"@[a-z0-9_-]+:").unwrap();
|
||||||
if !(re.is_match(&pkt.content()) && pkt.uuid() == Some(config.read().await.relay.uuid)) {
|
if !(re.is_match(&pkt.content()) && pkt.uuid() == Some(config.read().await.relay.uuid)) {
|
||||||
for wh in webhooks {
|
for wh in webhooks {
|
||||||
wh
|
|
||||||
.execute(http, false, |w| {
|
tokio::spawn({
|
||||||
w.content(pkt.content())
|
let wh_clone = wh.clone();
|
||||||
.username(pkt.username().unwrap_or("console".to_string())).allowed_mentions(|am| am.parse(ParseValue::Users).parse(ParseValue::Roles)).avatar_url(&format!("https://mc-heads.net/head/{}", pkt.uuid().map(|u| u.to_string()).unwrap_or("console".to_string())))
|
let http = Http::new("");
|
||||||
})
|
let pkt = pkt.clone();
|
||||||
.await
|
move || {
|
||||||
.expect("Could not execute webhook.");
|
async move {
|
||||||
|
wh_clone
|
||||||
|
.execute(http, false, |w| {
|
||||||
|
w.content(pkt.content())
|
||||||
|
.username(pkt.username().unwrap_or("console".to_string())).allowed_mentions(|am| am.parse(ParseValue::Users).parse(ParseValue::Roles)).avatar_url(&format!("https://mc-heads.net/head/{}", pkt.uuid().map(|u| u.to_string()).unwrap_or("console".to_string())))
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.expect("Could not execute webhook.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue