aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorTill Hoeppner2014-11-03 16:39:57 +0100
committerTill Hoeppner2014-11-03 16:39:57 +0100
commit55b915a75f49957eaddefa74cbbf572ad186ee2f (patch)
treee18b0bb361802261db96f719eae7f0c9d3f3dbf3 /src/event.rs
parentfc27f8cee888acf70683badca9edadb45544822c (diff)
downloadirsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.tar.gz
irsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.tar.xz
irsc-55b915a75f49957eaddefa74cbbf572ad186ee2f.zip
API improvements, but more copying
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
new file mode 100644
index 0000000..7e280a9
--- /dev/null
+++ b/src/event.rs
@@ -0,0 +1,33 @@
+use ident::Ident;
+
+#[deriving(Clone)]
+pub struct Event {
+ pub prefix: String,
+ pub command: String,
+ pub content: String
+}
+
+pub trait ParseResult {
+ fn parse(event: Event) -> Option<Self>;
+}
+
+pub const PRIVMSG: &'static str = "PRIVMSG";
+
+pub struct PrivMsg {
+ pub from: Ident,
+ pub to: String,
+ pub content: String
+}
+
+impl ParseResult for PrivMsg {
+ fn parse(event: Event) -> Option<PrivMsg> {
+ let from = Ident::parse(event.prefix[]);
+ match from {
+ Some(from) => Some(PrivMsg {
+ from: from,
+ content: event.content
+ }),
+ None => None
+ }
+ }
+}