From 8e493d3ac16f0845182263630d4a5acf9ad66cf5 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Wed, 11 Dec 2013 03:29:47 +0000 Subject: [PATCH] Add /msg command --- src/org/pileus/spades/Message.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/org/pileus/spades/Message.java b/src/org/pileus/spades/Message.java index 717677c..d12f42f 100644 --- a/src/org/pileus/spades/Message.java +++ b/src/org/pileus/spades/Message.java @@ -104,7 +104,7 @@ public class Message private static final String reMsg = "(:([^ ]+) +)?(([A-Z0-9]+) +)(([^ ]+)[= ]+)?(([^: ]+) *)?(:(.*))?"; private static final String reFrom = "([^! ]+)!.*"; private static final String reTo = "(([^ :,]*)[:,] *)?(.*)"; - private static final String reCmd = "/([a-z]+)( +(.*))?"; + private static final String reCmd = "/([a-z]+)(?: +([^ ]*)(?: +(.*))?)?"; private static final Pattern ptMsg = Pattern.compile(reMsg); private static final Pattern ptFrom = Pattern.compile(reFrom); @@ -210,7 +210,8 @@ public class Message return false; String cmd = notnull(mr.group(1)); - String arg = notnull(mr.group(3)); + String arg = notnull(mr.group(2)); + String txt = notnull(mr.group(3)); // Parse commands if (cmd.matches("j(oin)?")) { @@ -229,6 +230,15 @@ public class Message this.line = this.cmd + " :" + arg; } + if (cmd.matches("msg") && arg != null) { + Os.debug("Message: /msg"); + this.type = Type.PRIVMSG; + this.cmd = "PRIVMSG"; + this.dst = arg; + this.msg = txt; + this.line = this.cmd + " " + arg + " :" + txt; + } + // Print warning if command is not recognized if (this.line == null) Os.debug("Message: unknown command"); -- 2.43.2