Fixed circe not joining with the correct mode, updated examples

This commit is contained in:
famfo 2021-12-28 15:21:08 +01:00
parent e5022403e4
commit afb1891fb6
4 changed files with 14 additions and 7 deletions

View file

@ -3,7 +3,7 @@ use async_circe::{commands::Command, Client, Config};
#[tokio::main]
async fn main() -> Result<(), tokio::io::Error> {
let config = Config::new(
&["#no-normies"],
&["#main", "#no-normies"],
"karx.xyz",
Some("+B"),
Some("async-circe"),

View file

@ -1,5 +1,5 @@
host = "karx.xyz"
port = 6697
username = "async-circe"
channels = ["#no-normies"]
channels = ["#main", "#no-normies"]
mode = "+B"

View file

@ -9,7 +9,7 @@ async fn main() -> Result<(), tokio::io::Error> {
.init();
let config = Config::new(
&["#no-normies"],
&["#main", "#no-normies"],
"karx.xyz",
Some("+B"),
Some("async-circe"),

View file

@ -4,7 +4,7 @@
//! fn main() -> Result<(), tokio::io::Error> {
//! let config = Default::default();
//! let mut client = Client::new(config).await.unwrap();
//! client.identify()?.await.unwrap();
//! client.identify().await.unwrap();
//!
//! loop {
//! if let Ok(ref command) = client.read().await {
@ -162,7 +162,14 @@ impl Client {
}
let config = self.config.clone();
self.write_command(commands::Command::MODE(config.username, config.mode))
let user = {
if let Some(nick) = config.nickname {
nick
} else {
config.username
}
};
self.write_command(commands::Command::MODE(user, config.mode))
.await?;
for channel in &config.channels {
self.write_command(commands::Command::JOIN(channel.to_string()))
@ -602,10 +609,10 @@ impl Config {
/// # use circe::*;
/// let config = Config::new(
/// &["#main", "#circe"],
/// "192.168.178.100",
/// "karx.xyz",
/// Some("+B"),
/// Some("circe"),
/// 6667,
/// 6697,
/// "circe",
/// );
/// ```