2018-04-08 14:48:40 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using SharedLibraryCore;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Dtos;
|
2018-04-08 14:48:40 -04:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-04-08 02:44:42 -04:00
|
|
|
|
using SharedLibraryCore.Objects;
|
2018-03-09 03:01:12 -05:00
|
|
|
|
|
2018-04-08 14:48:40 -04:00
|
|
|
|
namespace IW4MAdmin.Application.API
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
2018-04-08 14:48:40 -04:00
|
|
|
|
class EventApi : IEventApi
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
2018-04-08 14:48:40 -04:00
|
|
|
|
Queue<EventInfo> Events = new Queue<EventInfo>();
|
|
|
|
|
DateTime LastFlagEvent;
|
2018-03-09 03:01:12 -05:00
|
|
|
|
static string[] FlaggedMessageContains =
|
|
|
|
|
{
|
|
|
|
|
" wh ",
|
|
|
|
|
"hax",
|
|
|
|
|
"cheat",
|
|
|
|
|
" hack ",
|
|
|
|
|
"aim",
|
|
|
|
|
"wall",
|
|
|
|
|
"cheto",
|
|
|
|
|
"hak",
|
|
|
|
|
"bot"
|
|
|
|
|
};
|
2018-04-08 14:48:40 -04:00
|
|
|
|
int FlaggedMessageCount;
|
|
|
|
|
|
|
|
|
|
public Queue<EventInfo> GetEvents() => Events;
|
2018-03-09 03:01:12 -05:00
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
public void OnServerEvent(object sender, GameEvent E)
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
2018-04-13 02:32:30 -04:00
|
|
|
|
if (E.Type == GameEvent.EventType.Say && E.Origin.Level < Player.Permission.Trusted)
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
|
|
|
|
bool flaggedMessage = false;
|
|
|
|
|
foreach (string msg in FlaggedMessageContains)
|
|
|
|
|
flaggedMessage = flaggedMessage ? flaggedMessage : E.Data.ToLower().Contains(msg);
|
|
|
|
|
|
|
|
|
|
if (flaggedMessage)
|
|
|
|
|
FlaggedMessageCount++;
|
|
|
|
|
|
|
|
|
|
if (FlaggedMessageCount > 3)
|
|
|
|
|
{
|
|
|
|
|
if (Events.Count > 20)
|
|
|
|
|
Events.Dequeue();
|
|
|
|
|
|
|
|
|
|
FlaggedMessageCount = 0;
|
|
|
|
|
|
2018-04-24 18:01:27 -04:00
|
|
|
|
E.Owner.Broadcast(Utilities.CurrentLocalization.LocalizationSet["GLOBAL_REPORT"]).Wait();
|
2018-04-08 02:44:42 -04:00
|
|
|
|
Events.Enqueue(new EventInfo(
|
|
|
|
|
EventInfo.EventType.ALERT,
|
|
|
|
|
EventInfo.EventVersion.IW4MAdmin,
|
2018-03-09 03:01:12 -05:00
|
|
|
|
"Chat indicates there may be a cheater",
|
|
|
|
|
"Alert",
|
|
|
|
|
E.Owner.Hostname, ""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((DateTime.UtcNow - LastFlagEvent).Minutes >= 3)
|
|
|
|
|
{
|
|
|
|
|
FlaggedMessageCount = 0;
|
|
|
|
|
LastFlagEvent = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 02:32:30 -04:00
|
|
|
|
if (E.Type == GameEvent.EventType.Report)
|
2018-03-09 03:01:12 -05:00
|
|
|
|
{
|
2018-04-08 02:44:42 -04:00
|
|
|
|
Events.Enqueue(new EventInfo(
|
|
|
|
|
EventInfo.EventType.ALERT,
|
|
|
|
|
EventInfo.EventVersion.IW4MAdmin,
|
2018-03-09 03:01:12 -05:00
|
|
|
|
$"**{E.Origin.Name}** has reported **{E.Target.Name}** for: {E.Data.Trim()}",
|
|
|
|
|
E.Target.Name, E.Origin.Name, ""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|