aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
blob: 7e280a9dd03379e50e484967c0df9942c7410240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
        }
    }
}