Skip to content

Commit

Permalink
make things clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyrot committed Oct 2, 2012
1 parent 203d81e commit 2d3308a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions parser_eggdrop.php
Expand Up @@ -76,8 +76,8 @@ protected function parse_line($line)
/**
* "Mode" lines.
*/
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] [#&!+]\S+: mode change \'(?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks>\S+( \S+)*)\' by (?<nick>\S+?)(!(\S+)?)?$/', $line, $matches)) {
$nicks = explode(' ', $matches['nicks']);
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] [#&!+]\S+: mode change \'(?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks_undergoing>\S+( \S+)*)\' by (?<nick_performing>\S+?)(!(\S+)?)?$/', $line, $matches)) {
$nicks_undergoing = explode(' ', $matches['nicks_undergoing']);
$modenum = 0;

for ($i = 0, $j = strlen($matches['modes']); $i < $j; $i++) {
Expand All @@ -86,7 +86,7 @@ protected function parse_line($line)
if ($mode == '-' || $mode == '+') {
$modesign = $mode;
} else {
$this->set_mode($this->date.' '.$matches['time'], $matches['nick'], $nicks[$modenum], $modesign.$mode);
$this->set_mode($this->date.' '.$matches['time'], $matches['nick_performing'], $nicks_undergoing[$modenum], $modesign.$mode);
$modenum++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions parser_hexchat.php
Expand Up @@ -28,7 +28,7 @@
* | Part | * NICK (HOST) has left CHAN (MSG) | Part message may be absent, or empty due to normalization.
* | Quit | * NICK has quit (MSG) | Quit message may be empty due to normalization.
* | Mode | * NICK gives channel operator status to NICK NICK | Only check for ops (channel operator status) and voices.
* | Mode | * NICK removes voice from NICK NICK |
* | Mode | * NICK removes voice from NICK NICK | "
* | Topic | * NICK has changed the topic to: MSG | Skip empty topics.
* | Kick | * NICK has kicked NICK from CHAN (MSG) | Kick message may be empty due to normalization.
* +------------+-------------------------------------------------------+->
Expand All @@ -37,7 +37,7 @@
* - normalize_line() scrubs all lines before passing them on to parse_line().
* - The way HexChat logs actions is pretty dumb, we can spoof nearly all other line types with our actions. Even non-chat messages are logged with the same
* syntax. For this reason we won't parse for actions.
* - Given that nicks can't contain "<", ">" or ":" the order of the regular expressions below is irrelevant (current order aims for best performance).
* - The order of the regular expressions below is irrelevant (current order aims for best performance).
* - The most common channel prefixes are "#&!+".
*/
final class parser_hexchat extends parser
Expand Down
11 changes: 6 additions & 5 deletions parser_irssi.php
Expand Up @@ -37,11 +37,12 @@
*
* Notes:
* - normalize_line() scrubs all lines before passing them on to parse_line().
* - The order of the regular expressions below is irrelevant (current order aims for best performance).
* - Given that nicks can't contain "/" or any of the channel prefixes, the order of the regular expressions below is irrelevant (current order aims for best
* performance).
* - We have to be mindful that nicks can contain "[" and "]".
* - The most common channel prefixes are "#&!+" and the most common nick prefixes are "~&@%+!*". If one of the nick prefixes slips through then validate_nick()
* will fail.
* - Irssi may log multiple "performing" nicks separated by commas. We use only the first one.
* - Irssi may log multiple "performing" nicks in "mode" lines separated by commas. We use only the first one.
* - In certain cases $matches[] won't contain index items if these optionally appear at the end of a line. We use empty() to check whether an index item is
* both set and has a value.
*/
Expand Down Expand Up @@ -73,8 +74,8 @@ protected function parse_line($line)
/**
* "Mode" lines.
*/
} elseif (preg_match('/^(?<time>\d{2}:\d{2}(:\d{2})?) -!- (ServerMode|mode)\/[#&!+]\S+ \[(?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks>\S+( \S+)*)\] by (?<nick>\S+)(, \S+)*$/', $line, $matches)) {
$nicks = explode(' ', $matches['nicks']);
} elseif (preg_match('/^(?<time>\d{2}:\d{2}(:\d{2})?) -!- (ServerMode|mode)\/[#&!+]\S+ \[(?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks_undergoing>\S+( \S+)*)\] by (?<nick_performing>\S+)(, \S+)*$/', $line, $matches)) {
$nicks_undergoing = explode(' ', $matches['nicks_undergoing']);
$modenum = 0;

for ($i = 0, $j = strlen($matches['modes']); $i < $j; $i++) {
Expand All @@ -83,7 +84,7 @@ protected function parse_line($line)
if ($mode == '-' || $mode == '+') {
$modesign = $mode;
} else {
$this->set_mode($this->date.' '.$matches['time'], $matches['nick'], $nicks[$modenum], $modesign.$mode);
$this->set_mode($this->date.' '.$matches['time'], $matches['nick_performing'], $nicks_undergoing[$modenum], $modesign.$mode);
$modenum++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions parser_mirc6.php
Expand Up @@ -72,8 +72,8 @@ protected function parse_line($line)
/**
* "Mode" lines.
*/
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] \* (?<nick>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks>\S+( \S+)*)$/', $line, $matches)) {
$nicks = explode(' ', $matches['nicks']);
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] \* (?<nick_performing>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks_undergoing>\S+( \S+)*)$/', $line, $matches)) {
$nicks_undergoing = explode(' ', $matches['nicks_undergoing']);
$modenum = 0;

for ($i = 0, $j = strlen($matches['modes']); $i < $j; $i++) {
Expand All @@ -82,7 +82,7 @@ protected function parse_line($line)
if ($mode == '-' || $mode == '+') {
$modesign = $mode;
} else {
$this->set_mode($this->date.' '.$matches['time'], $matches['nick'], $nicks[$modenum], $modesign.$mode);
$this->set_mode($this->date.' '.$matches['time'], $matches['nick_performing'], $nicks_undergoing[$modenum], $modesign.$mode);
$modenum++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions parser_muh2.php
Expand Up @@ -68,8 +68,8 @@ protected function parse_line($line)
/**
* "Mode" lines.
*/
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] \*\*\* (?<nick>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks>\S+( \S+)*)$/', $line, $matches)) {
$nicks = explode(' ', $matches['nicks']);
} elseif (preg_match('/^\[(?<time>\d{2}:\d{2}(:\d{2})?)\] \*\*\* (?<nick_performing>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks_undergoing>\S+( \S+)*)$/', $line, $matches)) {
$nicks_undergoing = explode(' ', $matches['nicks_undergoing']);
$modenum = 0;

for ($i = 0, $j = strlen($matches['modes']); $i < $j; $i++) {
Expand All @@ -78,7 +78,7 @@ protected function parse_line($line)
if ($mode == '-' || $mode == '+') {
$modesign = $mode;
} else {
$this->set_mode($this->date.' '.$matches['time'], $matches['nick'], $nicks[$modenum], $modesign.$mode);
$this->set_mode($this->date.' '.$matches['time'], $matches['nick_performing'], $nicks_undergoing[$modenum], $modesign.$mode);
$modenum++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions parser_supybot.php
Expand Up @@ -69,8 +69,8 @@ protected function parse_line($line)
/**
* "Mode" lines.
*/
} elseif (preg_match('/^\d{4}-\d{2}-\d{2}T(?<time>\d{2}:\d{2}:\d{2}) \*\*\* (?<nick>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks>\S+( \S+)*)$/', $line, $matches)) {
$nicks = explode(' ', $matches['nicks']);
} elseif (preg_match('/^\d{4}-\d{2}-\d{2}T(?<time>\d{2}:\d{2}:\d{2}) \*\*\* (?<nick_performing>\S+) sets mode: (?<modes>[-+][ov]+([-+][ov]+)?) (?<nicks_undergoing>\S+( \S+)*)$/', $line, $matches)) {
$nicks_undergoing = explode(' ', $matches['nicks_undergoing']);
$modenum = 0;

for ($i = 0, $j = strlen($matches['modes']); $i < $j; $i++) {
Expand All @@ -79,7 +79,7 @@ protected function parse_line($line)
if ($mode == '-' || $mode == '+') {
$modesign = $mode;
} else {
$this->set_mode($this->date.' '.$matches['time'], $matches['nick'], $nicks[$modenum], $modesign.$mode);
$this->set_mode($this->date.' '.$matches['time'], $matches['nick_performing'], $nicks_undergoing[$modenum], $modesign.$mode);
$modenum++;
}
}
Expand Down

0 comments on commit 2d3308a

Please sign in to comment.