Pass factoids as a separate arg

This commit is contained in:
Graham Christensen 2017-12-16 08:18:16 -05:00
parent b7bddc0635
commit 03312b8176
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 4 additions and 8 deletions

View file

@ -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();

View file

@ -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<String>,
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()),