Add ProjectZomboidAdminLog (admin.txt)
Free-form English message body with verb-dispatched analyser regexes (ADDED_ITEM, ADDED_XP, GRANTED_ACCESS, CHANGED_OPTION, RELOADED_OPTIONS, TELEPORTED). Parser captures only the timestamp, since the admin name itself can include parentheses or whitespace. Detectors: filename match plus content signatures on 'added item Base.X in Y's inventory' and 'granted ROLE access level on'.
This commit is contained in:
47
src/Log/ProjectZomboid/ProjectZomboidAdminLog.php
Normal file
47
src/Log/ProjectZomboid/ProjectZomboidAdminLog.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace IndifferentKetchup\Codex\Log\ProjectZomboid;
|
||||
|
||||
use IndifferentKetchup\Codex\Analyser\AnalyserInterface;
|
||||
use IndifferentKetchup\Codex\Analyser\PatternAnalyser;
|
||||
use IndifferentKetchup\Codex\Detective\FilenameDetector;
|
||||
use IndifferentKetchup\Codex\Detective\WeightedSinglePatternDetector;
|
||||
use IndifferentKetchup\Codex\Parser\ParserInterface;
|
||||
use IndifferentKetchup\Codex\Parser\PatternParser;
|
||||
use IndifferentKetchup\Codex\Pattern\ProjectZomboid\AdminPattern;
|
||||
|
||||
class ProjectZomboidAdminLog extends ProjectZomboidEventLog
|
||||
{
|
||||
public static function getDefaultParser(): ParserInterface
|
||||
{
|
||||
return static::makePatternParser(
|
||||
AdminPattern::LINE,
|
||||
[PatternParser::TIME]
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDefaultAnalyser(): AnalyserInterface
|
||||
{
|
||||
return new PatternAnalyser();
|
||||
}
|
||||
|
||||
public static function getDetectors(): array
|
||||
{
|
||||
return [
|
||||
(new FilenameDetector())
|
||||
->setPattern('/_admin\.txt$/')
|
||||
->setWeight(0.95),
|
||||
(new WeightedSinglePatternDetector())
|
||||
->setPattern('/^\[[^\]]+\] .+? added item Base\.\S+ in .+?\'s inventory/m')
|
||||
->setWeight(0.90),
|
||||
(new WeightedSinglePatternDetector())
|
||||
->setPattern('/^\[[^\]]+\] .+? granted (?:admin|user|moderator|gm|observer) access level on /m')
|
||||
->setWeight(0.85),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return "Project Zomboid Admin Log";
|
||||
}
|
||||
}
|
||||
28
src/Pattern/ProjectZomboid/AdminPattern.php
Normal file
28
src/Pattern/ProjectZomboid/AdminPattern.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace IndifferentKetchup\Codex\Pattern\ProjectZomboid;
|
||||
|
||||
/**
|
||||
* Regex constants for the Project Zomboid admin.txt format.
|
||||
*
|
||||
* Free-form English: '[time] <admin> <verb> ...' Verb dispatch is left
|
||||
* to the analyser layer. The admin name itself can contain parentheses
|
||||
* (Nathan(Weerd)) or whitespace (silly goose) so the parser captures
|
||||
* only the timestamp.
|
||||
*/
|
||||
class AdminPattern
|
||||
{
|
||||
public const string LINE = '/^\[(\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3})\] .+\.$/';
|
||||
|
||||
public const string ADDED_ITEM = '/^(?<admin>.+?) added item (?<item>Base\.\S+) in (?<target>.+?)\'s inventory$/';
|
||||
|
||||
public const string ADDED_XP = '/^(?<admin>.+?) added (?<amount>[\d.]+) (?<skill>\S+) xp\'s to (?<target>.+)$/';
|
||||
|
||||
public const string GRANTED_ACCESS = '/^(?<admin>.+?) granted (?<level>\w+) access level on (?<target>.+)$/';
|
||||
|
||||
public const string CHANGED_OPTION = '/^(?<admin>.+?) changed option (?<option>\S+?)=(?<value>.+)$/';
|
||||
|
||||
public const string RELOADED_OPTIONS = '/^(?<admin>.+?) reloaded options$/';
|
||||
|
||||
public const string TELEPORTED = '/^(?<admin>.+?) teleported (?<target>.+?) to (?<x>\d+),(?<y>\d+),(?<z>-?\d+)$/';
|
||||
}
|
||||
Reference in New Issue
Block a user