aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2017-12-24 15:27:14 +0100
committerJokler <jokler.contact@gmail.com>2017-12-24 15:27:14 +0100
commit32e870aeefee587d6eabdfa08cf27b3cf9a46f15 (patch)
tree4313a3abec20b2038be6f1f416fc6d3352fb3c8d /src/lib.rs
parent92ea5a1c2e0b7ddaa102d6b602d180e84964c3be (diff)
downloadfrippy-32e870aeefee587d6eabdfa08cf27b3cf9a46f15.tar.gz
frippy-32e870aeefee587d6eabdfa08cf27b3cf9a46f15.zip
Exit if no bot connected successfully
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 5d15802..5592da7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -132,7 +132,7 @@ impl Bot {
/// reactor.run(future::empty::<(), ()>()).unwrap();
/// # }
/// ```
- pub fn connect(&self, reactor: &mut Core, config: &Config) {
+ pub fn connect(&self, reactor: &mut Core, config: &Config) -> Option<()> {
info!("Plugins loaded: {}", self.plugins);
let server =
@@ -140,7 +140,7 @@ impl Bot {
Ok(v) => v,
Err(e) => {
error!("Failed to connect: {}", e);
- return;
+ return None;
}
};
@@ -148,7 +148,10 @@ impl Bot {
match server.identify() {
Ok(_) => info!("Identified"),
- Err(e) => error!("Failed to identify: {}", e),
+ Err(e) => {
+ error!("Failed to identify: {}", e);
+ return None;
+ }
};
// TODO Verify if we actually need to clone plugins twice
@@ -160,6 +163,7 @@ impl Bot {
.map_err(|e| error!("Failed to process message: {}", e));
reactor.handle().spawn(task);
+ Some(())
}
}