diff --git a/examples/testbot_instance.rs b/examples/testbot_instance.rs index ebc58a5..5a0190a 100644 --- a/examples/testbot_instance.rs +++ b/examples/testbot_instance.rs @@ -153,6 +153,10 @@ async fn on_event(event: Event) -> Result<(), ()> { #[tokio::main] async fn main() { - let _instance = Config::new("test").username("TestBot").build(on_event); + let _instance = Config::new("test") + .username(Some("TestBot")) + .build(on_event); + + // Once the instance is dropped, it stops, so we wait indefinitely here. tokio::time::sleep(Duration::from_secs(u64::MAX)).await; } diff --git a/src/bot/instance.rs b/src/bot/instance.rs index 1fa3374..1d15d66 100644 --- a/src/bot/instance.rs +++ b/src/bot/instance.rs @@ -63,23 +63,23 @@ impl Config { self } - pub fn human(mut self) -> Self { - self.human = true; + pub fn human(mut self, human: bool) -> Self { + self.human = human; self } - pub fn bot(mut self) -> Self { - self.human = false; + pub fn cookies(mut self, cookies: Arc>) -> Self { + self.cookies = cookies; self } - pub fn username(mut self, username: S) -> Self { - self.username = Some(username.to_string()); + pub fn username(mut self, username: Option) -> Self { + self.username = username.map(|s| s.to_string()); self } - pub fn password(mut self, password: S) -> Self { - self.password = Some(password.to_string()); + pub fn password(mut self, password: Option) -> Self { + self.password = password.map(|s| s.to_string()); self }