make the bot more bettererererererer
This commit is contained in:
parent
805fb82a98
commit
f1909ecad8
14
src/bot.rs
14
src/bot.rs
|
@ -2,6 +2,7 @@ use std::error::Error;
|
|||
use std::io::Cursor;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::{Arc};
|
||||
use std::thread;
|
||||
use serenity::prelude::*;
|
||||
use std::time::SystemTime;
|
||||
use azalea_buf::{McBufReadable, McBufVarReadable, McBufVarWritable};
|
||||
|
@ -117,7 +118,14 @@ async fn handle_packet(e: Event, config: &Arc<RwLock<Config>>, reciever: &Receiv
|
|||
let re = Regex::new(r"@[a-z0-9_-]+:").unwrap();
|
||||
if !(re.is_match(&pkt.content()) && pkt.uuid() == Some(config.read().await.relay.uuid)) {
|
||||
for wh in webhooks {
|
||||
wh
|
||||
|
||||
tokio::spawn({
|
||||
let wh_clone = wh.clone();
|
||||
let http = Http::new("");
|
||||
let pkt = pkt.clone();
|
||||
move || {
|
||||
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())))
|
||||
|
@ -126,6 +134,10 @@ async fn handle_packet(e: Event, config: &Arc<RwLock<Config>>, reciever: &Receiv
|
|||
.expect("Could not execute webhook.");
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue