Merge pull request #148 from RaidMax/feature/issue-144-report-action
implement action on report plugin for issue #144
This commit is contained in:
commit
d8626bf70c
@ -244,7 +244,10 @@ namespace IW4MAdmin.Application
|
|||||||
customLocale: config?.EnableCustomLocale ?? false ? (config.CustomLocale ?? "en-US") : "en-US");
|
customLocale: config?.EnableCustomLocale ?? false ? (config.CustomLocale ?? "en-US") : "en-US");
|
||||||
})
|
})
|
||||||
.AddSingleton<IManager, ApplicationManager>()
|
.AddSingleton<IManager, ApplicationManager>()
|
||||||
.AddSingleton(_serviceProvider => RestClient.For<IMasterApi>(Utilities.IsDevelopment ? new Uri("http://127.0.0.1:8080") : _serviceProvider.GetRequiredService<ApplicationConfiguration>().MasterUrl))
|
.AddSingleton(_serviceProvider => RestClient
|
||||||
|
.For<IMasterApi>(Utilities.IsDevelopment ? new Uri("http://127.0.0.1:8080") : _serviceProvider
|
||||||
|
.GetRequiredService<IConfigurationHandler<ApplicationConfiguration>>().Configuration()?.MasterUrl ??
|
||||||
|
new ApplicationConfiguration().MasterUrl))
|
||||||
.AddSingleton<IMasterCommunication, MasterCommunication>();
|
.AddSingleton<IMasterCommunication, MasterCommunication>();
|
||||||
|
|
||||||
if (args.Contains("serialevents"))
|
if (args.Contains("serialevents"))
|
||||||
|
@ -36,6 +36,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IW4ScriptCommands", "Plugin
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ScriptPlugins", "ScriptPlugins", "{3F9ACC27-26DB-49FA-BCD2-50C54A49C9FA}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
Plugins\ScriptPlugins\ActionOnReport.js = Plugins\ScriptPlugins\ActionOnReport.js
|
||||||
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
|
Plugins\ScriptPlugins\ParserCoD4x.js = Plugins\ScriptPlugins\ParserCoD4x.js
|
||||||
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
|
Plugins\ScriptPlugins\ParserIW4x.js = Plugins\ScriptPlugins\ParserIW4x.js
|
||||||
Plugins\ScriptPlugins\ParserPIW5.js = Plugins\ScriptPlugins\ParserPIW5.js
|
Plugins\ScriptPlugins\ParserPIW5.js = Plugins\ScriptPlugins\ParserPIW5.js
|
||||||
|
49
Plugins/ScriptPlugins/ActionOnReport.js
Normal file
49
Plugins/ScriptPlugins/ActionOnReport.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
let plugin = {
|
||||||
|
author: 'RaidMax',
|
||||||
|
version: 1.0,
|
||||||
|
name: 'Action on Report',
|
||||||
|
enabled: false, // indicates if the plugin is enabled
|
||||||
|
reportAction: 'TempBan', // can be TempBan or Ban
|
||||||
|
maxReportCount: 5, // how many reports before action is taken
|
||||||
|
tempBanDurationMinutes: 60, // how long to temporarily ban the player
|
||||||
|
eventTypes: { 'report': 103 },
|
||||||
|
|
||||||
|
onEventAsync: function (gameEvent, server) {
|
||||||
|
if (!this.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameEvent.Type === this.eventTypes['report']) {
|
||||||
|
if (!gameEvent.Target.IsIngame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let reportCount = this.reportCounts[gameEvent.Target.NetworkId] === undefined ? 0 : this.reportCounts[gameEvent.Target.NetworkId];
|
||||||
|
reportCount++;
|
||||||
|
this.reportCounts[gameEvent.Target.NetworkId] = reportCount;
|
||||||
|
|
||||||
|
if (reportCount >= this.maxReportCount) {
|
||||||
|
switch (this.reportAction) {
|
||||||
|
case 'TempBan':
|
||||||
|
server.Logger.WriteInfo(`TempBanning client (id) ${gameEvent.Target.ClientId} because they received ${reportCount} reports`);
|
||||||
|
gameEvent.Target.TempBan(_localization.LocalizationIndex['PLUGINS_REPORT_ACTION'], System.TimeSpan.FromMinutes(this.tempBanDurationMinutes), _IW4MAdminClient);
|
||||||
|
break;
|
||||||
|
case 'Ban':
|
||||||
|
server.Logger.WriteInfo(`Banning client (id) ${gameEvent.Target.ClientId} because they received ${reportCount} reports`);
|
||||||
|
gameEvent.Target.Ban(_localization.LocalizationIndex['PLUGINS_REPORT_ACTION'], _IW4MAdminClient, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoadAsync: function (manager) {
|
||||||
|
this.reportCounts = {};
|
||||||
|
},
|
||||||
|
|
||||||
|
onUnloadAsync: function () {
|
||||||
|
},
|
||||||
|
|
||||||
|
onTickAsync: function (server) {
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user