aboutsummaryrefslogtreecommitdiff
path: root/src/server.rs
diff options
context:
space:
mode:
authorTill Hoeppner2014-11-03 16:50:28 +0100
committerTill Hoeppner2014-11-03 16:50:28 +0100
commitfe1e048e42865a57b7bfd6e78cf44aefb1269a11 (patch)
tree14dea63644e3e2165f21bf776d2306abcabfee7f /src/server.rs
parent55b915a75f49957eaddefa74cbbf572ad186ee2f (diff)
downloadirsc-fe1e048e42865a57b7bfd6e78cf44aefb1269a11.tar.gz
irsc-fe1e048e42865a57b7bfd6e78cf44aefb1269a11.tar.xz
irsc-fe1e048e42865a57b7bfd6e78cf44aefb1269a11.zip
Proper PRIVMSG parsing
Diffstat (limited to 'src/server.rs')
-rw-r--r--src/server.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/server.rs b/src/server.rs
index 277c77e..99b8fb0 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -8,6 +8,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use callback::Callback;
+use event;
use event::Event;
#[deriving(Show, PartialEq, Eq, Clone)]
@@ -38,7 +39,7 @@ impl Server {
fn handle_event(arg: (Server, Event)) {
let (mut server, event) = arg;
match event.command[] {
- "PING" => {
+ event::PING => {
server.sendraw(format!("PONG {}", event.content).as_slice(), true).unwrap();
}
_ => ()
@@ -121,23 +122,11 @@ impl Server {
parts.remove(0).unwrap()
} else { "" };
-
- fn join(v: Vec<&str>, from: uint) -> String {
- let mut msg = if v[from].chars().next().unwrap() == ':' {
- v[from][1..].into_string()
- } else { v[from].into_string() };
- for m in v.iter().skip(from + 1) {
- msg.push_str(" ");
- msg.push_str(m.trim_right());
- }
- msg
- }
-
let cmd = parts.remove(0).unwrap();
let event = Event {
prefix: prefix.into_string(),
command: cmd.into_string(),
- content: join(parts, 0)
+ content: parts.iter().map(|p| p.into_string()).collect()
};
self.events.lock().fire(&(self.clone(), event));