Added method to get config from bots.

This commit is contained in:
Aaron Weiss 2014-10-08 13:40:19 -04:00
parent 54e781e6e7
commit bf31646bdd
2 changed files with 6 additions and 1 deletions

View file

@ -23,7 +23,7 @@ impl<'a> Message<'a> {
} }
} }
#[deriving(Decodable)] #[deriving(Clone, Decodable)]
pub struct Config { pub struct Config {
pub owners: Vec<String>, pub owners: Vec<String>,
pub nickname: String, pub nickname: String,

View file

@ -23,6 +23,7 @@ pub trait Bot<'a> {
fn send_privmsg(&self, chan: &str, msg: &str) -> IoResult<()>; fn send_privmsg(&self, chan: &str, msg: &str) -> IoResult<()>;
fn identify(&self) -> IoResult<()>; fn identify(&self) -> IoResult<()>;
fn output(&mut self) -> IoResult<()>; fn output(&mut self) -> IoResult<()>;
fn config(&self) -> Config;
} }
pub struct IrcBot<'a, T, U> where T: IrcWriter, U: IrcReader { pub struct IrcBot<'a, T, U> where T: IrcWriter, U: IrcReader {
@ -161,6 +162,10 @@ impl<'a, T, U> Bot<'a> for IrcBot<'a, T, U> where T: IrcWriter, U: IrcReader {
} }
Ok(()) Ok(())
} }
fn config(&self) -> Config {
self.config.clone()
}
} }
fn process(msg: &str) -> IoResult<(&str, &str, Vec<&str>)> { fn process(msg: &str) -> IoResult<(&str, &str, Vec<&str>)> {