diff --git a/ircbot/src/bin/factoids.rs b/ircbot/src/bin/factoids.rs index 1c8583a..6f7a321 100644 --- a/ircbot/src/bin/factoids.rs +++ b/ircbot/src/bin/factoids.rs @@ -10,13 +10,14 @@ extern crate env_logger; #[macro_use] extern crate log; +use ircbot::factoids::Factoids; use amqp::protocol::basic::Deliver; use amqp::protocol::basic::BasicProperties; use amqp::Basic; use amqp::Channel; use amqp::Session; use amqp::Table; - +use std::path::Path; use ircbot::config; @@ -38,7 +39,8 @@ fn main() { } let cfg = config::load(env::args().nth(1).unwrap().as_ref()); - let factoids = cfg.factoids().factoids; + let factoids_file = env::args().nth(2).unwrap(); + let factoids = Factoids::load(&Path::new(&factoids_file)).factoids; println!("{:?}", factoids.get("str1")); let mut session = Session::open_url(&cfg.rabbitmq.as_uri()).unwrap(); diff --git a/ircbot/src/config.rs b/ircbot/src/config.rs index 5b74566..921a502 100644 --- a/ircbot/src/config.rs +++ b/ircbot/src/config.rs @@ -3,7 +3,6 @@ use std::path::Path; use std::fs::File; use std::io::Read; -use ircbot::factoids::Factoids; use irc::client::prelude::Config as IrcConfig; #[derive(Serialize, Deserialize, Debug)] @@ -13,7 +12,6 @@ pub struct Config { password: String, channels: Vec, pub rabbitmq: RabbitMQConfig, - factoid_toml: String, } #[derive(Serialize, Deserialize, Debug)] @@ -37,10 +35,6 @@ impl RabbitMQConfig { } impl Config { - pub fn factoids(&self) -> Factoids { - Factoids::load(&Path::new(&self.factoid_toml)) - } - pub fn irc_config(&self) -> IrcConfig { IrcConfig { nickname: Some(self.nickname.clone()),