aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorTill Höppner2015-04-18 15:29:14 +0200
committerTill Höppner2015-04-18 15:29:14 +0200
commit057d3e0bdb4bb46749267b45223281fd9afc956d (patch)
treef6994ad12dd7d765d58958599705fb3d9d2c4d16 /src/event.rs
parent326b5d9d96a5f45fa8b371f2a78394bcd87030e0 (diff)
parent4eea7cdff640f31f6595ec880d5405665fbd5c55 (diff)
downloadirsc-057d3e0bdb4bb46749267b45223281fd9afc956d.tar.gz
irsc-057d3e0bdb4bb46749267b45223281fd9afc956d.tar.xz
irsc-057d3e0bdb4bb46749267b45223281fd9afc956d.zip
Merge pull request #3 from tilpner/refactor
Refactor
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/event.rs b/src/event.rs
deleted file mode 100644
index b8e9743..0000000
--- a/src/event.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use ident::Ident;
-
-use std::borrow::ToOwned;
-
-#[deriving(Clone)]
-pub struct Event {
- pub prefix: String,
- pub command: String,
- pub content: Vec<String>
-}
-
-pub trait ParseResult {
- fn parse(event: Event) -> Option<Self>;
-}
-
-pub const PING: &'static str = "PING";
-
-pub const PRIVMSG: &'static str = "PRIVMSG";
-
-fn join(v: Vec<String>, from: uint) -> String {
- let mut msg = if v[from].chars().next().unwrap() == ':' {
- v[from][][1..].to_owned()
- } else { v[from].clone() };
- for m in v.iter().skip(from + 1) {
- msg.push_str(" ");
- msg.push_str(m.trim_right());
- }
- msg
-}
-
-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[]);
- let to = event.content[0].clone();
- match from {
- Some(from) => Some(PrivMsg {
- from: from,
- to: to,
- content: join(event.content, 1)
- }),
- None => None
- }
- }
-}