aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
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
+ }
+ }
+}