mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
Finally stopped the "error on character" printout (removed console.writeline in Kayak submodule)
Fixed console execute button cascading on IE/Edge Fixed reports truncating reason if space in target name If multiple matches are found when finding a player, a list of matches is shown Reallowed special characters in names/chat stats command player isn't required Added prune command
This commit is contained in:
@ -151,7 +151,7 @@ namespace SharedLibrary.Commands
|
||||
},
|
||||
new CommandArgument()
|
||||
{
|
||||
Name = "duration (m|d|w|y|)",
|
||||
Name = "duration (m|h|d|w|y)",
|
||||
Required = true,
|
||||
},
|
||||
new CommandArgument()
|
||||
@ -193,8 +193,8 @@ namespace SharedLibrary.Commands
|
||||
},
|
||||
new CommandArgument()
|
||||
{
|
||||
Name = "reason",
|
||||
Required = true
|
||||
Name = "reason",
|
||||
Required = true
|
||||
}
|
||||
})
|
||||
{ }
|
||||
@ -247,7 +247,7 @@ namespace SharedLibrary.Commands
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientID, E.Origin.NetworkID, E.Origin.DatabaseID, SharedLibrary.Utilities.ConvertLevelToColor(E.Origin.Level), E.Origin.IP);
|
||||
String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientID, E.Origin.NetworkID, E.Origin.DatabaseID, Utilities.ConvertLevelToColor(E.Origin.Level), E.Origin.IP);
|
||||
await E.Origin.Tell(You);
|
||||
}
|
||||
}
|
||||
@ -663,8 +663,9 @@ namespace SharedLibrary.Commands
|
||||
|
||||
public class CReload : Command
|
||||
{
|
||||
public CReload() :
|
||||
base("reload", "reload configuration files", "rl", Player.Permission.Owner, false) { }
|
||||
public CReload() :
|
||||
base("reload", "reload configuration files", "rl", Player.Permission.Owner, false)
|
||||
{ }
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
@ -755,14 +756,14 @@ namespace SharedLibrary.Commands
|
||||
|
||||
if (E.Target.Level > E.Origin.Level)
|
||||
{
|
||||
await E.Origin.Tell("You cannot report " + E.Target.Name);
|
||||
await E.Origin.Tell($"You cannot report {E.Target.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
E.Data = E.Data.RemoveWords(1);
|
||||
E.Owner.Reports.Add(new Report(E.Target, E.Origin, E.Data));
|
||||
|
||||
await E.Origin.Tell("Successfully reported " + E.Target.Name);
|
||||
await E.Origin.Tell($"Successfully reported {E.Target.Name}");
|
||||
await E.Owner.ExecuteEvent(new Event(Event.GType.Report, E.Data, E.Origin, E.Target, E.Owner));
|
||||
await E.Owner.ToAdmins(String.Format("^5{0}^7->^1{1}^7: {2}", E.Origin.Name, E.Target.Name, E.Data));
|
||||
}
|
||||
@ -831,8 +832,8 @@ namespace SharedLibrary.Commands
|
||||
{
|
||||
new CommandArgument()
|
||||
{
|
||||
Name = "player",
|
||||
Required = true
|
||||
Name = "player",
|
||||
Required = true
|
||||
}
|
||||
})
|
||||
{ }
|
||||
|
@ -564,7 +564,7 @@ namespace SharedLibrary
|
||||
{
|
||||
Dictionary<String, object> newPlayer = new Dictionary<String, object>
|
||||
{
|
||||
{ "Name", Utilities.StripIllegalCharacters(P.Name) },
|
||||
{ "Name", P.Name },
|
||||
{ "npID", P.NetworkID },
|
||||
{ "Level", (int)P.Level },
|
||||
{ "LastOffense", "" },
|
||||
@ -596,12 +596,17 @@ namespace SharedLibrary
|
||||
}
|
||||
|
||||
|
||||
public void PruneAdmins(int inactiveDays)
|
||||
{
|
||||
ExecuteNonQuery($"UPDATE CLIENTS SET Level={(int)Player.Permission.User} WHERE LastConnection < '{Utilities.DateTimeSQLite(DateTime.Now.AddDays(-inactiveDays))}'");
|
||||
}
|
||||
|
||||
//Add specified ban to database
|
||||
public void AddPenalty(Penalty B)
|
||||
{
|
||||
Dictionary<String, object> newBan = new Dictionary<String, object>
|
||||
{
|
||||
{ "Reason", Utilities.StripIllegalCharacters(B.Reason) },
|
||||
{ "Reason", B.Reason },
|
||||
{ "npID", B.OffenderID },
|
||||
{ "bannedByID", B.PenaltyOriginID },
|
||||
{ "IP", B.IP },
|
||||
@ -712,7 +717,7 @@ namespace SharedLibrary
|
||||
Dictionary<String, object> newPlayer = new Dictionary<String, object>
|
||||
{
|
||||
{ "Number", Alias.Number },
|
||||
{ "NAMES", Utilities.StripIllegalCharacters(String.Join(";", Alias.Names)) },
|
||||
{ "NAMES", String.Join(";", Alias.Names) },
|
||||
{ "IPS", String.Join(";", Alias.IPS) }
|
||||
};
|
||||
Insert("ALIASES", newPlayer);
|
||||
|
@ -29,10 +29,10 @@ namespace SharedLibrary
|
||||
{
|
||||
Type = Ty;
|
||||
Version = V;
|
||||
Message = M;
|
||||
Message = System.Web.HttpUtility.HtmlEncode(M);
|
||||
Title = T;
|
||||
Origin = O;
|
||||
Target = Ta;
|
||||
Origin = System.Web.HttpUtility.HtmlEncode(O);
|
||||
Target = System.Web.HttpUtility.HtmlEncode(Ta);
|
||||
|
||||
ID = Math.Abs(DateTime.Now.GetHashCode());
|
||||
}
|
||||
@ -124,7 +124,7 @@ namespace SharedLibrary
|
||||
{
|
||||
Regex rgx = new Regex("[^a-zA-Z0-9 -! -_]");
|
||||
string message = rgx.Replace(line[4], "");
|
||||
return new Event(GType.Say, Utilities.StripIllegalCharacters(message).StripColors(), SV.ParseClientFromString(line, 2), null, SV) { Message = Utilities.StripIllegalCharacters(message).StripColors() };
|
||||
return new Event(GType.Say, message.StripColors(), SV.ParseClientFromString(line, 2), null, SV) { Message = message };
|
||||
}
|
||||
|
||||
if (removeTime.Contains("ScriptKill"))
|
||||
|
@ -7,7 +7,7 @@ namespace SharedLibrary
|
||||
{
|
||||
public Penalty(Type BType, String Reas, String TargID, String From, DateTime time, String ip, DateTime exp)
|
||||
{
|
||||
Reason = Reas.CleanChars().StripColors();
|
||||
Reason = Reas.StripColors();
|
||||
OffenderID = TargID;
|
||||
PenaltyOriginID = From;
|
||||
When = time;
|
||||
|
@ -91,12 +91,19 @@ namespace SharedLibrary
|
||||
/// </summary>
|
||||
/// <param name="pName">Player name to search for</param>
|
||||
/// <returns>Matching player if found</returns>
|
||||
public Player GetClientByName(String pName)
|
||||
public List<Player> GetClientByName(String pName)
|
||||
{
|
||||
string[] QuoteSplit = pName.Split('"');
|
||||
bool literal = false;
|
||||
if (QuoteSplit.Length > 1)
|
||||
{
|
||||
pName = QuoteSplit[1];
|
||||
return Players.FirstOrDefault(p => p != null && p.Name.ToLower().Contains(pName.ToLower()));
|
||||
literal = true;
|
||||
}
|
||||
if (literal)
|
||||
return Players.Where(p => p != null && p.Name.ToLower().Equals(pName.ToLower())).ToList();
|
||||
|
||||
return Players.Where(p => p != null && p.Name.ToLower().Contains(pName.ToLower())).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -75,6 +75,7 @@
|
||||
<HintPath>..\packages\System.Data.SQLite.Core.1.0.105.1\lib\net45\System.Data.SQLite.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
@ -80,27 +80,6 @@ namespace SharedLibrary
|
||||
return Player.Permission.Banned;
|
||||
}
|
||||
|
||||
public static String StripIllegalCharacters(String str)
|
||||
{
|
||||
if (str != null)
|
||||
return str.Replace("`", "").Replace("\\", "").Replace("\"", "").Replace(""", "").Replace("&", "&").Replace("\"", "''").Replace("'", "").Replace("?", "");
|
||||
|
||||
else
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public static String CleanChars(this string S)
|
||||
{
|
||||
if (S == null)
|
||||
return "";
|
||||
|
||||
StringBuilder Cleaned = new StringBuilder();
|
||||
|
||||
foreach (char c in S)
|
||||
if (c < 127 && c > 31 && c != 37 && c != 34 && c != 92) Cleaned.Append(c);
|
||||
return Cleaned.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all IW Engine color codes
|
||||
/// </summary>
|
||||
@ -314,5 +293,10 @@ namespace SharedLibrary
|
||||
|
||||
return "1 hour";
|
||||
}
|
||||
|
||||
public static string EscapeMarkdown(this string markdownString)
|
||||
{
|
||||
return markdownString.Replace("<", "\\<").Replace(">", "\\>").Replace("|", "\\|");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user