aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Hoeppner2015-04-03 00:18:35 +0200
committerTill Hoeppner2015-04-03 00:18:35 +0200
commit9826d256eec94144469e27c159e0ec4642b2fda6 (patch)
tree16d751b4dfea1c336747a3a2a63936e8881f0b3e
parent522ba8bdc2d63c6503324baf3eacdaa0630f4673 (diff)
downloadilc-9826d256eec94144469e27c159e0ec4642b2fda6.tar.gz
ilc-9826d256eec94144469e27c159e0ec4642b2fda6.tar.xz
ilc-9826d256eec94144469e27c159e0ec4642b2fda6.zip
More event types
-rw-r--r--README.md4
-rw-r--r--src/format/weechat3.rs20
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs6
4 files changed, 25 insertions, 7 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4114187
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+ilc 0.0.1
+=========
+
+
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(())
diff --git a/src/lib.rs b/src/lib.rs
index 1cceb27..ac89c95 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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()));
}
}