IW4M-Admin/Admin/Event.cs
RaidMax c3bf5bf33a Been a while -- unstable 0.75
-added mask command
-added baninfo command
-added alias command and removed redundant output from `find`
-added rcon command
-added webfront (http://127.0.0.1:1624)
-true skill is officially implemented
-find now shows last connect time
-noise on pm (if gsc_enabled)
-force 8 line chat height (if gsc_enabled)
-tell admins the number of reports on join
-enhanced ban tracking
-ip wait timeout added
-remove report on ban
-can't report yourself
-remove reported players when banned
-fixed rare crash with toadmins backend
-fixed crash when finding player stats that don't exist
-fixed a bug that caused owner command to reactivate only `creator` rank player existed
-fixed a bug that caused certain notifications to be sent to all players
2015-04-09 23:02:12 -05:00

111 lines
3.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace IW4MAdmin
{
class Event
{
public enum GType
{
//FROM SERVER
Connect,
Disconnect,
Say,
Kill,
Death,
MapChange,
MapEnd,
//FROM ADMIN
Broadcast,
Tell,
Kick,
Ban,
Unknown,
}
public Event(GType t, string d, Player O, Player T, Server S)
{
Type = t;
Data = d;
Origin = O;
Target = T;
Owner = S;
}
//This needs to be here
public Command isValidCMD(List<Command> list)
{
if (this.Data.Substring(0, 1) == "!")
{
string[] cmd = this.Data.Substring(1, this.Data.Length - 1).Split(' ');
foreach (Command C in list)
{
if (C.getName() == cmd[0].ToLower() || C.getAlias() == cmd[0].ToLower())
return C;
}
return null;
}
else
return null;
}
public static Event requestEvent(String[] line, Server SV)
{
#if DEBUG == false
try
#endif
{
String eventType = line[0].Substring(line[0].Length - 1);
eventType = eventType.Trim();
if (eventType == "J")
return new Event(GType.Connect, null, SV.clientFromEventLine(line, 2), null, SV);
if (eventType == "Q")
return new Event(GType.Disconnect, null, SV.clientFromEventLine(line, 2), null, SV);
if (eventType == "K")
return new Event(GType.Kill, line[9], SV.clientFromEventLine(line, 6), SV.clientFromEventLine(line, 2), SV);
if (line[0].Substring(line[0].Length - 3).Trim() == "say")
{
Regex rgx = new Regex("[^a-zA-Z0-9 -! -_]");
string message = rgx.Replace(line[4], "");
return new Event(GType.Say, Utilities.removeNastyChars(message), SV.clientFromEventLine(line, 2), null, SV);
}
if (eventType == ":")
return new Event(GType.MapEnd, null, null, null, null);
if (line[0].Length > 400) // blaze it
return new Event(GType.MapChange, line[0], null, null, null);
return null;
}
#if DEBUG == false
catch (Exception E)
{
SV.Log.Write("Error requesting event " + E.Message, Log.Level.Debug);
return null;
}
#endif
}
public GType Type;
public string Data; // Data is usually the message sent by player
public Player Origin;
public Player Target;
public Server Owner;
}
}