diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/format/weechat3.rs | 20 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 6 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/format/weechat3.rs b/src/format/weechat3.rs index 40445a1..dfe2868 100644 --- a/src/format/weechat3.rs +++ b/src/format/weechat3.rs @@ -58,14 +58,23 @@ impl<R> Iterator for Iter<R> where R: BufRead { nick: nick.to_owned(), channel: channel.to_owned(), mask: mask(host), time: timestamp(date, time) })), - [date, time, "<--", nick, host, "has", "left", channel, reason, _..] => return Some(Ok(Event::Part { + [date, time, "<--", nick, host, "has", "left", channel, reason..] => return Some(Ok(Event::Part { nick: nick.to_owned(), channel: channel.to_owned(), mask: mask(host), - reason: reason.to_owned(), time: timestamp(date, time) + reason: mask(&join(reason)), time: timestamp(date, time) + })), + [date, time, "--", notice, content..] + if notice.starts_with("Notice(") + => return Some(Ok(Event::Notice { + nick: notice["Notice(".len()..notice.len() - 2].to_owned(), + content: join(content), + time: timestamp(date, time) })), [date, time, "--", "irc:", "disconnected", "from", "server", _..] => return Some(Ok(Event::Disconnect { time: timestamp(date, time) })), - [date, time, "*", nick, msg..] => return Some(Ok(Event::Action { + [date, time, sp, "*", nick, msg..] + if sp.is_empty() + => return Some(Ok(Event::Action { from: nick.to_owned(), content: join(msg), time: timestamp(date, time) })), @@ -159,7 +168,7 @@ impl<W> Encode<W> for Weechat3 where W: Write { try!(writeln!(&mut output, "{}\t{}\t{}", date(*time), from, content)) }, &Event::Action { ref from, ref content, ref time } => { - try!(writeln!(&mut output, "{}\t*\t{} {}", date(*time), from, content)) + try!(writeln!(&mut output, "{}\t *\t{} {}", date(*time), from, content)) }, &Event::Join { ref nick, ref mask, ref channel, ref time } => { try!(writeln!(&mut output, "{}\t-->\t{} ({}) has joined {}", @@ -183,6 +192,9 @@ impl<W> Encode<W> for Weechat3 where W: Write { &Event::Disconnect { ref time } => { try!(writeln!(&mut output, "{}\t--\tirc: disconnected from server", date(*time))) }, + &Event::Notice { ref nick, ref content, ref time } => { + try!(writeln!(&mut output, "{}\t--\tNotice({}): {}", date(*time), nick, content)) + }, _ => () } Ok(()) @@ -1,4 +1,4 @@ -#![feature(plugin, slice_patterns, convert, core)] +#![feature(plugin, str_char, slice_patterns, convert, core)] #![plugin(regex_macros)] extern crate regex; extern crate chrono; diff --git a/src/main.rs b/src/main.rs index be86652..53c3527 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,8 @@ extern crate docopt; extern crate rustc_serialize; extern crate libc; extern crate regex; +#[macro_use] +extern crate log; extern crate env_logger; use std::fs::File; @@ -59,8 +61,8 @@ fn main() { for file in args.arg_file { let f: BufReader<File> = BufReader::new(File::open(file).unwrap()); let iter = parser.decode(f); - let events: Vec<_> = iter.collect(); - for e in events { + for e in iter { + info!("Parsed: {:?}", e); drop(parser.encode(io::stdout(), &e.unwrap())); } } |