forked from lavina/lavina
fix irc parsing
it's not required to start trailing arg with : if it doesn't contain spaces
This commit is contained in:
parent
daf05869a3
commit
8efbacc4d0
|
@ -1,5 +1,7 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
use nom::combinator::opt;
|
||||||
|
|
||||||
/// Client-to-server command.
|
/// Client-to-server command.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ClientMessage {
|
pub enum ClientMessage {
|
||||||
|
@ -121,8 +123,12 @@ fn client_message_user(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
let (input, _) = receiver(input)?;
|
let (input, _) = receiver(input)?;
|
||||||
let (input, _) = tag(" ")(input)?;
|
let (input, _) = tag(" ")(input)?;
|
||||||
let (input, _) = receiver(input)?;
|
let (input, _) = receiver(input)?;
|
||||||
let (input, _) = tag(" :")(input)?;
|
let (input, _) = tag(" ")(input)?;
|
||||||
let (input, realname) = token(input)?;
|
let (input, r) = opt(tag(":"))(input)?;
|
||||||
|
let (input, realname) = match r {
|
||||||
|
Some(_) => token(input)?,
|
||||||
|
None => receiver(input)?,
|
||||||
|
};
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
input,
|
input,
|
||||||
|
@ -156,8 +162,12 @@ fn client_message_who(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
fn client_message_topic(input: &str) -> IResult<&str, ClientMessage> {
|
fn client_message_topic(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
let (input, _) = tag("TOPIC ")(input)?;
|
let (input, _) = tag("TOPIC ")(input)?;
|
||||||
let (input, chan) = chan(input)?;
|
let (input, chan) = chan(input)?;
|
||||||
let (input, _) = tag(" :")(input)?;
|
let (input, _) = tag(" ")(input)?;
|
||||||
let (input, topic) = token(input)?;
|
let (input, r) = opt(tag(":"))(input)?;
|
||||||
|
let (input, topic) = match r {
|
||||||
|
Some(_) => token(input)?,
|
||||||
|
None => receiver(input)?,
|
||||||
|
};
|
||||||
|
|
||||||
let topic = topic.into();
|
let topic = topic.into();
|
||||||
Ok((input, ClientMessage::Topic { chan, topic }))
|
Ok((input, ClientMessage::Topic { chan, topic }))
|
||||||
|
@ -166,8 +176,12 @@ fn client_message_topic(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
fn client_message_part(input: &str) -> IResult<&str, ClientMessage> {
|
fn client_message_part(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
let (input, _) = tag("PART ")(input)?;
|
let (input, _) = tag("PART ")(input)?;
|
||||||
let (input, chan) = chan(input)?;
|
let (input, chan) = chan(input)?;
|
||||||
let (input, _) = tag(" :")(input)?;
|
let (input, _) = tag(" ")(input)?;
|
||||||
let (input, message) = token(input)?;
|
let (input, r) = opt(tag(":"))(input)?;
|
||||||
|
let (input, message) = match r {
|
||||||
|
Some(_) => token(input)?,
|
||||||
|
None => receiver(input)?,
|
||||||
|
};
|
||||||
|
|
||||||
let message = message.into();
|
let message = message.into();
|
||||||
Ok((input, ClientMessage::Part { chan, message }))
|
Ok((input, ClientMessage::Part { chan, message }))
|
||||||
|
@ -176,8 +190,12 @@ fn client_message_part(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
fn client_message_privmsg(input: &str) -> IResult<&str, ClientMessage> {
|
fn client_message_privmsg(input: &str) -> IResult<&str, ClientMessage> {
|
||||||
let (input, _) = tag("PRIVMSG ")(input)?;
|
let (input, _) = tag("PRIVMSG ")(input)?;
|
||||||
let (input, recipient) = recipient(input)?;
|
let (input, recipient) = recipient(input)?;
|
||||||
let (input, _) = tag(" :")(input)?;
|
let (input, _) = tag(" ")(input)?;
|
||||||
let (input, body) = token(input)?;
|
let (input, r) = opt(tag(":"))(input)?;
|
||||||
|
let (input, body) = match r {
|
||||||
|
Some(_) => token(input)?,
|
||||||
|
None => receiver(input)?,
|
||||||
|
};
|
||||||
|
|
||||||
let body = body.into();
|
let body = body.into();
|
||||||
Ok((input, ClientMessage::PrivateMessage { recipient, body }))
|
Ok((input, ClientMessage::PrivateMessage { recipient, body }))
|
||||||
|
|
Loading…
Reference in New Issue