diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index 99e3323..dd90f0e 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -136,7 +136,7 @@ async fn on_packet(packet: ParsedPacket, snapshot: Snapshot) -> Result<(), ()> { // If you are not interested in the result, you can just // throw away the future returned by the send function. println!("Sending reply..."); - let _ = snapshot.conn_tx.send(Send { + snapshot.conn_tx.send_only(Send { content: reply, parent: Some(event.0.id), }); diff --git a/examples/testbot_instances.rs b/examples/testbot_instances.rs index 1c0e5bf..4632597 100644 --- a/examples/testbot_instances.rs +++ b/examples/testbot_instances.rs @@ -137,7 +137,7 @@ async fn on_packet(packet: ParsedPacket, snapshot: Snapshot) -> Result<(), ()> { // If you are not interested in the result, you can just // throw away the future returned by the send function. println!("Sending reply..."); - let _ = snapshot.conn_tx.send(Send { + snapshot.conn_tx.send_only(Send { content: reply, parent: Some(event.0.id), }); diff --git a/examples/testbot_manual.rs b/examples/testbot_manual.rs index 10ac7a4..8a7afe0 100644 --- a/examples/testbot_manual.rs +++ b/examples/testbot_manual.rs @@ -140,7 +140,7 @@ async fn on_packet(packet: ParsedPacket, conn_tx: &ConnTx, state: &State) -> Res // If you are not interested in the result, you can just // throw away the future returned by the send function. println!("Sending reply..."); - let _ = conn_tx.send(Send { + conn_tx.send_only(Send { content: reply, parent: Some(event.0.id), }); diff --git a/src/bot/instance.rs b/src/bot/instance.rs index c38c4d5..8abfe91 100644 --- a/src/bot/instance.rs +++ b/src/bot/instance.rs @@ -421,7 +421,7 @@ impl Instance { if config.force_username || snapshot.nick.is_none() { debug!("{}: Setting nick to username {}", config.name, username); let name = username.to_string(); - let _ = conn.tx().send(Nick { name }); + conn.tx().send_only(Nick { name }); } else if let Some(nick) = &snapshot.nick { debug!("{}: Not setting nick, already set to {}", config.name, nick); } @@ -434,7 +434,7 @@ impl Instance { r#type: AuthOption::Passcode, passcode: Some(password.to_string()), }; - let _ = conn.tx().send(cmd); + conn.tx().send_only(cmd); } else { warn!("{}: Auth required but no password configured", config.name); break; diff --git a/src/conn.rs b/src/conn.rs index 07f636e..dcfc948 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -330,6 +330,12 @@ impl ConnTx { Self::finish_send::(rx) } + /// Like [`Self::send`] but ignoring the server's reply. + pub fn send_only>(&self, cmd: C) { + let (tx, _) = oneshot::channel(); + let _ = self.cmd_tx.send(ConnCommand::SendCmd(cmd.into(), tx)); + } + pub async fn state(&self) -> Result { let (tx, rx) = oneshot::channel(); self.cmd_tx