From da1033bd5f2600afa674e4f536aef48b1a802634 Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Sun, 19 Apr 2015 20:23:55 +0200 Subject: Apparently not. Let's try again. --- .travis.yml | 6 +++--- src/message.rs | 18 +++++++++++------- src/server.rs | 12 ++++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21839e2..2be0c4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust after_success: - -| + - | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && cargo doc && @@ -8,10 +8,10 @@ after_success: sudo pip install ghp-import && ghp-import -n target/doc && git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages - -| + - | [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ] && - cargo publish --publish ${CRATESIO-TOKEN} + cargo publish --token ${CRATESIO-TOKEN} env: global: diff --git a/src/message.rs b/src/message.rs index e192a9d..f2cd9d3 100644 --- a/src/message.rs +++ b/src/message.rs @@ -70,7 +70,8 @@ impl<'a> FromStr for Message<'a> { s = &s[i..]; } }); - if s.chars().next() == Some(' ') { s = &s[1..] }; + // if s.chars().next() == Some(' ') { s = &s[1..] }; + s = &s[1..] } let msg_type = if suffix.as_ref() @@ -259,17 +260,16 @@ pub enum Command<'a> { Ctcp { command: Cow<'a, String> }, - /* /// "Welcome to the Internet Relay Network !@" - RPL_WELCOME = 001, + RPL_WELCOME, /// "Your host is , running version " - RPL_YOURHOST = 002, + RPL_YOURHOST, /// "This server was created " - RPL_CREATED = 003, + RPL_CREATED, /// " " - RPL_MYINFO = 004, - /// "Try server , port " + RPL_MYINFO, + /*/// "Try server , port " /// Sent by the server to a user to suggest an alternative /// server. This is often used when the connection is /// refused because the server is already full. @@ -1123,6 +1123,10 @@ impl<'a> Command<'a> { Command::Notice { to: Cow::Borrowed(&t), content: Cow::Borrowed(&c) })), "PING" => msg.content.get(0).and_then(|s1| msg.content.get(1).map(|s2| Command::Ping { server1: Some(Cow::Borrowed(&s1)), server2: Some(Cow::Borrowed(&s2)) })), + "001" => Some(Command::RPL_WELCOME), + "002" => Some(Command::RPL_YOURHOST), + "003" => Some(Command::RPL_CREATED), + "004" => Some(Command::RPL_MYINFO), "451" => Some(Command::ErrNotRegistered), _ => unimplemented!() } diff --git a/src/server.rs b/src/server.rs index 62ee071..a8c2819 100644 --- a/src/server.rs +++ b/src/server.rs @@ -114,27 +114,27 @@ impl Server { } pub fn join(&mut self, channel: &str) -> Result<()> { - self.sendraw(format!("JOIN {}", channel).as_ref()) + self.sendraw(format!("JOIN {}\r\n", channel).as_ref()) } pub fn part(&mut self, channel: &str) -> Result<()> { - self.sendraw(format!("PART {}", channel).as_ref()) + self.sendraw(format!("PART {}\r\n", channel).as_ref()) } pub fn nick(&mut self, nick: &str) -> Result<()> { - self.sendraw(format!("NICK {}", nick).as_ref()) + self.sendraw(format!("NICK {}\r\n", nick).as_ref()) } pub fn user(&mut self, username: &str, hostname: &str, servername: &str, realname: &str) -> Result<()> { - self.sendraw(format!("USER {} {} {} :{}", username, hostname, servername, realname).as_ref()) + self.sendraw(format!("USER {} {} {} :{}\r\n", username, hostname, servername, realname).as_ref()) } pub fn password(&mut self, password: &str) -> Result<()> { - self.sendraw(format!("PASS {}", password).as_ref()) + self.sendraw(format!("PASS {}\r\n", password).as_ref()) } pub fn msg(&mut self, target: &str, message: &str) -> Result<()> { - self.sendraw(format!("PRIVMSG {} :{}", target, message).as_ref()) + self.sendraw(format!("PRIVMSG {} :{}\r\n", target, message).as_ref()) } pub fn listen(&mut self, events: &[fn(&mut Server, &Message)]) -> Result<()> { -- cgit v1.2.3