aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTill Hoeppner2015-04-19 20:23:55 +0200
committerTill Hoeppner2015-04-19 20:48:01 +0200
commitda1033bd5f2600afa674e4f536aef48b1a802634 (patch)
treeac920735e2a4f9be13ea3200523e5c010b7c7176 /src
parent358eb0769750059561ae58797f049918c703fe79 (diff)
downloadirsc-da1033bd5f2600afa674e4f536aef48b1a802634.tar.gz
irsc-da1033bd5f2600afa674e4f536aef48b1a802634.tar.xz
irsc-da1033bd5f2600afa674e4f536aef48b1a802634.zip
Apparently not. Let's try again.
Diffstat (limited to 'src')
-rw-r--r--src/message.rs18
-rw-r--r--src/server.rs12
2 files changed, 17 insertions, 13 deletions
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 <nick>!<user>@<host>"
- RPL_WELCOME = 001,
+ RPL_WELCOME,
/// "Your host is <servername>, running version <ver>"
- RPL_YOURHOST = 002,
+ RPL_YOURHOST,
/// "This server was created <date>"
- RPL_CREATED = 003,
+ RPL_CREATED,
/// "<servername> <version> <available user modes> <available channel modes>"
- RPL_MYINFO = 004,
- /// "Try server <server name>, port <port number>"
+ RPL_MYINFO,
+ /*/// "Try server <server name>, port <port number>"
/// 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<()> {