Added additional utilities.

This commit is contained in:
Aaron Weiss 2014-11-03 03:47:08 -05:00
parent 25c50b182b
commit f0e3db4ce6
2 changed files with 22 additions and 1 deletions

View file

@ -70,6 +70,7 @@ impl<'a, T, U> IrcServer<'a, T, U> where T: IrcWriter, U: IrcReader {
})
}
/// Handles messages internally for basic bot functionality
fn handle_message(&self, message: &Message) {
if message.command[] == "PING" {
utils::send_pong(self, message.suffix.as_ref().unwrap()[]).unwrap();

View file

@ -2,7 +2,7 @@
#![experimental]
use std::io::IoResult;
use data::command::{JOIN, NICK, PONG, USER};
use data::command::{JOIN, KILL, NICK, OPER, PONG, PRIVMSG, SAMODE, SANICK, USER};
use data::kinds::{IrcReader, IrcWriter};
use server::Server;
@ -19,3 +19,23 @@ pub fn send_pong<'a, T, U>(server: &Server<'a, T, U>, msg: &str) -> IoResult<()>
pub fn send_join<'a, T, U>(server: &Server<'a, T, U>, chanlist: &str) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(JOIN(chanlist, None))
}
pub fn send_oper<'a, T, U>(server: &Server<'a, T, U>, username: &str, password: &str) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(OPER(username, password))
}
pub fn send_privmsg<'a, T, U>(server: &Server<'a, T, U>, target: &str, message: &str) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(PRIVMSG(target, message))
}
pub fn send_kill<'a, T, U>(server: &Server<'a, T, U>, target: &str, message: &str) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(KILL(target, message))
}
pub fn send_samode<'a, T, U>(server: &Server<'a, T, U>, target: &'a str, mode: &'a str, modeparams: Option<&'a str>) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(SAMODE(target, mode, modeparams))
}
pub fn send_sanick<'a, T, U>(server: &Server<'a, T, U>, old_nick: &str, new_nick: &str) -> IoResult<()> where T: IrcWriter, U: IrcReader {
server.send(SANICK(old_nick, new_nick))
}