//setup our DI
IServiceCollection services = new ServiceCollection().AddGameClientMonitor();
//setup provider
using(IServiceProvider serviceProvider = services.BuildServiceProvider())
{
// resolve INotificationMonitor
INotificationMonitor monitor = serviceProvider.GetService<INotificationMonitor>();
// subscribe to event
monitor.NotificationReceived += (sender, args) =>
{
// handle required case
if(args.Notification is AfkNotification afkNotification)
{
Console.WriteLine(afkNotification.IsActive ? "Hey wake up!" : "AFK disabled");
}
}
}
You can configure INotificationMonitor by using optional parameter of dependency injection extension method:
services.AddGameClientMonitor(config =>
{
config.ClientTxtPath = @"D:\Steam\steamapps\common\Path of Exile\logs\Client.txt";
config.IsOnlyFirstMatchHandled = true;
config.UseDefaultMatchings = false;
config.NotificationMatches = new []{ YourNotificationMath, AnotherNotificationMatch }
});
ClientTxtPath
: custom path to Client.txt- default:
"C:\Program Files\Steam\steamapps\common\Path of Exile\logs\Client.txt"
- default:
IsOnlyFirstMatchHandled
: whether monitor stops processing log line after meeting first match- default:
true
- default:
UseDefaultMatchings
: whether default matching rules are registered (see Supported Matching Rules below)- default:
true
- default:
NotificationMatches
: collection of custom matching rules (see Custom Matching Rules below)- default:
null
- default:
- Area enter - location name
- AFK on/off - is enabled
- Level up - login, level
- Chat Message -
- Local, Global, Trade, Guild, Party, Whisper
- Player joined/left the area
- Trade templates based on poe.trade and map exchange services
- Kitavas Affliction (resistatnce penalty)
Planned in the near future:
- NPC dialoges (chat messages with additional filter on constant names)
- error notifications with additional filter for "Disconnected from server"
It is possible to write and register custom matching rules based on regular expression and capturing group mapping. This feature allows to handle specific cases like trade message, map exchange or bulk purchase templates.
INotificationMatch notificaionMatch = new NotificationMatch
(
regex: new Regex(@"Connect time to instance server was (\d*)ms"),
onMap: (groups, metadata) => new ConnectionNotification(int.Parse(groups[1].Value), metadata)
);
...
class ConnectionNotification : BaseNotification
{
public int ConnectTime { get; }
public ConnectionNotification(int connectTime, LogMetadata metadata) : base(metadata)
{
ConnectTime = connectTime;
}
}
...
// subscribe to event
monitor.NotificationReceived += (sender, args) =>
{
// handle required case
if(args.Notification is ConnectionNotification connectionNotification)
{
Console.WriteLine($"Your connect time was {connectionNotification.ConnectTime} ms");
}
}