Added a bot constructor that takes an already-made configuration file.

This commit is contained in:
Aaron Weiss 2014-11-02 13:01:02 -05:00
parent 16d8fc15ea
commit aa6ff176f2

View file

@ -23,6 +23,16 @@ impl<'a> IrcBot<'a, BufferedWriter<TcpStream>, BufferedReader<TcpStream>> {
chanlists: RefCell::new(HashMap::new()),
})
}
pub fn new_with_config(config: Config, process: |&IrcBot<BufferedWriter<TcpStream>, BufferedReader<TcpStream>>, &str, &str, &[&str]|:'a -> IoResult<()>) -> IoResult<IrcBot<'a, BufferedWriter<TcpStream>, BufferedReader<TcpStream>>> {
let conn = try!(Connection::connect(config.server[], config.port));
Ok(IrcBot {
conn: conn,
config: config,
process: RefCell::new(process),
chanlists: RefCell::new(HashMap::new()),
})
}
}
impl<'a, T, U> Bot for IrcBot<'a, T, U> where T: IrcWriter, U: IrcReader {