fix the chatspam problem
This commit is contained in:
parent
35574fa76a
commit
48a1a69575
|
@ -278,12 +278,11 @@ async fn handle_packet(e: Event, config: &Config, client: &mut Client, ws_stream
|
||||||
Event::Init => {}
|
Event::Init => {}
|
||||||
Event::Login => {}
|
Event::Login => {}
|
||||||
Event::Chat(pkt) => {
|
Event::Chat(pkt) => {
|
||||||
if pkt.content().starts_with("/skill") {
|
if !pkt.content().starts_with("/skill") {
|
||||||
return Ok(());
|
info!("<{} ({})> {}", pkt.username().unwrap_or("SYSTEM".to_string()), pkt.uuid().map(|u| u.to_string()).unwrap_or("SYSTEM".to_string()), pkt.message());
|
||||||
|
handle_message(pkt.clone(), client, config).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("<{} ({})> {}", pkt.username().unwrap_or("SYSTEM".to_string()), pkt.uuid().map(|u| u.to_string()).unwrap_or("SYSTEM".to_string()), pkt.message());
|
|
||||||
|
|
||||||
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.server.uuid)) {
|
if !(re.is_match(&pkt.content()) && pkt.uuid() == Some(config.server.uuid)) {
|
||||||
info!("sending message");
|
info!("sending message");
|
||||||
|
@ -295,7 +294,7 @@ async fn handle_packet(e: Event, config: &Config, client: &mut Client, ws_stream
|
||||||
}})?)).await?;
|
}})?)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_message(pkt.clone(), client, config).await;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
return Err("Disconnected by server")?;
|
return Err("Disconnected by server")?;
|
||||||
}
|
}
|
||||||
GatewayPacketS2C::Relayed { msg } => {
|
GatewayPacketS2C::Relayed { msg } => {
|
||||||
|
if msg.message.contains("/skill") { continue; } // fix chatspam problem
|
||||||
info!("msg: {:?}", msg);
|
info!("msg: {:?}", msg);
|
||||||
if matches!(msg.source, Discord) { continue; }
|
if matches!(msg.source, Discord) { continue; }
|
||||||
for wh in &config.websockets {
|
for wh in &config.websockets {
|
||||||
|
|
Loading…
Reference in New Issue