Fix instance not setting nick or using password

This commit is contained in:
Joscha 2023-01-21 13:11:33 +01:00
parent c1a970ae3c
commit bd74931ecd

View file

@ -12,6 +12,7 @@ use tokio::select;
use tokio::sync::{mpsc, oneshot}; use tokio::sync::{mpsc, oneshot};
use crate::api::packet::ParsedPacket; use crate::api::packet::ParsedPacket;
use crate::api::{Auth, AuthOption, Data, Nick};
use crate::conn::{Conn, ConnTx, State}; use crate::conn::{Conn, ConnTx, State};
const EUPH_DOMAIN: &str = "euphoria.io"; const EUPH_DOMAIN: &str = "euphoria.io";
@ -187,6 +188,27 @@ impl Instance {
}, },
}; };
match &event.packet.content {
Ok(Data::SnapshotEvent(_)) => {
if let Some(username) = &config.username {
let name = username.to_string();
let _ = conn.tx().send(Nick { name });
}
}
Ok(Data::BounceEvent(_)) => {
if let Some(password) = &config.password {
let cmd = Auth {
r#type: AuthOption::Passcode,
passcode: Some(password.to_string()),
};
let _ = conn.tx().send(cmd);
} else {
break;
}
}
_ => {}
}
if on_event(event).await.is_err() { if on_event(event).await.is_err() {
break; break;
} }