Removed stability attributes.
This commit is contained in:
parent
1740a2e669
commit
2505cc5784
12 changed files with 3 additions and 349 deletions
|
@ -1,5 +1,4 @@
|
||||||
//! Thread-safe connections on IrcStreams.
|
//! Thread-safe connections on IrcStreams.
|
||||||
#![stable]
|
|
||||||
#[cfg(feature = "ssl")] use std::error::Error as StdError;
|
#[cfg(feature = "ssl")] use std::error::Error as StdError;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::{BufReader, BufWriter, Result};
|
use std::io::{BufReader, BufWriter, Result};
|
||||||
|
@ -16,22 +15,18 @@ use client::data::message::ToMessage;
|
||||||
#[cfg(feature = "ssl")] use openssl::ssl::error::SslError;
|
#[cfg(feature = "ssl")] use openssl::ssl::error::SslError;
|
||||||
|
|
||||||
/// A thread-safe connection.
|
/// A thread-safe connection.
|
||||||
#[stable]
|
|
||||||
pub struct Connection<T: IrcRead, U: IrcWrite> {
|
pub struct Connection<T: IrcRead, U: IrcWrite> {
|
||||||
reader: Mutex<T>,
|
reader: Mutex<T>,
|
||||||
writer: Mutex<U>,
|
writer: Mutex<U>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Connection over a buffered NetStream.
|
/// A Connection over a buffered NetStream.
|
||||||
#[stable]
|
|
||||||
pub type NetConnection = Connection<BufReader<NetStream>, BufWriter<NetStream>>;
|
pub type NetConnection = Connection<BufReader<NetStream>, BufWriter<NetStream>>;
|
||||||
/// An internal type
|
/// An internal type
|
||||||
type NetReadWritePair = (BufReader<NetStream>, BufWriter<NetStream>);
|
type NetReadWritePair = (BufReader<NetStream>, BufWriter<NetStream>);
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl Connection<BufReader<NetStream>, BufWriter<NetStream>> {
|
impl Connection<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
/// Creates a thread-safe TCP connection to the specified server.
|
/// Creates a thread-safe TCP connection to the specified server.
|
||||||
#[stable]
|
|
||||||
pub fn connect(host: &str, port: u16) -> Result<NetConnection> {
|
pub fn connect(host: &str, port: u16) -> Result<NetConnection> {
|
||||||
let (reader, writer) = try!(Connection::connect_internal(host, port));
|
let (reader, writer) = try!(Connection::connect_internal(host, port));
|
||||||
Ok(Connection::new(reader, writer))
|
Ok(Connection::new(reader, writer))
|
||||||
|
@ -46,7 +41,6 @@ impl Connection<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
|
|
||||||
/// Creates a thread-safe TCP connection to the specified server over SSL.
|
/// Creates a thread-safe TCP connection to the specified server over SSL.
|
||||||
/// If the library is compiled without SSL support, this method panics.
|
/// If the library is compiled without SSL support, this method panics.
|
||||||
#[stable]
|
|
||||||
pub fn connect_ssl(host: &str, port: u16) -> Result<NetConnection> {
|
pub fn connect_ssl(host: &str, port: u16) -> Result<NetConnection> {
|
||||||
let (reader, writer) = try!(Connection::connect_ssl_internal(host, port));
|
let (reader, writer) = try!(Connection::connect_ssl_internal(host, port));
|
||||||
Ok(Connection::new(reader, writer))
|
Ok(Connection::new(reader, writer))
|
||||||
|
@ -69,7 +63,6 @@ impl Connection<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reconnects to the specified server, dropping the current connection.
|
/// Reconnects to the specified server, dropping the current connection.
|
||||||
#[stable]
|
|
||||||
pub fn reconnect(&self, host: &str, port: u16) -> Result<()> {
|
pub fn reconnect(&self, host: &str, port: u16) -> Result<()> {
|
||||||
let use_ssl = match self.reader.lock().unwrap().get_ref() {
|
let use_ssl = match self.reader.lock().unwrap().get_ref() {
|
||||||
&NetStream::UnsecuredTcpStream(_) => false,
|
&NetStream::UnsecuredTcpStream(_) => false,
|
||||||
|
@ -106,10 +99,8 @@ impl Connection<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
/// Creates a new connection from an IrcReader and an IrcWriter.
|
/// Creates a new connection from an IrcReader and an IrcWriter.
|
||||||
#[stable]
|
|
||||||
pub fn new(reader: T, writer: U) -> Connection<T, U> {
|
pub fn new(reader: T, writer: U) -> Connection<T, U> {
|
||||||
Connection {
|
Connection {
|
||||||
reader: Mutex::new(reader),
|
reader: Mutex::new(reader),
|
||||||
|
@ -118,7 +109,6 @@ impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a Message over this connection.
|
/// Sends a Message over this connection.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "encode")]
|
#[cfg(feature = "encode")]
|
||||||
pub fn send<M: ToMessage>(&self, to_msg: M, encoding: &str) -> Result<()> {
|
pub fn send<M: ToMessage>(&self, to_msg: M, encoding: &str) -> Result<()> {
|
||||||
let encoding = match encoding_from_whatwg_label(encoding) {
|
let encoding = match encoding_from_whatwg_label(encoding) {
|
||||||
|
@ -140,7 +130,6 @@ impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a message over this connection.
|
/// Sends a message over this connection.
|
||||||
#[stable]
|
|
||||||
#[cfg(not(feature = "encode"))]
|
#[cfg(not(feature = "encode"))]
|
||||||
pub fn send<M: ToMessage>(&self, to_msg: M) -> Result<()> {
|
pub fn send<M: ToMessage>(&self, to_msg: M) -> Result<()> {
|
||||||
let mut writer = self.writer.lock().unwrap();
|
let mut writer = self.writer.lock().unwrap();
|
||||||
|
@ -149,7 +138,6 @@ impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives a single line from this connection.
|
/// Receives a single line from this connection.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "encoding")]
|
#[cfg(feature = "encoding")]
|
||||||
pub fn recv(&self, encoding: &str) -> Result<String> {
|
pub fn recv(&self, encoding: &str) -> Result<String> {
|
||||||
let encoding = match encoding_from_whatwg_label(encoding) {
|
let encoding = match encoding_from_whatwg_label(encoding) {
|
||||||
|
@ -171,7 +159,6 @@ impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives a single line from this connection.
|
/// Receives a single line from this connection.
|
||||||
#[stable]
|
|
||||||
#[cfg(not(feature = "encoding"))]
|
#[cfg(not(feature = "encoding"))]
|
||||||
pub fn recv(&self) -> Result<String> {
|
pub fn recv(&self) -> Result<String> {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
|
@ -184,13 +171,11 @@ impl<T: IrcRead, U: IrcWrite> Connection<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Acquires the Reader lock.
|
/// Acquires the Reader lock.
|
||||||
#[stable]
|
|
||||||
pub fn reader<'a>(&'a self) -> MutexGuard<'a, T> {
|
pub fn reader<'a>(&'a self) -> MutexGuard<'a, T> {
|
||||||
self.reader.lock().unwrap()
|
self.reader.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Acquires the Writer lock.
|
/// Acquires the Writer lock.
|
||||||
#[stable]
|
|
||||||
pub fn writer<'a>(&'a self) -> MutexGuard<'a, U> {
|
pub fn writer<'a>(&'a self) -> MutexGuard<'a, U> {
|
||||||
self.writer.lock().unwrap()
|
self.writer.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
@ -208,15 +193,12 @@ fn ssl_to_io<T>(res: StdResult<T, SslError>) -> Result<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An abstraction over different networked streams.
|
/// An abstraction over different networked streams.
|
||||||
#[stable]
|
|
||||||
pub enum NetStream {
|
pub enum NetStream {
|
||||||
/// An unsecured TcpStream.
|
/// An unsecured TcpStream.
|
||||||
#[stable]
|
|
||||||
UnsecuredTcpStream(TcpStream),
|
UnsecuredTcpStream(TcpStream),
|
||||||
/// An SSL-secured TcpStream.
|
/// An SSL-secured TcpStream.
|
||||||
/// This is only available when compiled with SSL support.
|
/// This is only available when compiled with SSL support.
|
||||||
#[cfg(feature = "ssl")]
|
#[cfg(feature = "ssl")]
|
||||||
#[stable]
|
|
||||||
SslTcpStream(SslStream<TcpStream>),
|
SslTcpStream(SslStream<TcpStream>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! Enumeration of all available client commands.
|
//! Enumeration of all available client commands.
|
||||||
#![stable]
|
|
||||||
use std::io::{Error, ErrorKind, Result};
|
use std::io::{Error, ErrorKind, Result};
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -9,202 +8,144 @@ use client::data::message::{Message, ToMessage};
|
||||||
/// also includes commands from the
|
/// also includes commands from the
|
||||||
/// [capabilities extension](https://tools.ietf.org/html/draft-mitchell-irc-capabilities-01).
|
/// [capabilities extension](https://tools.ietf.org/html/draft-mitchell-irc-capabilities-01).
|
||||||
/// Additionally, this includes some common additional commands from popular IRCds.
|
/// Additionally, this includes some common additional commands from popular IRCds.
|
||||||
#[stable]
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Command {
|
pub enum Command {
|
||||||
// 3.1 Connection Registration
|
// 3.1 Connection Registration
|
||||||
/// PASS :password
|
/// PASS :password
|
||||||
#[stable]
|
|
||||||
PASS(String),
|
PASS(String),
|
||||||
/// NICK :nickname
|
/// NICK :nickname
|
||||||
#[stable]
|
|
||||||
NICK(String),
|
NICK(String),
|
||||||
/// USER user mode * :realname
|
/// USER user mode * :realname
|
||||||
#[stable]
|
|
||||||
USER(String, String, String),
|
USER(String, String, String),
|
||||||
/// OPER name :password
|
/// OPER name :password
|
||||||
#[stable]
|
|
||||||
OPER(String, String),
|
OPER(String, String),
|
||||||
/// MODE nickname modes
|
/// MODE nickname modes
|
||||||
/// MODE channel modes [modeparams]
|
/// MODE channel modes [modeparams]
|
||||||
#[stable]
|
|
||||||
MODE(String, String, Option<String>),
|
MODE(String, String, Option<String>),
|
||||||
/// SERVICE nickname reserved distribution type reserved :info
|
/// SERVICE nickname reserved distribution type reserved :info
|
||||||
#[stable]
|
|
||||||
SERVICE(String, String, String, String, String, String),
|
SERVICE(String, String, String, String, String, String),
|
||||||
/// QUIT :comment
|
/// QUIT :comment
|
||||||
#[stable]
|
|
||||||
QUIT(Option<String>),
|
QUIT(Option<String>),
|
||||||
/// SQUIT server :comment
|
/// SQUIT server :comment
|
||||||
#[stable]
|
|
||||||
SQUIT(String, String),
|
SQUIT(String, String),
|
||||||
|
|
||||||
// 3.2 Channel operations
|
// 3.2 Channel operations
|
||||||
/// JOIN chanlist [chankeys]
|
/// JOIN chanlist [chankeys]
|
||||||
#[stable]
|
|
||||||
JOIN(String, Option<String>),
|
JOIN(String, Option<String>),
|
||||||
/// PART chanlist :[comment]
|
/// PART chanlist :[comment]
|
||||||
#[stable]
|
|
||||||
PART(String, Option<String>),
|
PART(String, Option<String>),
|
||||||
// MODE is already defined.
|
// MODE is already defined.
|
||||||
// MODE(String, String, Option<String>),
|
// MODE(String, String, Option<String>),
|
||||||
/// TOPIC channel :[topic]
|
/// TOPIC channel :[topic]
|
||||||
#[stable]
|
|
||||||
TOPIC(String, Option<String>),
|
TOPIC(String, Option<String>),
|
||||||
/// NAMES [chanlist :[target]]
|
/// NAMES [chanlist :[target]]
|
||||||
#[stable]
|
|
||||||
NAMES(Option<String>, Option<String>),
|
NAMES(Option<String>, Option<String>),
|
||||||
/// LIST [chanlist :[target]]
|
/// LIST [chanlist :[target]]
|
||||||
#[stable]
|
|
||||||
LIST(Option<String>, Option<String>),
|
LIST(Option<String>, Option<String>),
|
||||||
/// INVITE nickname channel
|
/// INVITE nickname channel
|
||||||
#[stable]
|
|
||||||
INVITE(String, String),
|
INVITE(String, String),
|
||||||
/// KICK chanlist userlist :[comment]
|
/// KICK chanlist userlist :[comment]
|
||||||
#[stable]
|
|
||||||
KICK(String, String, Option<String>),
|
KICK(String, String, Option<String>),
|
||||||
|
|
||||||
// 3.3 Sending messages
|
// 3.3 Sending messages
|
||||||
/// PRIVMSG msgtarget :message
|
/// PRIVMSG msgtarget :message
|
||||||
#[stable]
|
|
||||||
PRIVMSG(String, String),
|
PRIVMSG(String, String),
|
||||||
/// NOTICE msgtarget :message
|
/// NOTICE msgtarget :message
|
||||||
#[stable]
|
|
||||||
NOTICE(String, String),
|
NOTICE(String, String),
|
||||||
|
|
||||||
// 3.4 Server queries and commands
|
// 3.4 Server queries and commands
|
||||||
/// MOTD :[target]
|
/// MOTD :[target]
|
||||||
#[stable]
|
|
||||||
MOTD(Option<String>),
|
MOTD(Option<String>),
|
||||||
/// LUSERS [mask :[target]]
|
/// LUSERS [mask :[target]]
|
||||||
#[stable]
|
|
||||||
LUSERS(Option<String>, Option<String>),
|
LUSERS(Option<String>, Option<String>),
|
||||||
/// VERSION :[target]
|
/// VERSION :[target]
|
||||||
#[stable]
|
|
||||||
VERSION(Option<String>),
|
VERSION(Option<String>),
|
||||||
/// STATS [query :[target]]
|
/// STATS [query :[target]]
|
||||||
#[stable]
|
|
||||||
STATS(Option<String>, Option<String>),
|
STATS(Option<String>, Option<String>),
|
||||||
/// LINKS [[remote server] server :mask]
|
/// LINKS [[remote server] server :mask]
|
||||||
#[stable]
|
|
||||||
LINKS(Option<String>, Option<String>),
|
LINKS(Option<String>, Option<String>),
|
||||||
/// TIME :[target]
|
/// TIME :[target]
|
||||||
#[stable]
|
|
||||||
TIME(Option<String>),
|
TIME(Option<String>),
|
||||||
/// CONNECT target server port :[remote server]
|
/// CONNECT target server port :[remote server]
|
||||||
#[stable]
|
|
||||||
CONNECT(String, String, Option<String>),
|
CONNECT(String, String, Option<String>),
|
||||||
/// TRACE :[target]
|
/// TRACE :[target]
|
||||||
#[stable]
|
|
||||||
TRACE(Option<String>),
|
TRACE(Option<String>),
|
||||||
/// ADMIN :[target]
|
/// ADMIN :[target]
|
||||||
#[stable]
|
|
||||||
ADMIN(Option<String>),
|
ADMIN(Option<String>),
|
||||||
/// INFO :[target]
|
/// INFO :[target]
|
||||||
#[stable]
|
|
||||||
INFO(Option<String>),
|
INFO(Option<String>),
|
||||||
|
|
||||||
// 3.5 Service Query and Commands
|
// 3.5 Service Query and Commands
|
||||||
/// SERVLIST [mask :[type]]
|
/// SERVLIST [mask :[type]]
|
||||||
#[stable]
|
|
||||||
SERVLIST(Option<String>, Option<String>),
|
SERVLIST(Option<String>, Option<String>),
|
||||||
/// SQUERY servicename text
|
/// SQUERY servicename text
|
||||||
#[stable]
|
|
||||||
SQUERY(String, String),
|
SQUERY(String, String),
|
||||||
|
|
||||||
// 3.6 User based queries
|
// 3.6 User based queries
|
||||||
/// WHO [mask ["o"]]
|
/// WHO [mask ["o"]]
|
||||||
#[stable]
|
|
||||||
WHO(Option<String>, Option<bool>),
|
WHO(Option<String>, Option<bool>),
|
||||||
/// WHOIS [target] masklist
|
/// WHOIS [target] masklist
|
||||||
#[stable]
|
|
||||||
WHOIS(Option<String>, String),
|
WHOIS(Option<String>, String),
|
||||||
/// WHOWAS nicklist [count :[target]]
|
/// WHOWAS nicklist [count :[target]]
|
||||||
#[stable]
|
|
||||||
WHOWAS(String, Option<String>, Option<String>),
|
WHOWAS(String, Option<String>, Option<String>),
|
||||||
|
|
||||||
// 3.7 Miscellaneous messages
|
// 3.7 Miscellaneous messages
|
||||||
/// KILL nickname :comment
|
/// KILL nickname :comment
|
||||||
#[stable]
|
|
||||||
KILL(String, String),
|
KILL(String, String),
|
||||||
/// PING server1 :[server2]
|
/// PING server1 :[server2]
|
||||||
#[stable]
|
|
||||||
PING(String, Option<String>),
|
PING(String, Option<String>),
|
||||||
/// PONG server :[server2]
|
/// PONG server :[server2]
|
||||||
#[stable]
|
|
||||||
PONG(String, Option<String>),
|
PONG(String, Option<String>),
|
||||||
/// ERROR :message
|
/// ERROR :message
|
||||||
#[stable]
|
|
||||||
ERROR(String),
|
ERROR(String),
|
||||||
|
|
||||||
|
|
||||||
// 4 Optional Features
|
// 4 Optional Features
|
||||||
/// AWAY :[message]
|
/// AWAY :[message]
|
||||||
#[stable]
|
|
||||||
AWAY(Option<String>),
|
AWAY(Option<String>),
|
||||||
/// REHASH
|
/// REHASH
|
||||||
#[stable]
|
|
||||||
REHASH,
|
REHASH,
|
||||||
/// DIE
|
/// DIE
|
||||||
#[stable]
|
|
||||||
DIE,
|
DIE,
|
||||||
/// RESTART
|
/// RESTART
|
||||||
#[stable]
|
|
||||||
RESTART,
|
RESTART,
|
||||||
/// SUMMON user [target :[channel]]
|
/// SUMMON user [target :[channel]]
|
||||||
#[stable]
|
|
||||||
SUMMON(String, Option<String>, Option<String>),
|
SUMMON(String, Option<String>, Option<String>),
|
||||||
/// USERS :[target]
|
/// USERS :[target]
|
||||||
#[stable]
|
|
||||||
USERS(Option<String>),
|
USERS(Option<String>),
|
||||||
/// WALLOPS :Text to be sent
|
/// WALLOPS :Text to be sent
|
||||||
#[stable]
|
|
||||||
WALLOPS(String),
|
WALLOPS(String),
|
||||||
/// USERHOST space-separated nicklist
|
/// USERHOST space-separated nicklist
|
||||||
#[stable]
|
|
||||||
USERHOST(Vec<String>),
|
USERHOST(Vec<String>),
|
||||||
/// ISON space-separated nicklist
|
/// ISON space-separated nicklist
|
||||||
#[stable]
|
|
||||||
ISON(Vec<String>),
|
ISON(Vec<String>),
|
||||||
|
|
||||||
// Non-RFC commands from InspIRCd
|
// Non-RFC commands from InspIRCd
|
||||||
/// SAJOIN nickname channel
|
/// SAJOIN nickname channel
|
||||||
#[stable]
|
|
||||||
SAJOIN(String, String),
|
SAJOIN(String, String),
|
||||||
/// SAMODE target modes [modeparams]
|
/// SAMODE target modes [modeparams]
|
||||||
#[stable]
|
|
||||||
SAMODE(String, String, Option<String>),
|
SAMODE(String, String, Option<String>),
|
||||||
/// SANICK old nickname new nickname
|
/// SANICK old nickname new nickname
|
||||||
#[stable]
|
|
||||||
SANICK(String, String),
|
SANICK(String, String),
|
||||||
/// SAPART nickname :comment
|
/// SAPART nickname :comment
|
||||||
#[stable]
|
|
||||||
SAPART(String, String),
|
SAPART(String, String),
|
||||||
/// SAQUIT nickname :comment
|
/// SAQUIT nickname :comment
|
||||||
#[stable]
|
|
||||||
SAQUIT(String, String),
|
SAQUIT(String, String),
|
||||||
/// NICKSERV message
|
/// NICKSERV message
|
||||||
#[stable]
|
|
||||||
NICKSERV(String),
|
NICKSERV(String),
|
||||||
/// CHANSERV message
|
/// CHANSERV message
|
||||||
#[stable]
|
|
||||||
CHANSERV(String),
|
CHANSERV(String),
|
||||||
/// OPERSERV message
|
/// OPERSERV message
|
||||||
#[stable]
|
|
||||||
OPERSERV(String),
|
OPERSERV(String),
|
||||||
/// BOTSERV message
|
/// BOTSERV message
|
||||||
#[stable]
|
|
||||||
BOTSERV(String),
|
BOTSERV(String),
|
||||||
/// HOSTSERV message
|
/// HOSTSERV message
|
||||||
#[stable]
|
|
||||||
HOSTSERV(String),
|
HOSTSERV(String),
|
||||||
/// MEMOSERV message
|
/// MEMOSERV message
|
||||||
#[stable]
|
|
||||||
MEMOSERV(String),
|
MEMOSERV(String),
|
||||||
|
|
||||||
// Capabilities extension to IRCv3
|
// Capabilities extension to IRCv3
|
||||||
/// CAP [*] COMMAND [*] :[param]
|
/// CAP [*] COMMAND [*] :[param]
|
||||||
#[unstable = "Feature recently changed to hopefully be specification-compliant."]
|
|
||||||
CAP(Option<String>, CapSubCommand, Option<String>, Option<String>),
|
CAP(Option<String>, CapSubCommand, Option<String>, Option<String>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,10 +301,8 @@ impl ToMessage for Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl Command {
|
impl Command {
|
||||||
/// Converts a Message into a Command.
|
/// Converts a Message into a Command.
|
||||||
#[stable]
|
|
||||||
pub fn from_message(m: &Message) -> Result<Command> {
|
pub fn from_message(m: &Message) -> Result<Command> {
|
||||||
Ok(if let "PASS" = &m.command[..] {
|
Ok(if let "PASS" = &m.command[..] {
|
||||||
match m.suffix {
|
match m.suffix {
|
||||||
|
@ -1081,43 +1020,32 @@ impl Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a potential Message result into a potential Command result.
|
/// Converts a potential Message result into a potential Command result.
|
||||||
#[unstable = "This feature is still relatively new."]
|
|
||||||
pub fn from_message_io(m: Result<Message>) -> Result<Command> {
|
pub fn from_message_io(m: Result<Message>) -> Result<Command> {
|
||||||
m.and_then(|msg| Command::from_message(&msg))
|
m.and_then(|msg| Command::from_message(&msg))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A list of all of the subcommands for the capabilities extension.
|
/// A list of all of the subcommands for the capabilities extension.
|
||||||
#[stable]
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum CapSubCommand {
|
pub enum CapSubCommand {
|
||||||
/// Requests a list of the server's capabilities.
|
/// Requests a list of the server's capabilities.
|
||||||
#[stable]
|
|
||||||
LS,
|
LS,
|
||||||
/// Requests a list of the server's capabilities.
|
/// Requests a list of the server's capabilities.
|
||||||
#[stable]
|
|
||||||
LIST,
|
LIST,
|
||||||
/// Requests specific capabilities blindly.
|
/// Requests specific capabilities blindly.
|
||||||
#[stable]
|
|
||||||
REQ,
|
REQ,
|
||||||
/// Acknowledges capabilities.
|
/// Acknowledges capabilities.
|
||||||
#[stable]
|
|
||||||
ACK,
|
ACK,
|
||||||
/// Does not acknowledge certain capabilities.
|
/// Does not acknowledge certain capabilities.
|
||||||
#[stable]
|
|
||||||
NAK,
|
NAK,
|
||||||
/// Requests that the server clears the capabilities of this client.
|
/// Requests that the server clears the capabilities of this client.
|
||||||
#[stable]
|
|
||||||
CLEAR,
|
CLEAR,
|
||||||
/// Ends the capability negotiation before registration.
|
/// Ends the capability negotiation before registration.
|
||||||
#[stable]
|
|
||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl CapSubCommand {
|
impl CapSubCommand {
|
||||||
/// Gets the string that corresponds to this subcommand.
|
/// Gets the string that corresponds to this subcommand.
|
||||||
#[stable]
|
|
||||||
pub fn to_str(&self) -> &str {
|
pub fn to_str(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
&CapSubCommand::LS => "LS",
|
&CapSubCommand::LS => "LS",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! JSON configuration files using libserialize.
|
//! JSON configuration files using libserialize.
|
||||||
#![stable]
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -10,61 +9,43 @@ use rustc_serialize::json::decode;
|
||||||
|
|
||||||
/// Configuration data.
|
/// Configuration data.
|
||||||
#[derive(Clone, RustcDecodable, Default, PartialEq, Debug)]
|
#[derive(Clone, RustcDecodable, Default, PartialEq, Debug)]
|
||||||
#[stable]
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// A list of the owners of the bot by nickname.
|
/// A list of the owners of the bot by nickname.
|
||||||
#[stable]
|
|
||||||
pub owners: Option<Vec<String>>,
|
pub owners: Option<Vec<String>>,
|
||||||
/// The bot's nickname.
|
/// The bot's nickname.
|
||||||
#[stable]
|
|
||||||
pub nickname: Option<String>,
|
pub nickname: Option<String>,
|
||||||
/// The bot's NICKSERV password.
|
/// The bot's NICKSERV password.
|
||||||
#[stable]
|
|
||||||
pub nick_password: Option<String>,
|
pub nick_password: Option<String>,
|
||||||
/// Alternative nicknames for the bots, if the default is taken.
|
/// Alternative nicknames for the bots, if the default is taken.
|
||||||
#[stable]
|
|
||||||
pub alt_nicks: Option<Vec<String>>,
|
pub alt_nicks: Option<Vec<String>>,
|
||||||
/// The bot's username.
|
/// The bot's username.
|
||||||
#[stable]
|
|
||||||
pub username: Option<String>,
|
pub username: Option<String>,
|
||||||
/// The bot's real name.
|
/// The bot's real name.
|
||||||
#[stable]
|
|
||||||
pub realname: Option<String>,
|
pub realname: Option<String>,
|
||||||
/// The server to connect to.
|
/// The server to connect to.
|
||||||
#[stable]
|
|
||||||
pub server: Option<String>,
|
pub server: Option<String>,
|
||||||
/// The port to connect on.
|
/// The port to connect on.
|
||||||
#[stable]
|
|
||||||
pub port: Option<u16>,
|
pub port: Option<u16>,
|
||||||
/// The password to connect to the server.
|
/// The password to connect to the server.
|
||||||
#[stable]
|
|
||||||
pub password: Option<String>,
|
pub password: Option<String>,
|
||||||
/// Whether or not to use SSL.
|
/// Whether or not to use SSL.
|
||||||
/// Bots will automatically panic if this is enabled without SSL support.
|
/// Bots will automatically panic if this is enabled without SSL support.
|
||||||
#[stable]
|
|
||||||
pub use_ssl: Option<bool>,
|
pub use_ssl: Option<bool>,
|
||||||
/// The encoding type used for this connection.
|
/// The encoding type used for this connection.
|
||||||
/// This is typically UTF-8, but could be something else.
|
/// This is typically UTF-8, but could be something else.
|
||||||
#[stable]
|
|
||||||
pub encoding: Option<String>,
|
pub encoding: Option<String>,
|
||||||
/// A list of channels to join on connection.
|
/// A list of channels to join on connection.
|
||||||
#[stable]
|
|
||||||
pub channels: Option<Vec<String>>,
|
pub channels: Option<Vec<String>>,
|
||||||
/// User modes to set on connect. Example: "+RB-x"
|
/// User modes to set on connect. Example: "+RB-x"
|
||||||
#[unstable]
|
|
||||||
pub umodes: Option<String>,
|
pub umodes: Option<String>,
|
||||||
/// The text that'll be sent in response to CTCP USERINFO requests.
|
/// The text that'll be sent in response to CTCP USERINFO requests.
|
||||||
#[stable]
|
|
||||||
pub user_info: Option<String>,
|
pub user_info: Option<String>,
|
||||||
/// A map of additional options to be stored in config.
|
/// A map of additional options to be stored in config.
|
||||||
#[stable]
|
|
||||||
pub options: Option<HashMap<String, String>>,
|
pub options: Option<HashMap<String, String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Loads a JSON configuration from the desired path.
|
/// Loads a JSON configuration from the desired path.
|
||||||
#[stable]
|
|
||||||
pub fn load(path: &Path) -> Result<Config> {
|
pub fn load(path: &Path) -> Result<Config> {
|
||||||
let mut file = try!(File::open(path));
|
let mut file = try!(File::open(path));
|
||||||
let mut data = String::new();
|
let mut data = String::new();
|
||||||
|
@ -75,34 +56,29 @@ impl Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a JSON configuration using the string as a UTF-8 path.
|
/// Loads a JSON configuration using the string as a UTF-8 path.
|
||||||
#[stable]
|
|
||||||
pub fn load_utf8(path: &str) -> Result<Config> {
|
pub fn load_utf8(path: &str) -> Result<Config> {
|
||||||
Config::load(Path::new(path))
|
Config::load(Path::new(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines whether or not the nickname provided is the owner of the bot.
|
/// Determines whether or not the nickname provided is the owner of the bot.
|
||||||
#[stable]
|
|
||||||
pub fn is_owner(&self, nickname: &str) -> bool {
|
pub fn is_owner(&self, nickname: &str) -> bool {
|
||||||
self.owners.as_ref().map(|o| o.contains(&nickname.to_string())).unwrap()
|
self.owners.as_ref().map(|o| o.contains(&nickname.to_string())).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the nickname specified in the configuration.
|
/// Gets the nickname specified in the configuration.
|
||||||
/// This will panic if not specified.
|
/// This will panic if not specified.
|
||||||
#[stable]
|
|
||||||
pub fn nickname(&self) -> &str {
|
pub fn nickname(&self) -> &str {
|
||||||
self.nickname.as_ref().map(|s| &s[..]).unwrap()
|
self.nickname.as_ref().map(|s| &s[..]).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the bot's nickserv password specified in the configuration.
|
/// Gets the bot's nickserv password specified in the configuration.
|
||||||
/// This defaults to an empty string when not specified.
|
/// This defaults to an empty string when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn nick_password(&self) -> &str {
|
pub fn nick_password(&self) -> &str {
|
||||||
self.nick_password.as_ref().map(|s| &s[..]).unwrap_or("")
|
self.nick_password.as_ref().map(|s| &s[..]).unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the alternate nicknames specified in the configuration.
|
/// Gets the alternate nicknames specified in the configuration.
|
||||||
/// This defaults to an empty vector when not specified.
|
/// This defaults to an empty vector when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn get_alternate_nicknames(&self) -> Vec<&str> {
|
pub fn get_alternate_nicknames(&self) -> Vec<&str> {
|
||||||
self.alt_nicks.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
|
self.alt_nicks.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
|
||||||
}
|
}
|
||||||
|
@ -110,28 +86,24 @@ impl Config {
|
||||||
|
|
||||||
/// Gets the username specified in the configuration.
|
/// Gets the username specified in the configuration.
|
||||||
/// This defaults to the user's nickname when not specified.
|
/// This defaults to the user's nickname when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn username(&self) -> &str {
|
pub fn username(&self) -> &str {
|
||||||
self.username.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
|
self.username.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the real name specified in the configuration.
|
/// Gets the real name specified in the configuration.
|
||||||
/// This defaults to the user's nickname when not specified.
|
/// This defaults to the user's nickname when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn real_name(&self) -> &str {
|
pub fn real_name(&self) -> &str {
|
||||||
self.realname.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
|
self.realname.as_ref().map(|s| &s[..]).unwrap_or(self.nickname())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the address of the server specified in the configuration.
|
/// Gets the address of the server specified in the configuration.
|
||||||
/// This panics when not specified.
|
/// This panics when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn server(&self) -> &str {
|
pub fn server(&self) -> &str {
|
||||||
self.server.as_ref().map(|s| &s[..]).unwrap()
|
self.server.as_ref().map(|s| &s[..]).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the port of the server specified in the configuration.
|
/// Gets the port of the server specified in the configuration.
|
||||||
/// This defaults to 6667 (or 6697 if use_ssl is specified as true) when not specified.
|
/// This defaults to 6667 (or 6697 if use_ssl is specified as true) when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn port(&self) -> u16 {
|
pub fn port(&self) -> u16 {
|
||||||
self.port.as_ref().map(|p| *p).unwrap_or(if self.use_ssl() {
|
self.port.as_ref().map(|p| *p).unwrap_or(if self.use_ssl() {
|
||||||
6697
|
6697
|
||||||
|
@ -142,42 +114,36 @@ impl Config {
|
||||||
|
|
||||||
/// Gets the server password specified in the configuration.
|
/// Gets the server password specified in the configuration.
|
||||||
/// This defaults to a blank string when not specified.
|
/// This defaults to a blank string when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn password(&self) -> &str {
|
pub fn password(&self) -> &str {
|
||||||
self.password.as_ref().map(|s| &s[..]).unwrap_or("")
|
self.password.as_ref().map(|s| &s[..]).unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets whether or not to use SSL with this connection.
|
/// Gets whether or not to use SSL with this connection.
|
||||||
/// This defaults to false when not specified.
|
/// This defaults to false when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn use_ssl(&self) -> bool {
|
pub fn use_ssl(&self) -> bool {
|
||||||
self.use_ssl.as_ref().map(|u| *u).unwrap_or(false)
|
self.use_ssl.as_ref().map(|u| *u).unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the encoding to use for this connection. This requires the encode feature to work.
|
/// Gets the encoding to use for this connection. This requires the encode feature to work.
|
||||||
/// This defaults to UTF-8 when not specified.
|
/// This defaults to UTF-8 when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn encoding(&self) -> &str {
|
pub fn encoding(&self) -> &str {
|
||||||
self.encoding.as_ref().map(|s| &s[..]).unwrap_or("UTF-8")
|
self.encoding.as_ref().map(|s| &s[..]).unwrap_or("UTF-8")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the channels to join upon connection.
|
/// Gets the channels to join upon connection.
|
||||||
/// This defaults to an empty vector if it's not specified.
|
/// This defaults to an empty vector if it's not specified.
|
||||||
#[stable]
|
|
||||||
pub fn channels(&self) -> Vec<&str> {
|
pub fn channels(&self) -> Vec<&str> {
|
||||||
self.channels.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
|
self.channels.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the user modes to set on connect specified in the configuration.
|
/// Gets the user modes to set on connect specified in the configuration.
|
||||||
/// This defaults to an empty string when not specified.
|
/// This defaults to an empty string when not specified.
|
||||||
#[unstable = "Feature is still relatively new."]
|
|
||||||
pub fn umodes(&self) -> &str {
|
pub fn umodes(&self) -> &str {
|
||||||
self.umodes.as_ref().map(|s| &s[..]).unwrap_or("")
|
self.umodes.as_ref().map(|s| &s[..]).unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the string to be sent in response to CTCP USERINFO requests.
|
/// Gets the string to be sent in response to CTCP USERINFO requests.
|
||||||
/// This defaults to an empty string when not specified.
|
/// This defaults to an empty string when not specified.
|
||||||
#[stable]
|
|
||||||
pub fn user_info(&self) -> &str {
|
pub fn user_info(&self) -> &str {
|
||||||
self.user_info.as_ref().map(|s| &s[..]).unwrap_or("")
|
self.user_info.as_ref().map(|s| &s[..]).unwrap_or("")
|
||||||
}
|
}
|
||||||
|
@ -185,7 +151,6 @@ impl Config {
|
||||||
/// Looks up the specified string in the options map.
|
/// Looks up the specified string in the options map.
|
||||||
/// This uses indexing, and thus panics when the string is not present.
|
/// This uses indexing, and thus panics when the string is not present.
|
||||||
/// This will also panic if used and there are no options.
|
/// This will also panic if used and there are no options.
|
||||||
#[stable]
|
|
||||||
pub fn get_option(&self, option: &str) -> &str {
|
pub fn get_option(&self, option: &str) -> &str {
|
||||||
self.options.as_ref().map(|o| &o[&option.to_owned()][..]).unwrap()
|
self.options.as_ref().map(|o| &o[&option.to_owned()][..]).unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,23 @@
|
||||||
//! Messages to and from the server.
|
//! Messages to and from the server.
|
||||||
#![stable]
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// IRC Message data.
|
/// IRC Message data.
|
||||||
#[stable]
|
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
/// The message prefix (or source) as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
/// The message prefix (or source) as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
||||||
#[stable]
|
|
||||||
pub prefix: Option<String>,
|
pub prefix: Option<String>,
|
||||||
/// The IRC command as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
/// The IRC command as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
||||||
#[stable]
|
|
||||||
pub command: String,
|
pub command: String,
|
||||||
/// The command arguments.
|
/// The command arguments.
|
||||||
#[stable]
|
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
/// The message suffix as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
/// The message suffix as defined by [RFC 2812](http://tools.ietf.org/html/rfc2812).
|
||||||
/// This is the only part of the message that is allowed to contain spaces.
|
/// This is the only part of the message that is allowed to contain spaces.
|
||||||
#[stable]
|
|
||||||
pub suffix: Option<String>,
|
pub suffix: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl Message {
|
impl Message {
|
||||||
/// Creates a new Message.
|
/// Creates a new Message.
|
||||||
#[stable]
|
|
||||||
pub fn new(prefix: Option<&str>, command: &str, args: Option<Vec<&str>>, suffix: Option<&str>)
|
pub fn new(prefix: Option<&str>, command: &str, args: Option<Vec<&str>>, suffix: Option<&str>)
|
||||||
-> Message {
|
-> Message {
|
||||||
Message {
|
Message {
|
||||||
|
@ -37,13 +29,11 @@ impl Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the nickname of the message source, if it exists.
|
/// Gets the nickname of the message source, if it exists.
|
||||||
#[stable]
|
|
||||||
pub fn get_source_nickname(&self) -> Option<&str> {
|
pub fn get_source_nickname(&self) -> Option<&str> {
|
||||||
self.prefix.as_ref().and_then(|s| s.find('!').map(|i| &s[..i]))
|
self.prefix.as_ref().and_then(|s| s.find('!').map(|i| &s[..i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a Message into a String according to the IRC protocol.
|
/// Converts a Message into a String according to the IRC protocol.
|
||||||
#[stable]
|
|
||||||
pub fn into_string(&self) -> String {
|
pub fn into_string(&self) -> String {
|
||||||
let mut ret = String::new();
|
let mut ret = String::new();
|
||||||
if let Some(ref prefix) = self.prefix {
|
if let Some(ref prefix) = self.prefix {
|
||||||
|
@ -104,7 +94,6 @@ impl FromStr for Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait representing the ability to be converted into a Message.
|
/// A trait representing the ability to be converted into a Message.
|
||||||
#[stable]
|
|
||||||
pub trait ToMessage {
|
pub trait ToMessage {
|
||||||
/// Converts this to a Message.
|
/// Converts this to a Message.
|
||||||
fn to_message(&self) -> Message;
|
fn to_message(&self) -> Message;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! Data related to IRC functionality.
|
//! Data related to IRC functionality.
|
||||||
#![stable]
|
|
||||||
|
|
||||||
pub use client::data::command::Command;
|
pub use client::data::command::Command;
|
||||||
pub use client::data::config::Config;
|
pub use client::data::config::Config;
|
||||||
|
@ -9,15 +8,12 @@ pub use client::data::user::{AccessLevel, User};
|
||||||
|
|
||||||
pub mod kinds {
|
pub mod kinds {
|
||||||
//! Trait definitions of appropriate Writers and Buffers for use with this library.
|
//! Trait definitions of appropriate Writers and Buffers for use with this library.
|
||||||
#![stable]
|
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
|
|
||||||
/// Trait describing all possible Writers for this library.
|
/// Trait describing all possible Writers for this library.
|
||||||
#[stable]
|
|
||||||
pub trait IrcWrite: Write + Sized + Send + 'static {}
|
pub trait IrcWrite: Write + Sized + Send + 'static {}
|
||||||
impl<T> IrcWrite for T where T: Write + Sized + Send + 'static {}
|
impl<T> IrcWrite for T where T: Write + Sized + Send + 'static {}
|
||||||
/// Trait describing all possible Readers for this library.
|
/// Trait describing all possible Readers for this library.
|
||||||
#[stable]
|
|
||||||
pub trait IrcRead: BufRead + Sized + Send + 'static {}
|
pub trait IrcRead: BufRead + Sized + Send + 'static {}
|
||||||
impl<T> IrcRead for T where T: BufRead + Sized + Send + 'static {}
|
impl<T> IrcRead for T where T: BufRead + Sized + Send + 'static {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! Enumeration of all the possible server responses.
|
//! Enumeration of all the possible server responses.
|
||||||
#![stable]
|
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
@ -9,437 +8,296 @@ use client::data::message::Message;
|
||||||
/// All commands are documented with their expected form from the RFC.
|
/// All commands are documented with their expected form from the RFC.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
#[stable]
|
|
||||||
pub enum Response {
|
pub enum Response {
|
||||||
// Expected replies
|
// Expected replies
|
||||||
/// 001 Welcome to the Internet Relay Network <nick>!<user>@<host>
|
/// 001 Welcome to the Internet Relay Network <nick>!<user>@<host>
|
||||||
#[stable]
|
|
||||||
RPL_WELCOME = 001,
|
RPL_WELCOME = 001,
|
||||||
/// 002 Your host is <servername>, running version <ver>
|
/// 002 Your host is <servername>, running version <ver>
|
||||||
#[stable]
|
|
||||||
RPL_YOURHOST = 002,
|
RPL_YOURHOST = 002,
|
||||||
/// 003 This server was created <date>
|
/// 003 This server was created <date>
|
||||||
#[stable]
|
|
||||||
RPL_CREATED = 003,
|
RPL_CREATED = 003,
|
||||||
/// 004 <servername> <version> <available user modes> available channel modes>
|
/// 004 <servername> <version> <available user modes> available channel modes>
|
||||||
#[stable]
|
|
||||||
RPL_MYINFO = 004,
|
RPL_MYINFO = 004,
|
||||||
/// 005 Try server <server name>, port <port number>
|
/// 005 Try server <server name>, port <port number>
|
||||||
#[stable]
|
|
||||||
RPL_BOUNCE = 005,
|
RPL_BOUNCE = 005,
|
||||||
/// 302 :*1<reply> *( " " <reply> )
|
/// 302 :*1<reply> *( " " <reply> )
|
||||||
#[stable]
|
|
||||||
RPL_USERHOST = 302,
|
RPL_USERHOST = 302,
|
||||||
/// 303 :*1<nick> *( " " <nick> )
|
/// 303 :*1<nick> *( " " <nick> )
|
||||||
#[stable]
|
|
||||||
RPL_ISON = 303,
|
RPL_ISON = 303,
|
||||||
/// 301 <nick> :<away message>
|
/// 301 <nick> :<away message>
|
||||||
#[stable]
|
|
||||||
RPL_AWAY = 301,
|
RPL_AWAY = 301,
|
||||||
/// 305 :You are no longer marked as being away
|
/// 305 :You are no longer marked as being away
|
||||||
#[stable]
|
|
||||||
RPL_UNAWAY = 305,
|
RPL_UNAWAY = 305,
|
||||||
/// 306 :You have been marked as being away
|
/// 306 :You have been marked as being away
|
||||||
#[stable]
|
|
||||||
RPL_NOWAWAY = 306,
|
RPL_NOWAWAY = 306,
|
||||||
/// 311 <nick> <user> <host> * :<real name>
|
/// 311 <nick> <user> <host> * :<real name>
|
||||||
#[stable]
|
|
||||||
RPL_WHOISUSER = 311,
|
RPL_WHOISUSER = 311,
|
||||||
/// 312 <nick> <server> :<server info>
|
/// 312 <nick> <server> :<server info>
|
||||||
#[stable]
|
|
||||||
RPL_WHOISSERVER = 312,
|
RPL_WHOISSERVER = 312,
|
||||||
/// 313 <nick> :is an IRC operator
|
/// 313 <nick> :is an IRC operator
|
||||||
#[stable]
|
|
||||||
RPL_WHOISOPERATOR = 313,
|
RPL_WHOISOPERATOR = 313,
|
||||||
/// 317 <nick> <integer> :seconds idle
|
/// 317 <nick> <integer> :seconds idle
|
||||||
#[stable]
|
|
||||||
RPL_WHOISIDLE = 317,
|
RPL_WHOISIDLE = 317,
|
||||||
/// 318 <nick> :End of WHOIS list
|
/// 318 <nick> :End of WHOIS list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFWHOIS = 318,
|
RPL_ENDOFWHOIS = 318,
|
||||||
/// 319 <nick> :*( ( "@" / "+" ) <channel> " " )
|
/// 319 <nick> :*( ( "@" / "+" ) <channel> " " )
|
||||||
#[stable]
|
|
||||||
RPL_WHOISCHANNELS = 319,
|
RPL_WHOISCHANNELS = 319,
|
||||||
/// 314 <nick> <user> <host> * :<real name>
|
/// 314 <nick> <user> <host> * :<real name>
|
||||||
#[stable]
|
|
||||||
RPL_WHOWASUSER = 314,
|
RPL_WHOWASUSER = 314,
|
||||||
/// 369 <nick> :End of WHOWAS
|
/// 369 <nick> :End of WHOWAS
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFWHOWAS = 369,
|
RPL_ENDOFWHOWAS = 369,
|
||||||
/// Obsolete. Not used.
|
/// Obsolete. Not used.
|
||||||
#[stable]
|
|
||||||
RPL_LISTSTART = 321,
|
RPL_LISTSTART = 321,
|
||||||
/// 322 <channel> <# visible> :<topic>
|
/// 322 <channel> <# visible> :<topic>
|
||||||
#[stable]
|
|
||||||
RPL_LIST = 322,
|
RPL_LIST = 322,
|
||||||
/// 323 :End of LIST
|
/// 323 :End of LIST
|
||||||
#[stable]
|
|
||||||
RPL_LISTEND = 323,
|
RPL_LISTEND = 323,
|
||||||
/// 325 <channel> <nickname>
|
/// 325 <channel> <nickname>
|
||||||
#[stable]
|
|
||||||
RPL_UNIQOPIS = 325,
|
RPL_UNIQOPIS = 325,
|
||||||
/// 324 <channel> <mode> <mode params>
|
/// 324 <channel> <mode> <mode params>
|
||||||
#[stable]
|
|
||||||
RPL_CHANNELMODEIS = 324,
|
RPL_CHANNELMODEIS = 324,
|
||||||
/// 331 <channel> :No topic is set
|
/// 331 <channel> :No topic is set
|
||||||
#[stable]
|
|
||||||
RPL_NOTOPIC = 331,
|
RPL_NOTOPIC = 331,
|
||||||
/// 332 <channel> :<topic>
|
/// 332 <channel> :<topic>
|
||||||
#[stable]
|
|
||||||
RPL_TOPIC = 332,
|
RPL_TOPIC = 332,
|
||||||
/// 341 <channel> <nick>
|
/// 341 <channel> <nick>
|
||||||
#[stable]
|
|
||||||
RPL_INVITING = 341,
|
RPL_INVITING = 341,
|
||||||
/// 342 <user> :Summoning user to IRC
|
/// 342 <user> :Summoning user to IRC
|
||||||
#[stable]
|
|
||||||
RPL_SUMMONING = 342,
|
RPL_SUMMONING = 342,
|
||||||
/// 346 <channel> <invitemask>
|
/// 346 <channel> <invitemask>
|
||||||
#[stable]
|
|
||||||
RPL_INVITELIST = 346,
|
RPL_INVITELIST = 346,
|
||||||
/// 347 <channel> :End of channel invite list
|
/// 347 <channel> :End of channel invite list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFINVITELIST = 347,
|
RPL_ENDOFINVITELIST = 347,
|
||||||
/// 348 <channel> <exceptionmask>
|
/// 348 <channel> <exceptionmask>
|
||||||
#[stable]
|
|
||||||
RPL_EXCEPTLIST = 348,
|
RPL_EXCEPTLIST = 348,
|
||||||
/// 349 <channel> :End of channel exception list
|
/// 349 <channel> :End of channel exception list
|
||||||
#[stable]
|
RPL_ENDOFEXCEPTLIST = 349,
|
||||||
RPL_ENDOFEXECPTLIST = 349,
|
|
||||||
/// 351 <version>.<debuglevel> <server> :<comments>
|
/// 351 <version>.<debuglevel> <server> :<comments>
|
||||||
#[stable]
|
|
||||||
RPL_VERSION = 351,
|
RPL_VERSION = 351,
|
||||||
/// 352 <channel> <user> <host> <server> <nick> ( "H" / "G" > ["*"] [ ( "@" / "+" ) ]
|
/// 352 <channel> <user> <host> <server> <nick> ( "H" / "G" > ["*"] [ ( "@" / "+" ) ]
|
||||||
#[stable]
|
|
||||||
/// :<hopcount> <real name>
|
/// :<hopcount> <real name>
|
||||||
#[stable]
|
|
||||||
RPL_WHOREPLY = 352,
|
RPL_WHOREPLY = 352,
|
||||||
/// 315 <name> :End of WHO list
|
/// 315 <name> :End of WHO list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFWHO = 315,
|
RPL_ENDOFWHO = 315,
|
||||||
/// 353 ( "=" / "*" / "@" ) <channel> :[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
|
/// 353 ( "=" / "*" / "@" ) <channel> :[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
|
||||||
#[stable]
|
|
||||||
RPL_NAMREPLY = 353,
|
RPL_NAMREPLY = 353,
|
||||||
/// 366 <channel> :End of NAMES list
|
/// 366 <channel> :End of NAMES list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFNAMES = 366,
|
RPL_ENDOFNAMES = 366,
|
||||||
/// 364 <mask> <server> :<hopcount> <server info>
|
/// 364 <mask> <server> :<hopcount> <server info>
|
||||||
#[stable]
|
|
||||||
RPL_LINKS = 364,
|
RPL_LINKS = 364,
|
||||||
/// 365 <mask> :End of LINKS list
|
/// 365 <mask> :End of LINKS list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFLINKS = 365,
|
RPL_ENDOFLINKS = 365,
|
||||||
/// 367 <channel> <banmask>
|
/// 367 <channel> <banmask>
|
||||||
#[stable]
|
|
||||||
RPL_BANLIST = 367,
|
RPL_BANLIST = 367,
|
||||||
/// 368 <channel> :End of channel ban list
|
/// 368 <channel> :End of channel ban list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFBANLIST = 368,
|
RPL_ENDOFBANLIST = 368,
|
||||||
/// 371 :<string>
|
/// 371 :<string>
|
||||||
#[stable]
|
|
||||||
RPL_INFO = 371,
|
RPL_INFO = 371,
|
||||||
/// 374 :End of INFO list
|
/// 374 :End of INFO list
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFINFO = 374,
|
RPL_ENDOFINFO = 374,
|
||||||
/// 375 :- <server> Message of the day -
|
/// 375 :- <server> Message of the day -
|
||||||
#[stable]
|
|
||||||
RPL_MOTDSTART = 375,
|
RPL_MOTDSTART = 375,
|
||||||
/// 372 :- <text>
|
/// 372 :- <text>
|
||||||
#[stable]
|
|
||||||
RPL_MOTD = 372,
|
RPL_MOTD = 372,
|
||||||
/// 376 :End of MOTD command
|
/// 376 :End of MOTD command
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFMOTD = 376,
|
RPL_ENDOFMOTD = 376,
|
||||||
/// 381 :You are now an IRC operator
|
/// 381 :You are now an IRC operator
|
||||||
#[stable]
|
|
||||||
RPL_YOUREOPER = 381,
|
RPL_YOUREOPER = 381,
|
||||||
/// 382 <config file> :Rehashing
|
/// 382 <config file> :Rehashing
|
||||||
#[stable]
|
|
||||||
RPL_REHASHING = 382,
|
RPL_REHASHING = 382,
|
||||||
/// 383 You are service <servicename>
|
/// 383 You are service <servicename>
|
||||||
#[stable]
|
|
||||||
RPL_YOURESERVICE = 383,
|
RPL_YOURESERVICE = 383,
|
||||||
/// 391 <server> :<string showing server's local time>
|
/// 391 <server> :<string showing server's local time>
|
||||||
#[stable]
|
|
||||||
RPL_TIME = 391,
|
RPL_TIME = 391,
|
||||||
/// 392 :UserID Terminal Host
|
/// 392 :UserID Terminal Host
|
||||||
#[stable]
|
|
||||||
RPL_USERSSTART = 392,
|
RPL_USERSSTART = 392,
|
||||||
/// 393 :<username> <ttyline> <hostname>
|
/// 393 :<username> <ttyline> <hostname>
|
||||||
#[stable]
|
|
||||||
RPL_USERS = 393,
|
RPL_USERS = 393,
|
||||||
/// 394 :End of users
|
/// 394 :End of users
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFUSERS = 394,
|
RPL_ENDOFUSERS = 394,
|
||||||
/// 395 :Nobody logged in
|
/// 395 :Nobody logged in
|
||||||
#[stable]
|
|
||||||
RPL_NOUSERS = 395,
|
RPL_NOUSERS = 395,
|
||||||
/// 200 Link <version & debug level> <destination> <next server> V<protocol version>
|
/// 200 Link <version & debug level> <destination> <next server> V<protocol version>
|
||||||
/// <link uptime in seconds> <backstream sendq> <upstream sendq>
|
/// <link uptime in seconds> <backstream sendq> <upstream sendq>
|
||||||
#[stable]
|
|
||||||
RPL_TRACELINK = 200,
|
RPL_TRACELINK = 200,
|
||||||
/// 201 Try. <class> <server>
|
/// 201 Try. <class> <server>
|
||||||
#[stable]
|
|
||||||
RPL_TRACECONNECTING = 201,
|
RPL_TRACECONNECTING = 201,
|
||||||
/// 202 H.S. <class> <server>
|
/// 202 H.S. <class> <server>
|
||||||
#[stable]
|
|
||||||
RPL_TRACEHANDSHAKE = 202,
|
RPL_TRACEHANDSHAKE = 202,
|
||||||
/// 203 ???? <class> [<client IP address in dot form>]
|
/// 203 ???? <class> [<client IP address in dot form>]
|
||||||
#[stable]
|
|
||||||
RPL_TRACEUKNOWN = 203,
|
RPL_TRACEUKNOWN = 203,
|
||||||
/// 204 Oper <class> <nick>
|
/// 204 Oper <class> <nick>
|
||||||
#[stable]
|
|
||||||
RPL_TRACEOPERATOR = 204,
|
RPL_TRACEOPERATOR = 204,
|
||||||
/// 205 User <class> <nick>
|
/// 205 User <class> <nick>
|
||||||
#[stable]
|
|
||||||
RPL_TRACEUSER = 205,
|
RPL_TRACEUSER = 205,
|
||||||
/// 206 Serv <class> <int>S <int>C <server> <nick!user|*!*>@<host|server> V<protocol version>
|
/// 206 Serv <class> <int>S <int>C <server> <nick!user|*!*>@<host|server> V<protocol version>
|
||||||
#[stable]
|
|
||||||
RPL_TRACESERVER = 206,
|
RPL_TRACESERVER = 206,
|
||||||
/// 207 Service <class> <name> <type> <active type>
|
/// 207 Service <class> <name> <type> <active type>
|
||||||
#[stable]
|
|
||||||
RPL_TRACESERVICE = 207,
|
RPL_TRACESERVICE = 207,
|
||||||
/// 208 <newtype> 0 <client name>
|
/// 208 <newtype> 0 <client name>
|
||||||
#[stable]
|
|
||||||
RPL_TRACENEWTYPE = 208,
|
RPL_TRACENEWTYPE = 208,
|
||||||
/// 209 Class <class> <count>
|
/// 209 Class <class> <count>
|
||||||
#[stable]
|
|
||||||
RPL_TRACECLASS = 209,
|
RPL_TRACECLASS = 209,
|
||||||
/// Unused.
|
/// Unused.
|
||||||
RPL_TRACERECONNECT = 210,
|
RPL_TRACERECONNECT = 210,
|
||||||
/// 261 File <logfile> <debug level>
|
/// 261 File <logfile> <debug level>
|
||||||
#[stable]
|
|
||||||
RPL_TRACELOG = 261,
|
RPL_TRACELOG = 261,
|
||||||
/// 262 <server name> <version & debug level> :End of TRACE
|
/// 262 <server name> <version & debug level> :End of TRACE
|
||||||
#[stable]
|
|
||||||
RPL_TRACEEND = 262,
|
RPL_TRACEEND = 262,
|
||||||
/// 211 <linkname> <sendq> <sent messages> <sent Kbytes> <received messages> <received Kbytes>
|
/// 211 <linkname> <sendq> <sent messages> <sent Kbytes> <received messages> <received Kbytes>
|
||||||
/// <time open>
|
/// <time open>
|
||||||
#[stable]
|
|
||||||
RPL_STATSLINKINFO = 211,
|
RPL_STATSLINKINFO = 211,
|
||||||
/// 212 <command> <count> <byte count> <remote count>
|
/// 212 <command> <count> <byte count> <remote count>
|
||||||
#[stable]
|
|
||||||
RPL_STATSCOMMANDS = 212,
|
RPL_STATSCOMMANDS = 212,
|
||||||
/// 219 <stats letter> :End of STATS report
|
/// 219 <stats letter> :End of STATS report
|
||||||
#[stable]
|
|
||||||
RPL_ENDOFSTATS = 219,
|
RPL_ENDOFSTATS = 219,
|
||||||
/// 242 :Server Up %d days %d:%02d:%02d
|
/// 242 :Server Up %d days %d:%02d:%02d
|
||||||
#[stable]
|
|
||||||
RPL_STATSUPTIME = 242,
|
RPL_STATSUPTIME = 242,
|
||||||
/// O <hostmask> * <name>
|
/// O <hostmask> * <name>
|
||||||
#[stable]
|
|
||||||
RPL_STATSOLINE = 243,
|
RPL_STATSOLINE = 243,
|
||||||
/// 221 <user mode string>
|
/// 221 <user mode string>
|
||||||
#[stable]
|
|
||||||
RPL_UMODEIS = 221,
|
RPL_UMODEIS = 221,
|
||||||
/// 234 <name> <server> <mask> <type> <hopcount> <info>
|
/// 234 <name> <server> <mask> <type> <hopcount> <info>
|
||||||
#[stable]
|
|
||||||
RPL_SERVLIST = 234,
|
RPL_SERVLIST = 234,
|
||||||
/// 235 <mask> <type> :End of service listing
|
/// 235 <mask> <type> :End of service listing
|
||||||
#[stable]
|
|
||||||
RPL_SERVLISTEND = 235,
|
RPL_SERVLISTEND = 235,
|
||||||
/// 251 :There are <integer> users and <integer> services on <integer> servers
|
/// 251 :There are <integer> users and <integer> services on <integer> servers
|
||||||
#[stable]
|
|
||||||
RPL_LUSERCLIENT = 251,
|
RPL_LUSERCLIENT = 251,
|
||||||
/// 252 <integer> :operator(s) online
|
/// 252 <integer> :operator(s) online
|
||||||
#[stable]
|
|
||||||
RPL_LUSEROP = 252,
|
RPL_LUSEROP = 252,
|
||||||
/// 253 <integer> :unknown connection(s)
|
/// 253 <integer> :unknown connection(s)
|
||||||
#[stable]
|
|
||||||
RPL_LUSERUNKNOWN = 253,
|
RPL_LUSERUNKNOWN = 253,
|
||||||
/// 254 <integer> :channels formed
|
/// 254 <integer> :channels formed
|
||||||
#[stable]
|
|
||||||
RPL_LUSERCHANNELS = 254,
|
RPL_LUSERCHANNELS = 254,
|
||||||
/// 255 :I have <integer> clients and <integer> servers
|
/// 255 :I have <integer> clients and <integer> servers
|
||||||
#[stable]
|
|
||||||
RPL_LUSERME = 255,
|
RPL_LUSERME = 255,
|
||||||
/// 256 <server> :Administrative info
|
/// 256 <server> :Administrative info
|
||||||
#[stable]
|
|
||||||
RPL_ADMINME = 256,
|
RPL_ADMINME = 256,
|
||||||
/// 257 :<admin info>
|
/// 257 :<admin info>
|
||||||
#[stable]
|
|
||||||
RPL_ADMINLOC1 = 257,
|
RPL_ADMINLOC1 = 257,
|
||||||
/// 258 :<admin info>
|
/// 258 :<admin info>
|
||||||
#[stable]
|
|
||||||
RPL_ADMINLOC2 = 258,
|
RPL_ADMINLOC2 = 258,
|
||||||
/// 259 :<admin info>
|
/// 259 :<admin info>
|
||||||
#[stable]
|
|
||||||
RPL_ADMINEMAIL = 259,
|
RPL_ADMINEMAIL = 259,
|
||||||
/// 263 <command> :Please wait a while and try again.
|
/// 263 <command> :Please wait a while and try again.
|
||||||
#[stable]
|
|
||||||
RPL_TRYAGAIN = 263,
|
RPL_TRYAGAIN = 263,
|
||||||
|
|
||||||
// Error replies
|
// Error replies
|
||||||
/// 401 <nickname> :No such nick/channel
|
/// 401 <nickname> :No such nick/channel
|
||||||
#[stable]
|
|
||||||
ERR_NOSUCHNICK = 401,
|
ERR_NOSUCHNICK = 401,
|
||||||
/// 402 <server name> :No such server
|
/// 402 <server name> :No such server
|
||||||
#[stable]
|
|
||||||
ERR_NOSUCHSERVER = 402,
|
ERR_NOSUCHSERVER = 402,
|
||||||
/// 403 <channel name> :No such channel
|
/// 403 <channel name> :No such channel
|
||||||
#[stable]
|
|
||||||
ERR_NOSUCHCHANNEL = 403,
|
ERR_NOSUCHCHANNEL = 403,
|
||||||
/// 404 <channel name> :Cannot send to channel
|
/// 404 <channel name> :Cannot send to channel
|
||||||
#[stable]
|
|
||||||
ERR_CANNOTSENDTOCHAN = 404,
|
ERR_CANNOTSENDTOCHAN = 404,
|
||||||
/// 405 <channel name> :You have joined too many channels
|
/// 405 <channel name> :You have joined too many channels
|
||||||
#[stable]
|
|
||||||
ERR_TOOMANYCHANNELS = 405,
|
ERR_TOOMANYCHANNELS = 405,
|
||||||
/// 406 <nickname> :There was no such nickname
|
/// 406 <nickname> :There was no such nickname
|
||||||
#[stable]
|
|
||||||
ERR_WASNOSUCHNICK = 406,
|
ERR_WASNOSUCHNICK = 406,
|
||||||
/// 407 <target> :<error code> recipients. <abort message>
|
/// 407 <target> :<error code> recipients. <abort message>
|
||||||
#[stable]
|
|
||||||
ERR_TOOMANYTARGETS = 407,
|
ERR_TOOMANYTARGETS = 407,
|
||||||
/// 408 <service name> :No such service
|
/// 408 <service name> :No such service
|
||||||
#[stable]
|
|
||||||
ERR_NOSUCHSERVICE = 408,
|
ERR_NOSUCHSERVICE = 408,
|
||||||
/// 409 :No origin specified
|
/// 409 :No origin specified
|
||||||
#[stable]
|
|
||||||
ERR_NOORIGIN = 409,
|
ERR_NOORIGIN = 409,
|
||||||
/// 411 :No recipient given (<command>)
|
/// 411 :No recipient given (<command>)
|
||||||
#[stable]
|
|
||||||
ERR_NORECIPIENT = 411,
|
ERR_NORECIPIENT = 411,
|
||||||
/// 412 :No text to send
|
/// 412 :No text to send
|
||||||
#[stable]
|
|
||||||
ERR_NOTEXTTOSEND = 412,
|
ERR_NOTEXTTOSEND = 412,
|
||||||
/// 413 <mask> :No toplevel domain specified
|
/// 413 <mask> :No toplevel domain specified
|
||||||
#[stable]
|
|
||||||
ERR_NOTOPLEVEL = 413,
|
ERR_NOTOPLEVEL = 413,
|
||||||
/// 414 <mask> :Wildcard in toplevel domain
|
/// 414 <mask> :Wildcard in toplevel domain
|
||||||
#[stable]
|
|
||||||
ERR_WILDTOPLEVEL = 414,
|
ERR_WILDTOPLEVEL = 414,
|
||||||
/// 415 <mask> :Bad Server/host mask
|
/// 415 <mask> :Bad Server/host mask
|
||||||
#[stable]
|
|
||||||
ERR_BADMASK = 415,
|
ERR_BADMASK = 415,
|
||||||
/// 421 <command> :Unknown command
|
/// 421 <command> :Unknown command
|
||||||
#[stable]
|
|
||||||
ERR_UNKNOWNCOMMAND = 421,
|
ERR_UNKNOWNCOMMAND = 421,
|
||||||
/// 422 :MOTD File is missing
|
/// 422 :MOTD File is missing
|
||||||
#[stable]
|
|
||||||
ERR_NOMOTD = 422,
|
ERR_NOMOTD = 422,
|
||||||
/// 423 <server> :No administrative info available
|
/// 423 <server> :No administrative info available
|
||||||
#[stable]
|
|
||||||
ERR_NOADMININFO = 423,
|
ERR_NOADMININFO = 423,
|
||||||
/// 424 :File error doing <file op> on <file>
|
/// 424 :File error doing <file op> on <file>
|
||||||
#[stable]
|
|
||||||
ERR_FILEERROR = 424,
|
ERR_FILEERROR = 424,
|
||||||
/// 431 :No nickname given
|
/// 431 :No nickname given
|
||||||
#[stable]
|
|
||||||
ERR_NONICKNAMEGIVEN = 431,
|
ERR_NONICKNAMEGIVEN = 431,
|
||||||
/// 432 <nick> :Erroneous nickname"
|
/// 432 <nick> :Erroneous nickname"
|
||||||
#[stable]
|
|
||||||
ERR_ERRONEOUSNICKNAME = 432,
|
ERR_ERRONEOUSNICKNAME = 432,
|
||||||
/// 433 <nick> :Nickname is already in use
|
/// 433 <nick> :Nickname is already in use
|
||||||
#[stable]
|
|
||||||
ERR_NICKNAMEINUSE = 433,
|
ERR_NICKNAMEINUSE = 433,
|
||||||
/// 436 <nick> :Nickname collision KILL from <user>@<host>
|
/// 436 <nick> :Nickname collision KILL from <user>@<host>
|
||||||
#[stable]
|
|
||||||
ERR_NICKCOLLISION = 436,
|
ERR_NICKCOLLISION = 436,
|
||||||
/// 437 <nick/channel> :Nick/channel is temporarily unavailable
|
/// 437 <nick/channel> :Nick/channel is temporarily unavailable
|
||||||
#[stable]
|
|
||||||
ERR_UNAVAILRESOURCE = 437,
|
ERR_UNAVAILRESOURCE = 437,
|
||||||
/// 441 <nick> <channel> :They aren't on that channel
|
/// 441 <nick> <channel> :They aren't on that channel
|
||||||
#[stable]
|
|
||||||
ERR_USERNOTINCHANNEL = 441,
|
ERR_USERNOTINCHANNEL = 441,
|
||||||
/// 442 <channel> :You're not on that channel
|
/// 442 <channel> :You're not on that channel
|
||||||
#[stable]
|
|
||||||
ERR_NOTONCHANNEL = 442,
|
ERR_NOTONCHANNEL = 442,
|
||||||
/// 443 <user> <channel> :is already on channel
|
/// 443 <user> <channel> :is already on channel
|
||||||
#[stable]
|
|
||||||
ERR_USERONCHANNEL = 443,
|
ERR_USERONCHANNEL = 443,
|
||||||
/// 444 <user> :User not logged in
|
/// 444 <user> :User not logged in
|
||||||
#[stable]
|
|
||||||
ERR_NOLOGIN = 444,
|
ERR_NOLOGIN = 444,
|
||||||
/// 445 :SUMMON has been disabled
|
/// 445 :SUMMON has been disabled
|
||||||
#[stable]
|
|
||||||
ERR_SUMMONDISABLED = 445,
|
ERR_SUMMONDISABLED = 445,
|
||||||
/// 446 :USERS has been disabled
|
/// 446 :USERS has been disabled
|
||||||
#[stable]
|
|
||||||
ERR_USERSDISABLED = 446,
|
ERR_USERSDISABLED = 446,
|
||||||
/// 451 :You have not registered
|
/// 451 :You have not registered
|
||||||
#[stable]
|
|
||||||
ERR_NOTREGISTERED = 451,
|
ERR_NOTREGISTERED = 451,
|
||||||
/// 461 <command> :Not enough parameters
|
/// 461 <command> :Not enough parameters
|
||||||
#[stable]
|
|
||||||
ERR_NEEDMOREPARAMS = 461,
|
ERR_NEEDMOREPARAMS = 461,
|
||||||
/// 462 :Unauthorized command (already registered)
|
/// 462 :Unauthorized command (already registered)
|
||||||
#[stable]
|
|
||||||
ERR_ALREADYREGISTRED = 462,
|
ERR_ALREADYREGISTRED = 462,
|
||||||
/// 463 :Your host isn't among the privileged
|
/// 463 :Your host isn't among the privileged
|
||||||
#[stable]
|
|
||||||
ERR_NOPERMFORHOST = 463,
|
ERR_NOPERMFORHOST = 463,
|
||||||
/// 464 :Password incorrect
|
/// 464 :Password incorrect
|
||||||
#[stable]
|
|
||||||
ERR_PASSWDMISMATCH = 464,
|
ERR_PASSWDMISMATCH = 464,
|
||||||
/// 465 :You are banned from this server
|
/// 465 :You are banned from this server
|
||||||
#[stable]
|
|
||||||
ERR_YOUREBANNEDCREEP = 465,
|
ERR_YOUREBANNEDCREEP = 465,
|
||||||
/// 466
|
/// 466
|
||||||
#[stable]
|
|
||||||
ERR_YOUWILLBEBANNED = 466,
|
ERR_YOUWILLBEBANNED = 466,
|
||||||
/// 467 <channel> :Channel key already set
|
/// 467 <channel> :Channel key already set
|
||||||
#[stable]
|
|
||||||
ERR_KEYSET = 467,
|
ERR_KEYSET = 467,
|
||||||
/// 471 <channel> :Cannot join channel (+l)
|
/// 471 <channel> :Cannot join channel (+l)
|
||||||
#[stable]
|
|
||||||
ERR_CHANNELISFULL = 471,
|
ERR_CHANNELISFULL = 471,
|
||||||
/// 472 <char> :is unknown mode char to me for <channel>
|
/// 472 <char> :is unknown mode char to me for <channel>
|
||||||
#[stable]
|
|
||||||
ERR_UNKNOWNMODE = 472,
|
ERR_UNKNOWNMODE = 472,
|
||||||
/// 473 <channel> :Cannot join channel (+i)
|
/// 473 <channel> :Cannot join channel (+i)
|
||||||
#[stable]
|
|
||||||
ERR_INVITEONLYCHAN = 473,
|
ERR_INVITEONLYCHAN = 473,
|
||||||
/// 474 <channel> :Cannot join channel (+b)
|
/// 474 <channel> :Cannot join channel (+b)
|
||||||
#[stable]
|
|
||||||
ERR_BANNEDFROMCHAN = 474,
|
ERR_BANNEDFROMCHAN = 474,
|
||||||
/// 475 <channel> :Cannot join channel (+k)
|
/// 475 <channel> :Cannot join channel (+k)
|
||||||
#[stable]
|
|
||||||
ERR_BADCHANNELKEY = 475,
|
ERR_BADCHANNELKEY = 475,
|
||||||
/// 476 <channel> :Bad Channel Mask
|
/// 476 <channel> :Bad Channel Mask
|
||||||
#[stable]
|
|
||||||
ERR_BADCHANMASK = 476,
|
ERR_BADCHANMASK = 476,
|
||||||
/// 477 <channel> :Channel doesn't support modes
|
/// 477 <channel> :Channel doesn't support modes
|
||||||
#[stable]
|
|
||||||
ERR_NOCHANMODES = 477,
|
ERR_NOCHANMODES = 477,
|
||||||
/// 478 <channel> <char> :Channel list is full
|
/// 478 <channel> <char> :Channel list is full
|
||||||
#[stable]
|
|
||||||
ERR_BANLISTFULL = 478,
|
ERR_BANLISTFULL = 478,
|
||||||
/// 481 :Permission Denied- You're not an IRC operator
|
/// 481 :Permission Denied- You're not an IRC operator
|
||||||
#[stable]
|
|
||||||
ERR_NOPRIVILEGES = 481,
|
ERR_NOPRIVILEGES = 481,
|
||||||
/// 482 <channel> :You're not channel operator
|
/// 482 <channel> :You're not channel operator
|
||||||
#[stable]
|
|
||||||
ERR_CHANOPRIVSNEEDED = 482,
|
ERR_CHANOPRIVSNEEDED = 482,
|
||||||
/// 483 :You can't kill a server!
|
/// 483 :You can't kill a server!
|
||||||
#[stable]
|
|
||||||
ERR_CANTKILLSERVER = 483,
|
ERR_CANTKILLSERVER = 483,
|
||||||
/// 484 :Your connection is restricted!
|
/// 484 :Your connection is restricted!
|
||||||
#[stable]
|
|
||||||
ERR_RESTRICTED = 484,
|
ERR_RESTRICTED = 484,
|
||||||
/// 485 :You're not the original channel operator
|
/// 485 :You're not the original channel operator
|
||||||
#[stable]
|
|
||||||
ERR_UNIQOPPRIVSNEEDED = 485,
|
ERR_UNIQOPPRIVSNEEDED = 485,
|
||||||
/// 491 :No O-lines for your host
|
/// 491 :No O-lines for your host
|
||||||
#[stable]
|
|
||||||
ERR_NOOPERHOST = 491,
|
ERR_NOOPERHOST = 491,
|
||||||
/// 501 :Unknown MODE flag
|
/// 501 :Unknown MODE flag
|
||||||
#[stable]
|
|
||||||
ERR_UMODEUNKNOWNFLAG = 501,
|
ERR_UMODEUNKNOWNFLAG = 501,
|
||||||
/// 502 :Cannot change mode for other users
|
/// 502 :Cannot change mode for other users
|
||||||
#[stable]
|
|
||||||
ERR_USERSDONTMATCH = 502,
|
ERR_USERSDONTMATCH = 502,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Gets a response from a message.
|
/// Gets a response from a message.
|
||||||
#[stable]
|
|
||||||
pub fn from_message(m: &Message) -> Option<Response> {
|
pub fn from_message(m: &Message) -> Option<Response> {
|
||||||
m.command.parse().ok()
|
m.command.parse().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines whether or not this response is an error response.
|
/// Determines whether or not this response is an error response.
|
||||||
#[stable]
|
|
||||||
pub fn is_error(&self) -> bool {
|
pub fn is_error(&self) -> bool {
|
||||||
*self as u16 >= 400
|
*self as u16 >= 400
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
//! Data for tracking user information.
|
//! Data for tracking user information.
|
||||||
#![unstable]
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::cmp::Ordering::{Less, Equal, Greater};
|
use std::cmp::Ordering::{Less, Equal, Greater};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
/// IRC User data.
|
/// IRC User data.
|
||||||
#[stable]
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
/// The user's nickname.
|
/// The user's nickname.
|
||||||
|
@ -17,10 +15,8 @@ pub struct User {
|
||||||
access_levels: Vec<AccessLevel>,
|
access_levels: Vec<AccessLevel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl User {
|
impl User {
|
||||||
/// Creates a new User.
|
/// Creates a new User.
|
||||||
#[stable]
|
|
||||||
pub fn new(name: &str) -> User {
|
pub fn new(name: &str) -> User {
|
||||||
let ranks: Vec<_> = AccessLevelIterator::new(name).collect();
|
let ranks: Vec<_> = AccessLevelIterator::new(name).collect();
|
||||||
User {
|
User {
|
||||||
|
@ -43,25 +39,21 @@ impl User {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the nickname of the user.
|
/// Gets the nickname of the user.
|
||||||
#[stable]
|
|
||||||
pub fn get_name(&self) -> &str {
|
pub fn get_name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the user's highest access level.
|
/// Gets the user's highest access level.
|
||||||
#[unstable = "API may change."]
|
|
||||||
pub fn highest_access_level(&self) -> AccessLevel {
|
pub fn highest_access_level(&self) -> AccessLevel {
|
||||||
self.highest_access_level
|
self.highest_access_level
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets all the user's access levels.
|
/// Gets all the user's access levels.
|
||||||
#[unstable = "API may change."]
|
|
||||||
pub fn access_levels(&self) -> Vec<AccessLevel> {
|
pub fn access_levels(&self) -> Vec<AccessLevel> {
|
||||||
self.access_levels.clone()
|
self.access_levels.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the user's access level.
|
/// Updates the user's access level.
|
||||||
#[unstable = "API may change."]
|
|
||||||
pub fn update_access_level(&mut self, mode: &str) {
|
pub fn update_access_level(&mut self, mode: &str) {
|
||||||
match mode {
|
match mode {
|
||||||
"+q" => self.add_access_level(AccessLevel::Owner),
|
"+q" => self.add_access_level(AccessLevel::Owner),
|
||||||
|
@ -112,26 +104,19 @@ impl PartialEq for User {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The user's access level.
|
/// The user's access level.
|
||||||
#[stable]
|
|
||||||
#[derive(Copy, PartialEq, Clone, Debug)]
|
#[derive(Copy, PartialEq, Clone, Debug)]
|
||||||
pub enum AccessLevel {
|
pub enum AccessLevel {
|
||||||
/// The channel owner (~).
|
/// The channel owner (~).
|
||||||
#[stable]
|
|
||||||
Owner,
|
Owner,
|
||||||
/// A channel administrator (&).
|
/// A channel administrator (&).
|
||||||
#[stable]
|
|
||||||
Admin,
|
Admin,
|
||||||
/// A channel operator (@),
|
/// A channel operator (@),
|
||||||
#[stable]
|
|
||||||
Oper,
|
Oper,
|
||||||
/// A channel half-oper (%),
|
/// A channel half-oper (%),
|
||||||
#[stable]
|
|
||||||
HalfOp,
|
HalfOp,
|
||||||
/// A user with voice (+),
|
/// A user with voice (+),
|
||||||
#[stable]
|
|
||||||
Voice,
|
Voice,
|
||||||
/// A normal user,
|
/// A normal user,
|
||||||
#[stable]
|
|
||||||
Member,
|
Member,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! A simple, thread-safe IRC client library.
|
//! A simple, thread-safe IRC client library.
|
||||||
#![stable]
|
|
||||||
|
|
||||||
pub mod conn;
|
pub mod conn;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
@ -7,8 +6,6 @@ pub mod server;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
//! A client-side IRC prelude, re-exporting all the necessary basics.
|
//! A client-side IRC prelude, re-exporting all the necessary basics.
|
||||||
#![unstable = "Prelude is newly added, and contents have not yet firmed up."]
|
|
||||||
|
|
||||||
pub use client::server::{IrcServer, Server};
|
pub use client::server::{IrcServer, Server};
|
||||||
pub use client::server::utils::ServerExt;
|
pub use client::server::utils::ServerExt;
|
||||||
pub use client::data::{Command, Config, Message, Response, ToMessage};
|
pub use client::data::{Command, Config, Message, Response, ToMessage};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! Interface for working with IRC Servers.
|
//! Interface for working with IRC Servers.
|
||||||
//!
|
//!
|
||||||
//! There are currently two recommended ways to work
|
//! There are currently two recommended ways to work
|
||||||
#![stable]
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
|
@ -17,28 +16,21 @@ use client::data::kinds::{IrcRead, IrcWrite};
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
/// Trait describing core Server functionality.
|
/// Trait describing core Server functionality.
|
||||||
#[stable]
|
|
||||||
pub trait Server<'a, T, U> {
|
pub trait Server<'a, T, U> {
|
||||||
/// Gets the configuration being used with this Server.
|
/// Gets the configuration being used with this Server.
|
||||||
#[stable]
|
|
||||||
fn config(&self) -> &Config;
|
fn config(&self) -> &Config;
|
||||||
/// Sends a Command to this Server.
|
/// Sends a Command to this Server.
|
||||||
#[stable]
|
|
||||||
fn send(&self, command: Command) -> Result<()>;
|
fn send(&self, command: Command) -> Result<()>;
|
||||||
/// Gets an Iterator over Messages received by this Server.
|
/// Gets an Iterator over Messages received by this Server.
|
||||||
#[stable]
|
|
||||||
fn iter(&'a self) -> ServerIterator<'a, T, U>;
|
fn iter(&'a self) -> ServerIterator<'a, T, U>;
|
||||||
/// Gets an Iterator over Commands received by this Server.
|
/// Gets an Iterator over Commands received by this Server.
|
||||||
#[unstable = "Feature is still relatively new."]
|
|
||||||
fn iter_cmd(&'a self) -> ServerCmdIterator<'a, T, U>;
|
fn iter_cmd(&'a self) -> ServerCmdIterator<'a, T, U>;
|
||||||
/// Gets a list of Users in the specified channel. This will be none if the channel is not
|
/// Gets a list of Users in the specified channel. This will be none if the channel is not
|
||||||
/// being tracked, or if tracking is not supported altogether.
|
/// being tracked, or if tracking is not supported altogether.
|
||||||
#[stable]
|
|
||||||
fn list_users(&self, channel: &str) -> Option<Vec<User>>;
|
fn list_users(&self, channel: &str) -> Option<Vec<User>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A thread-safe implementation of an IRC Server connection.
|
/// A thread-safe implementation of an IRC Server connection.
|
||||||
#[stable]
|
|
||||||
pub struct IrcServer<T: IrcRead, U: IrcWrite> {
|
pub struct IrcServer<T: IrcRead, U: IrcWrite> {
|
||||||
/// The thread-safe IRC connection.
|
/// The thread-safe IRC connection.
|
||||||
conn: Connection<T, U>,
|
conn: Connection<T, U>,
|
||||||
|
@ -51,21 +43,17 @@ pub struct IrcServer<T: IrcRead, U: IrcWrite> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An IrcServer over a buffered NetStream.
|
/// An IrcServer over a buffered NetStream.
|
||||||
#[stable]
|
|
||||||
pub type NetIrcServer = IrcServer<BufReader<NetStream>, BufWriter<NetStream>>;
|
pub type NetIrcServer = IrcServer<BufReader<NetStream>, BufWriter<NetStream>>;
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl IrcServer<BufReader<NetStream>, BufWriter<NetStream>> {
|
impl IrcServer<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
/// Creates a new IRC Server connection from the configuration at the specified path,
|
/// Creates a new IRC Server connection from the configuration at the specified path,
|
||||||
/// connecting immediately.
|
/// connecting immediately.
|
||||||
#[stable]
|
|
||||||
pub fn new(config: &str) -> Result<NetIrcServer> {
|
pub fn new(config: &str) -> Result<NetIrcServer> {
|
||||||
IrcServer::from_config(try!(Config::load_utf8(config)))
|
IrcServer::from_config(try!(Config::load_utf8(config)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new IRC server connection from the specified configuration, connecting
|
/// Creates a new IRC server connection from the specified configuration, connecting
|
||||||
/// immediately.
|
/// immediately.
|
||||||
#[stable]
|
|
||||||
pub fn from_config(config: Config) -> Result<NetIrcServer> {
|
pub fn from_config(config: Config) -> Result<NetIrcServer> {
|
||||||
let conn = try!(if config.use_ssl() {
|
let conn = try!(if config.use_ssl() {
|
||||||
Connection::connect_ssl(config.server(), config.port())
|
Connection::connect_ssl(config.server(), config.port())
|
||||||
|
@ -77,7 +65,6 @@ impl IrcServer<BufReader<NetStream>, BufWriter<NetStream>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reconnects to the IRC server.
|
/// Reconnects to the IRC server.
|
||||||
#[stable]
|
|
||||||
pub fn reconnect(&self) -> Result<()> {
|
pub fn reconnect(&self) -> Result<()> {
|
||||||
self.conn.reconnect(self.config().server(), self.config.port())
|
self.conn.reconnect(self.config().server(), self.config.port())
|
||||||
}
|
}
|
||||||
|
@ -118,17 +105,14 @@ impl<'a, T: IrcRead, U: IrcWrite> Server<'a, T, U> for IrcServer<T, U> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable]
|
|
||||||
impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> {
|
impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> {
|
||||||
/// Creates an IRC server from the specified configuration, and any arbitrary Connection.
|
/// Creates an IRC server from the specified configuration, and any arbitrary Connection.
|
||||||
#[stable]
|
|
||||||
pub fn from_connection(config: Config, conn: Connection<T, U>) -> IrcServer<T, U> {
|
pub fn from_connection(config: Config, conn: Connection<T, U>) -> IrcServer<T, U> {
|
||||||
IrcServer { conn: conn, config: config, chanlists: Mutex::new(HashMap::new()),
|
IrcServer { conn: conn, config: config, chanlists: Mutex::new(HashMap::new()),
|
||||||
alt_nick_index: RwLock::new(0) }
|
alt_nick_index: RwLock::new(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a reference to the IRC server's connection.
|
/// Gets a reference to the IRC server's connection.
|
||||||
#[stable]
|
|
||||||
pub fn conn(&self) -> &Connection<T, U> {
|
pub fn conn(&self) -> &Connection<T, U> {
|
||||||
&self.conn
|
&self.conn
|
||||||
}
|
}
|
||||||
|
@ -271,7 +255,6 @@ impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An Iterator over an IrcServer's incoming Messages.
|
/// An Iterator over an IrcServer's incoming Messages.
|
||||||
#[stable]
|
|
||||||
pub struct ServerIterator<'a, T: IrcRead, U: IrcWrite> {
|
pub struct ServerIterator<'a, T: IrcRead, U: IrcWrite> {
|
||||||
server: &'a IrcServer<T, U>
|
server: &'a IrcServer<T, U>
|
||||||
}
|
}
|
||||||
|
@ -280,10 +263,8 @@ pub struct ServerIterator<'a, T: IrcRead, U: IrcWrite> {
|
||||||
pub type ServerCmdIterator<'a, T, U> =
|
pub type ServerCmdIterator<'a, T, U> =
|
||||||
Map<ServerIterator<'a, T, U>, fn(Result<Message>) -> Result<Command>>;
|
Map<ServerIterator<'a, T, U>, fn(Result<Message>) -> Result<Command>>;
|
||||||
|
|
||||||
#[unstable = "Design is liable to change to accomodate new functionality."]
|
|
||||||
impl<'a, T: IrcRead, U: IrcWrite> ServerIterator<'a, T, U> {
|
impl<'a, T: IrcRead, U: IrcWrite> ServerIterator<'a, T, U> {
|
||||||
/// Creates a new ServerIterator for the desired IrcServer.
|
/// Creates a new ServerIterator for the desired IrcServer.
|
||||||
#[unstable = "Design is liable to change to accomodate new functionality."]
|
|
||||||
pub fn new(server: &IrcServer<T, U>) -> ServerIterator<T, U> {
|
pub fn new(server: &IrcServer<T, U>) -> ServerIterator<T, U> {
|
||||||
ServerIterator { server: server }
|
ServerIterator { server: server }
|
||||||
}
|
}
|
||||||
|
@ -302,7 +283,6 @@ impl<'a, T: IrcRead, U: IrcWrite> ServerIterator<'a, T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: IrcRead, U: IrcWrite> Iterator for ServerIterator<'a, T, U> {
|
impl<'a, T: IrcRead, U: IrcWrite> Iterator for ServerIterator<'a, T, U> {
|
||||||
#[stable]
|
|
||||||
type Item = Result<Message>;
|
type Item = Result<Message>;
|
||||||
fn next(&mut self) -> Option<Result<Message>> {
|
fn next(&mut self) -> Option<Result<Message>> {
|
||||||
let res = self.get_next_line().and_then(|msg|
|
let res = self.get_next_line().and_then(|msg|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
//! Utilities and shortcuts for working with IRC servers.
|
//! Utilities and shortcuts for working with IRC servers.
|
||||||
#![stable]
|
|
||||||
|
|
||||||
use std::io::Result;
|
use std::io::Result;
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
|
@ -11,10 +10,8 @@ use client::data::kinds::{IrcRead, IrcWrite};
|
||||||
use client::server::Server;
|
use client::server::Server;
|
||||||
|
|
||||||
/// Extensions for Server capabilities that make it easier to work directly with the protocol.
|
/// Extensions for Server capabilities that make it easier to work directly with the protocol.
|
||||||
#[unstable = "More functionality will be added."]
|
|
||||||
pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
/// Sends a NICK and USER to identify.
|
/// Sends a NICK and USER to identify.
|
||||||
#[unstable = "Capabilities requests may be moved outside of identify."]
|
|
||||||
fn identify(&self) -> Result<()> {
|
fn identify(&self) -> Result<()> {
|
||||||
// We'll issue a CAP REQ for multi-prefix support to improve access level tracking.
|
// We'll issue a CAP REQ for multi-prefix support to improve access level tracking.
|
||||||
try!(self.send(CAP(None, REQ, None, Some("multi-prefix".to_owned()))));
|
try!(self.send(CAP(None, REQ, None, Some("multi-prefix".to_owned()))));
|
||||||
|
@ -29,25 +26,21 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a PONG with the specified message.
|
/// Sends a PONG with the specified message.
|
||||||
#[stable]
|
|
||||||
fn send_pong(&self, msg: &str) -> Result<()> {
|
fn send_pong(&self, msg: &str) -> Result<()> {
|
||||||
self.send(PONG(msg.to_owned(), None))
|
self.send(PONG(msg.to_owned(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Joins the specified channel or chanlist.
|
/// Joins the specified channel or chanlist.
|
||||||
#[stable]
|
|
||||||
fn send_join(&self, chanlist: &str) -> Result<()> {
|
fn send_join(&self, chanlist: &str) -> Result<()> {
|
||||||
self.send(JOIN(chanlist.to_owned(), None))
|
self.send(JOIN(chanlist.to_owned(), None))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to oper up using the specified username and password.
|
/// Attempts to oper up using the specified username and password.
|
||||||
#[stable]
|
|
||||||
fn send_oper(&self, username: &str, password: &str) -> Result<()> {
|
fn send_oper(&self, username: &str, password: &str) -> Result<()> {
|
||||||
self.send(OPER(username.to_owned(), password.to_owned()))
|
self.send(OPER(username.to_owned(), password.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a message to the specified target.
|
/// Sends a message to the specified target.
|
||||||
#[stable]
|
|
||||||
fn send_privmsg(&self, target: &str, message: &str) -> Result<()> {
|
fn send_privmsg(&self, target: &str, message: &str) -> Result<()> {
|
||||||
for line in message.split("\r\n") {
|
for line in message.split("\r\n") {
|
||||||
try!(self.send(PRIVMSG(target.to_owned(), line.to_owned())))
|
try!(self.send(PRIVMSG(target.to_owned(), line.to_owned())))
|
||||||
|
@ -56,7 +49,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a notice to the specified target.
|
/// Sends a notice to the specified target.
|
||||||
#[stable]
|
|
||||||
fn send_notice(&self, target: &str, message: &str) -> Result<()> {
|
fn send_notice(&self, target: &str, message: &str) -> Result<()> {
|
||||||
for line in message.split("\r\n") {
|
for line in message.split("\r\n") {
|
||||||
try!(self.send(NOTICE(target.to_owned(), line.to_owned())))
|
try!(self.send(NOTICE(target.to_owned(), line.to_owned())))
|
||||||
|
@ -66,7 +58,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sets the topic of a channel or requests the current one.
|
/// Sets the topic of a channel or requests the current one.
|
||||||
/// If `topic` is an empty string, it won't be included in the message.
|
/// If `topic` is an empty string, it won't be included in the message.
|
||||||
#[unstable = "Design may change."]
|
|
||||||
fn send_topic(&self, channel: &str, topic: &str) -> Result<()> {
|
fn send_topic(&self, channel: &str, topic: &str) -> Result<()> {
|
||||||
self.send(TOPIC(channel.to_owned(), if topic.len() == 0 {
|
self.send(TOPIC(channel.to_owned(), if topic.len() == 0 {
|
||||||
None
|
None
|
||||||
|
@ -76,14 +67,12 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Kills the target with the provided message.
|
/// Kills the target with the provided message.
|
||||||
#[stable]
|
|
||||||
fn send_kill(&self, target: &str, message: &str) -> Result<()> {
|
fn send_kill(&self, target: &str, message: &str) -> Result<()> {
|
||||||
self.send(KILL(target.to_owned(), message.to_owned()))
|
self.send(KILL(target.to_owned(), message.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Kicks the listed nicknames from the listed channels with a comment.
|
/// Kicks the listed nicknames from the listed channels with a comment.
|
||||||
/// If `message` is an empty string, it won't be included in the message.
|
/// If `message` is an empty string, it won't be included in the message.
|
||||||
#[unstable = "Design may change."]
|
|
||||||
fn send_kick(&self, chanlist: &str, nicklist: &str, message: &str) -> Result<()> {
|
fn send_kick(&self, chanlist: &str, nicklist: &str, message: &str) -> Result<()> {
|
||||||
self.send(KICK(chanlist.to_owned(), nicklist.to_owned(), if message.len() == 0 {
|
self.send(KICK(chanlist.to_owned(), nicklist.to_owned(), if message.len() == 0 {
|
||||||
None
|
None
|
||||||
|
@ -94,7 +83,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Changes the mode of the target.
|
/// Changes the mode of the target.
|
||||||
/// If `modeparmas` is an empty string, it won't be included in the message.
|
/// If `modeparmas` is an empty string, it won't be included in the message.
|
||||||
#[unstable = "Design may change."]
|
|
||||||
fn send_mode(&self, target: &str, mode: &str, modeparams: &str) -> Result<()> {
|
fn send_mode(&self, target: &str, mode: &str, modeparams: &str) -> Result<()> {
|
||||||
self.send(MODE(target.to_owned(), mode.to_owned(), if modeparams.len() == 0 {
|
self.send(MODE(target.to_owned(), mode.to_owned(), if modeparams.len() == 0 {
|
||||||
None
|
None
|
||||||
|
@ -105,7 +93,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Changes the mode of the target by force.
|
/// Changes the mode of the target by force.
|
||||||
/// If `modeparams` is an empty string, it won't be included in the message.
|
/// If `modeparams` is an empty string, it won't be included in the message.
|
||||||
#[unstable = "Design may change."]
|
|
||||||
fn send_samode(&self, target: &str, mode: &str, modeparams: &str) -> Result<()> {
|
fn send_samode(&self, target: &str, mode: &str, modeparams: &str) -> Result<()> {
|
||||||
self.send(SAMODE(target.to_owned(), mode.to_owned(), if modeparams.len() == 0 {
|
self.send(SAMODE(target.to_owned(), mode.to_owned(), if modeparams.len() == 0 {
|
||||||
None
|
None
|
||||||
|
@ -115,20 +102,17 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Forces a user to change from the old nickname to the new nickname.
|
/// Forces a user to change from the old nickname to the new nickname.
|
||||||
#[stable]
|
|
||||||
fn send_sanick(&self, old_nick: &str, new_nick: &str) -> Result<()> {
|
fn send_sanick(&self, old_nick: &str, new_nick: &str) -> Result<()> {
|
||||||
self.send(SANICK(old_nick.to_owned(), new_nick.to_owned()))
|
self.send(SANICK(old_nick.to_owned(), new_nick.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invites a user to the specified channel.
|
/// Invites a user to the specified channel.
|
||||||
#[stable]
|
|
||||||
fn send_invite(&self, nick: &str, chan: &str) -> Result<()> {
|
fn send_invite(&self, nick: &str, chan: &str) -> Result<()> {
|
||||||
self.send(INVITE(nick.to_owned(), chan.to_owned()))
|
self.send(INVITE(nick.to_owned(), chan.to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Quits the server entirely with a message.
|
/// Quits the server entirely with a message.
|
||||||
/// This defaults to `Powered by Rust.` if none is specified.
|
/// This defaults to `Powered by Rust.` if none is specified.
|
||||||
#[unstable = "Design may change."]
|
|
||||||
fn send_quit(&self, msg: &str) -> Result<()> {
|
fn send_quit(&self, msg: &str) -> Result<()> {
|
||||||
self.send(QUIT(Some(if msg.len() == 0 {
|
self.send(QUIT(Some(if msg.len() == 0 {
|
||||||
"Powered by Rust.".to_owned()
|
"Powered by Rust.".to_owned()
|
||||||
|
@ -139,7 +123,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a CTCP-escaped message to the specified target.
|
/// Sends a CTCP-escaped message to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_ctcp(&self, target: &str, msg: &str) -> Result<()> {
|
fn send_ctcp(&self, target: &str, msg: &str) -> Result<()> {
|
||||||
self.send_privmsg(target, &format!("\u{001}{}\u{001}", msg)[..])
|
self.send_privmsg(target, &format!("\u{001}{}\u{001}", msg)[..])
|
||||||
|
@ -147,7 +130,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends an action command to the specified target.
|
/// Sends an action command to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_action(&self, target: &str, msg: &str) -> Result<()> {
|
fn send_action(&self, target: &str, msg: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, &format!("ACTION {}", msg)[..])
|
self.send_ctcp(target, &format!("ACTION {}", msg)[..])
|
||||||
|
@ -155,7 +137,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a finger request to the specified target.
|
/// Sends a finger request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_finger(&self, target: &str) -> Result<()> {
|
fn send_finger(&self, target: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, "FINGER")
|
self.send_ctcp(target, "FINGER")
|
||||||
|
@ -163,7 +144,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a version request to the specified target.
|
/// Sends a version request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_version(&self, target: &str) -> Result<()> {
|
fn send_version(&self, target: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, "VERSION")
|
self.send_ctcp(target, "VERSION")
|
||||||
|
@ -171,7 +151,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a source request to the specified target.
|
/// Sends a source request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_source(&self, target: &str) -> Result<()> {
|
fn send_source(&self, target: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, "SOURCE")
|
self.send_ctcp(target, "SOURCE")
|
||||||
|
@ -179,7 +158,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a user info request to the specified target.
|
/// Sends a user info request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_user_info(&self, target: &str) -> Result<()> {
|
fn send_user_info(&self, target: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, "USERINFO")
|
self.send_ctcp(target, "USERINFO")
|
||||||
|
@ -187,7 +165,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a finger request to the specified target.
|
/// Sends a finger request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_ctcp_ping(&self, target: &str) -> Result<()> {
|
fn send_ctcp_ping(&self, target: &str) -> Result<()> {
|
||||||
let time = get_time();
|
let time = get_time();
|
||||||
|
@ -196,7 +173,6 @@ pub trait ServerExt<'a, T, U>: Server<'a, T, U> {
|
||||||
|
|
||||||
/// Sends a time request to the specified target.
|
/// Sends a time request to the specified target.
|
||||||
/// This requires the CTCP feature to be enabled.
|
/// This requires the CTCP feature to be enabled.
|
||||||
#[stable]
|
|
||||||
#[cfg(feature = "ctcp")]
|
#[cfg(feature = "ctcp")]
|
||||||
fn send_time(&self, target: &str) -> Result<()> {
|
fn send_time(&self, target: &str) -> Result<()> {
|
||||||
self.send_ctcp(target, "TIME")
|
self.send_ctcp(target, "TIME")
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
//! A simple, thread-safe IRC library.
|
//! A simple, thread-safe IRC library.
|
||||||
#![crate_name = "irc"]
|
#![crate_name = "irc"]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![unstable]
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
#[cfg(feature = "ctcp")] extern crate time;
|
#[cfg(feature = "ctcp")] extern crate time;
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
//! A simple, thread-safe IRC server library.
|
//! A simple, thread-safe IRC server library.
|
||||||
#![unstable = "This has yet to be written."]
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue