More clean-up around ToMessage, and removed debug messages from CTCP
implementation.
This commit is contained in:
parent
a6146bc135
commit
dbd0e4b65b
2 changed files with 5 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
pub use data::command::Command;
|
pub use data::command::Command;
|
||||||
pub use data::config::Config;
|
pub use data::config::Config;
|
||||||
pub use data::message::Message;
|
pub use data::message::{Message, ToMessage};
|
||||||
pub use data::response::Response;
|
pub use data::response::Response;
|
||||||
pub use data::user::{AccessLevel, User};
|
pub use data::user::{AccessLevel, User};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ use conn::{Connection, NetStream};
|
||||||
use data::{Command, Config, Message, Response, User};
|
use data::{Command, Config, Message, Response, User};
|
||||||
use data::Command::{JOIN, NICK, NICKSERV, PONG};
|
use data::Command::{JOIN, NICK, NICKSERV, PONG};
|
||||||
use data::kinds::{IrcReader, IrcWriter};
|
use data::kinds::{IrcReader, IrcWriter};
|
||||||
use data::message::ToMessage;
|
|
||||||
#[cfg(feature = "ctcp")] use time::now;
|
#[cfg(feature = "ctcp")] use time::now;
|
||||||
|
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
@ -76,13 +75,13 @@ impl<'a, T: IrcReader, U: IrcWriter> Server<'a, T, U> for IrcServer<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "encode")]
|
#[cfg(feature = "encode")]
|
||||||
fn send(&self, command: Command) -> IoResult<()> {
|
fn send(&self, cmd: Command) -> IoResult<()> {
|
||||||
self.conn.send(command.to_message(), self.config.encoding())
|
self.conn.send(cmd, self.config.encoding())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "encode"))]
|
#[cfg(not(feature = "encode"))]
|
||||||
fn send(&self, command: Command) -> IoResult<()> {
|
fn send(&self, cmd: Command) -> IoResult<()> {
|
||||||
self.conn.send(command.to_message())
|
self.conn.send(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iter(&'a self) -> ServerIterator<'a, T, U> {
|
fn iter(&'a self) -> ServerIterator<'a, T, U> {
|
||||||
|
@ -187,7 +186,6 @@ impl<T: IrcReader, U: IrcWriter> IrcServer<T, U> {
|
||||||
None => "",
|
None => "",
|
||||||
};
|
};
|
||||||
if let ("PRIVMSG", [ref target]) = (msg.command[], msg.args[]) {
|
if let ("PRIVMSG", [ref target]) = (msg.command[], msg.args[]) {
|
||||||
println!("it's a privmsg");
|
|
||||||
let resp = if target.starts_with("#") { target[] } else { source };
|
let resp = if target.starts_with("#") { target[] } else { source };
|
||||||
match msg.suffix {
|
match msg.suffix {
|
||||||
Some(ref msg) if msg.starts_with("\u{001}") => {
|
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()
|
msg[1..end].split_str(" ").collect()
|
||||||
};
|
};
|
||||||
println!("we made it this far.");
|
|
||||||
match tokens[0] {
|
match tokens[0] {
|
||||||
"FINGER" => self.send_ctcp(resp, format!("FINGER :{} ({})",
|
"FINGER" => self.send_ctcp(resp, format!("FINGER :{} ({})",
|
||||||
self.config.real_name(),
|
self.config.real_name(),
|
||||||
self.config.username())[]),
|
self.config.username())[]),
|
||||||
"VERSION" => self.send_ctcp(resp, "VERSION irc:git:Rust"),
|
"VERSION" => self.send_ctcp(resp, "VERSION irc:git:Rust"),
|
||||||
"SOURCE" => {
|
"SOURCE" => {
|
||||||
println!("sending shit!");
|
|
||||||
self.send_ctcp(resp, "SOURCE https://github.com/aatxe/irc");
|
self.send_ctcp(resp, "SOURCE https://github.com/aatxe/irc");
|
||||||
self.send_ctcp(resp, "SOURCE");
|
self.send_ctcp(resp, "SOURCE");
|
||||||
println!("sent");
|
|
||||||
},
|
},
|
||||||
"PING" => self.send_ctcp(resp, format!("PING {}", tokens[1])[]),
|
"PING" => self.send_ctcp(resp, format!("PING {}", tokens[1])[]),
|
||||||
"TIME" => self.send_ctcp(resp, format!("TIME :{}", now().rfc822z())[]),
|
"TIME" => self.send_ctcp(resp, format!("TIME :{}", now().rfc822z())[]),
|
||||||
|
|
Loading…
Reference in a new issue