Logger: Handle TOPIC and 332 commands
This commit is contained in:
parent
bfa355e846
commit
251962ae0f
26
logger.pm
26
logger.pm
@ -371,6 +371,30 @@ sub handleNames {
|
||||
push(@{$aLogFiles->{$aCommand->[3]}{"names"}}, @names);
|
||||
}
|
||||
|
||||
sub handleTopic {
|
||||
my $aCommand = $_[0];
|
||||
my $aServerName = $_[1];
|
||||
my $aLogFiles = $_[2];
|
||||
my $aChangedByUser = $_[3];
|
||||
|
||||
my $aCommandLength = scalar(@$aCommand);
|
||||
if($aCommandLength!=5) {
|
||||
print("[error] Encountered invalid TOPIC command (5 arguments expected, $aCommandLength provided)\n");
|
||||
return;
|
||||
}
|
||||
if(!prepareLogFile($aLogFiles, $aServerName, $aCommand->[2])) {
|
||||
return;
|
||||
}
|
||||
if($aChangedByUser) {
|
||||
my $username = getUsernameFromHost($aCommand->[4]);
|
||||
$aLogFiles->{$aCommand->[2]}{"file"}->print(sprintf("(%s) %s changed topic for channel %s to: %s\n", localtime->strftime("%H:%M:%S"), $username, $aCommand->[2], $aCommand->[3]));
|
||||
}
|
||||
else {
|
||||
$aLogFiles->{$aCommand->[2]}{"file"}->print(sprintf("(%s) Topic for channel %s: %s\n", localtime->strftime("%H:%M:%S"), $aCommand->[2], $aCommand->[3]));
|
||||
}
|
||||
$aLogFiles->{$aCommand->[2]}{"file"}->flush();
|
||||
}
|
||||
|
||||
our @connections :shared;
|
||||
our $running :shared = 1;
|
||||
|
||||
@ -419,8 +443,10 @@ sub connectionWorker {
|
||||
when("QUIT") { handleQuit(\@command, $aServerName, \%logFiles); }
|
||||
when("PART") { handlePart(\@command, $aServerName, \%logFiles); }
|
||||
when("NICK") { handleNick(\@command, $aServerName, \%logFiles); }
|
||||
when("TOPIC") { handleTopic(\@command, $aServerName, \%logFiles, 1); }
|
||||
when("376") { joinChannels($stream, $aChannels); } # end of MOTD
|
||||
when("353") { handleNames(\@command, $aChannels, \%logFiles); } # NAMES reply
|
||||
when("332") { handleTopic(\@command, $aServerName, \%logFiles, 0); } # TOPIC reply
|
||||
}
|
||||
($line, $remaining) = readLineFromBuffer($buffer);
|
||||
$buffer = $remaining;
|
||||
|
Loading…
Reference in New Issue
Block a user