Added a bot constructor that takes an already-made configuration file.
This commit is contained in:
parent
16d8fc15ea
commit
aa6ff176f2
1 changed files with 10 additions and 0 deletions
10
src/bot.rs
10
src/bot.rs
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue