Skip to content

Commit

Permalink
Fixed the PRIVMSG/NOTICE parser bug (issue #14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlinc committed Apr 30, 2012
1 parent 063361f commit 97e32c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Parser/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __invoke($rawdata)
sscanf($rawdata, 'PING :%[ -~]', $cmd->code);
} elseif ($tmp[0] == 'NOTICE' || $tmp[1] == 'NOTICE') {
$cmd = new \Ircbot\Command\Notice;
preg_match('/^(:(?P<sender>.+) )?NOTICE (?P<target>.+) :(?P<message>.*)$/', $rawdata, $matches);
preg_match('/^(:(?P<sender>.+) )?NOTICE (?P<target>.+) :(?P<message>.[^ ]+)$/', $rawdata, $matches);
$cmd->sender = $matches['sender'];
$cmd->target = $matches['target'];
$cmd->message = $matches['message'];
Expand Down Expand Up @@ -48,7 +48,8 @@ public function __invoke($rawdata)
sscanf($rawdata, ':%s QUIT :%[ -~]', $cmd->mask, $cmd->message);
} elseif ($tmp[1] == 'PRIVMSG') {
$cmd = new \Ircbot\Command\PrivMsg;
preg_match('/^:(.+) PRIVMSG (.+) :(.*)$/', $rawdata, $matches);
preg_match('/^:(.+) PRIVMSG (.[^ ]+) :(.*)$/', $rawdata, $matches);
var_dump($matches);
list(, $cmd->sender, $cmd->target, $cmd->message) = $matches;
if (($cmd->message[0] == chr(1))
&& ($cmd->message[strlen($cmd->message) - 1] == chr(1))) {
Expand Down

0 comments on commit 97e32c5

Please sign in to comment.