More clean-up around ToMessage, and removed debug messages from CTCP

implementation.
This commit is contained in:
Aaron Weiss 2014-12-31 20:26:44 -05:00
parent a6146bc135
commit dbd0e4b65b
2 changed files with 5 additions and 10 deletions

View file

@ -3,7 +3,7 @@
pub use data::command::Command;
pub use data::config::Config;
pub use data::message::Message;
pub use data::message::{Message, ToMessage};
pub use data::response::Response;
pub use data::user::{AccessLevel, User};

View file

@ -8,7 +8,6 @@ use conn::{Connection, NetStream};
use data::{Command, Config, Message, Response, User};
use data::Command::{JOIN, NICK, NICKSERV, PONG};
use data::kinds::{IrcReader, IrcWriter};
use data::message::ToMessage;
#[cfg(feature = "ctcp")] use time::now;
pub mod utils;
@ -76,13 +75,13 @@ impl<'a, T: IrcReader, U: IrcWriter> Server<'a, T, U> for IrcServer<T, U> {
}
#[cfg(feature = "encode")]
fn send(&self, command: Command) -> IoResult<()> {
self.conn.send(command.to_message(), self.config.encoding())
fn send(&self, cmd: Command) -> IoResult<()> {
self.conn.send(cmd, self.config.encoding())
}
#[cfg(not(feature = "encode"))]
fn send(&self, command: Command) -> IoResult<()> {
self.conn.send(command.to_message())
fn send(&self, cmd: Command) -> IoResult<()> {
self.conn.send(cmd)
}
fn iter(&'a self) -> ServerIterator<'a, T, U> {
@ -187,7 +186,6 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
None => "",
};
if let ("PRIVMSG", [ref target]) = (msg.command[], msg.args[]) {
println!("it's a privmsg");
let resp = if target.starts_with("#") { target[] } else { source };
match msg.suffix {
Some(ref msg) if msg.starts_with("\u{001}") => {
@ -199,17 +197,14 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
};
msg[1..end].split_str(" ").collect()
};
println!("we made it this far.");
match tokens[0] {
"FINGER" => self.send_ctcp(resp, format!("FINGER :{} ({})",
self.config.real_name(),
self.config.username())[]),
"VERSION" => self.send_ctcp(resp, "VERSION irc:git:Rust"),
"SOURCE" => {
println!("sending shit!");
self.send_ctcp(resp, "SOURCE https://github.com/aatxe/irc");
self.send_ctcp(resp, "SOURCE");
println!("sent");
},
"PING" => self.send_ctcp(resp, format!("PING {}", tokens[1])[]),
"TIME" => self.send_ctcp(resp, format!("TIME :{}", now().rfc822z())[]),