fixed unicode crap stuff in webhook
enable preview of tiered compiliation (faster startup) ban events are sent to the API properly now add vpn except id configuration begin work on javascript plugin support
This commit is contained in:
parent
b5939bbdaf
commit
ac64d8d3c1
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
|
<TieredCompilation>true</TieredCompilation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -254,6 +254,7 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Manager.GetApplicationSettings().Configuration().EnableClientVPNs &&
|
if (!Manager.GetApplicationSettings().Configuration().EnableClientVPNs &&
|
||||||
|
Manager.GetApplicationSettings().Configuration().VpnExceptionIds?.FirstOrDefault(i => i == player.ClientId) != null &&
|
||||||
await VPNCheck.UsingVPN(player.IPAddressString, Manager.GetApplicationSettings().Configuration().IPHubAPIKey))
|
await VPNCheck.UsingVPN(player.IPAddressString, Manager.GetApplicationSettings().Configuration().IPHubAPIKey))
|
||||||
{
|
{
|
||||||
await player.Kick(Utilities.CurrentLocalization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], new Player() { ClientId = 1 });
|
await player.Kick(Utilities.CurrentLocalization.LocalizationIndex["SERVER_KICK_VPNS_NOTALLOWED"], new Player() { ClientId = 1 });
|
||||||
@ -330,8 +331,8 @@ namespace IW4MAdmin
|
|||||||
public override async Task ExecuteEvent(GameEvent E)
|
public override async Task ExecuteEvent(GameEvent E)
|
||||||
{
|
{
|
||||||
bool canExecuteCommand = true;
|
bool canExecuteCommand = true;
|
||||||
await ProcessEvent(E);
|
|
||||||
Manager.GetEventApi().OnServerEvent(this, E);
|
Manager.GetEventApi().OnServerEvent(this, E);
|
||||||
|
await ProcessEvent(E);
|
||||||
|
|
||||||
Command C = null;
|
Command C = null;
|
||||||
if (E.Type == GameEvent.EventType.Command)
|
if (E.Type == GameEvent.EventType.Command)
|
||||||
@ -989,6 +990,17 @@ namespace IW4MAdmin
|
|||||||
{
|
{
|
||||||
// this is set only because they're still in the server.
|
// this is set only because they're still in the server.
|
||||||
Target.Level = Player.Permission.Banned;
|
Target.Level = Player.Permission.Banned;
|
||||||
|
|
||||||
|
// let the api know that a ban occured
|
||||||
|
Manager.GetEventHandler().AddEvent(new GameEvent()
|
||||||
|
{
|
||||||
|
Type = GameEvent.EventType.Ban,
|
||||||
|
Data = Message,
|
||||||
|
Origin = Origin,
|
||||||
|
Target = Target,
|
||||||
|
Owner = this
|
||||||
|
});
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
string formattedString = String.Format(RconParser.GetCommandPrefixes().Kick, Target.ClientNumber, $"{loc["SERVER_BAN_TEXT"]} - ^5{Message} ^7({loc["SERVER_BAN_APPEAL"]} {Website})^7");
|
string formattedString = String.Format(RconParser.GetCommandPrefixes().Kick, Target.ClientNumber, $"{loc["SERVER_BAN_TEXT"]} - ^5{Message} ^7({loc["SERVER_BAN_APPEAL"]} {Website})^7");
|
||||||
await Target.CurrentServer.ExecuteCommandAsync(formattedString);
|
await Target.CurrentServer.ExecuteCommandAsync(formattedString);
|
||||||
|
@ -2,6 +2,7 @@ import requests
|
|||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import collections
|
import collections
|
||||||
|
import os
|
||||||
|
|
||||||
# the following classes model the discord webhook api parameters
|
# the following classes model the discord webhook api parameters
|
||||||
class WebhookAuthor():
|
class WebhookAuthor():
|
||||||
@ -45,13 +46,18 @@ class WebhookParams():
|
|||||||
|
|
||||||
# gets the relative link to a user's profile
|
# gets the relative link to a user's profile
|
||||||
def get_client_profile(profile_id):
|
def get_client_profile(profile_id):
|
||||||
return '{}/Client/ProfileAsync/{}'.format(base_url, str(profile_id))
|
return u'{}/Client/ProfileAsync/{}'.format(base_url, profile_id)
|
||||||
|
|
||||||
def get_client_profile_markdown(client_name, profile_id):
|
def get_client_profile_markdown(client_name, profile_id):
|
||||||
return '[{}]({})'.format(client_name, get_client_profile(profile_id))
|
return u'[{}]({})'.format(client_name, get_client_profile(profile_id))
|
||||||
|
|
||||||
#todo: exception handling for opening the file
|
#todo: exception handling for opening the file
|
||||||
with open('config.json') as json_config_file:
|
if os.getenv("DEBUG"):
|
||||||
|
config_file_name = 'config.dev.json'
|
||||||
|
else:
|
||||||
|
config_file_name = 'config.json'
|
||||||
|
|
||||||
|
with open(config_file_name) as json_config_file:
|
||||||
json_config = json.load(json_config_file)
|
json_config = json.load(json_config_file)
|
||||||
|
|
||||||
# this should be an URL to an IP or FQN to an IW4MAdmin instance
|
# this should be an URL to an IP or FQN to an IW4MAdmin instance
|
||||||
@ -79,11 +85,11 @@ def get_new_events():
|
|||||||
server_name = event['ownerEntity']['name']
|
server_name = event['ownerEntity']['name']
|
||||||
|
|
||||||
if event['originEntity']:
|
if event['originEntity']:
|
||||||
origin_client_name = str(event['originEntity']['name'])
|
origin_client_name = event['originEntity']['name']
|
||||||
origin_client_id = int(event['originEntity']['id'])
|
origin_client_id = int(event['originEntity']['id'])
|
||||||
|
|
||||||
if event['targetEntity']:
|
if event['targetEntity']:
|
||||||
target_client_name = str(event['targetEntity']['name']) or ''
|
target_client_name = event['targetEntity']['name'] or ''
|
||||||
target_client_id = int(event['targetEntity']['id']) or 0
|
target_client_id = int(event['targetEntity']['id']) or 0
|
||||||
|
|
||||||
webhook_item = WebhookParams()
|
webhook_item = WebhookParams()
|
||||||
@ -146,7 +152,7 @@ def get_new_events():
|
|||||||
|
|
||||||
elif event_type == 'Say':
|
elif event_type == 'Say':
|
||||||
say_client_field = WebhookField('Player', get_client_profile_markdown(origin_client_name, origin_client_id))
|
say_client_field = WebhookField('Player', get_client_profile_markdown(origin_client_name, origin_client_id))
|
||||||
message_field = WebhookField('Message', str(event['extraInfo']))
|
message_field = WebhookField('Message', event['extraInfo'])
|
||||||
|
|
||||||
webhook_item_embed.title = 'Message From Player'
|
webhook_item_embed.title = 'Message From Player'
|
||||||
webhook_item_embed.fields.append(say_client_field)
|
webhook_item_embed.fields.append(say_client_field)
|
||||||
@ -181,7 +187,8 @@ def execute_webhook(data):
|
|||||||
|
|
||||||
if event['notify']:
|
if event['notify']:
|
||||||
url = discord_webhook_notification_url
|
url = discord_webhook_notification_url
|
||||||
elif len(discord_webhook_information_url) > 0:
|
else:
|
||||||
|
if len(discord_webhook_information_url) > 0:
|
||||||
url = discord_webhook_information_url
|
url = discord_webhook_information_url
|
||||||
|
|
||||||
if url :
|
if url :
|
||||||
@ -197,8 +204,9 @@ def run():
|
|||||||
try:
|
try:
|
||||||
new_events = get_new_events()
|
new_events = get_new_events()
|
||||||
execute_webhook(new_events)
|
execute_webhook(new_events)
|
||||||
except:
|
except Exception as e:
|
||||||
print('failed to get new events ({})'.format(failed_count))
|
print('failed to get new events ({})'.format(failed_count))
|
||||||
|
print(e)
|
||||||
failed_count += 1
|
failed_count += 1
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
<Name>DiscordWebhook</Name>
|
<Name>DiscordWebhook</Name>
|
||||||
<RootNamespace>DiscordWebhook</RootNamespace>
|
<RootNamespace>DiscordWebhook</RootNamespace>
|
||||||
<InterpreterId>MSBuild|env|$(MSBuildProjectFullPath)</InterpreterId>
|
<InterpreterId>MSBuild|env|$(MSBuildProjectFullPath)</InterpreterId>
|
||||||
|
<IsWindowsApplication>False</IsWindowsApplication>
|
||||||
|
<LaunchProvider>Standard Python launcher</LaunchProvider>
|
||||||
|
<EnableNativeCodeDebugging>False</EnableNativeCodeDebugging>
|
||||||
|
<Environment>DEBUG=True</Environment>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
@ -9,6 +9,7 @@ namespace IW4MAdmin.Plugins.Stats.Config
|
|||||||
public bool EnableAntiCheat { get; set; }
|
public bool EnableAntiCheat { get; set; }
|
||||||
public List<StreakMessageConfiguration> KillstreakMessages { get; set; }
|
public List<StreakMessageConfiguration> KillstreakMessages { get; set; }
|
||||||
public List<StreakMessageConfiguration> DeathstreakMessages { get; set; }
|
public List<StreakMessageConfiguration> DeathstreakMessages { get; set; }
|
||||||
|
public int TopPlayersMinPlayTime { get; set; }
|
||||||
public string Name() => "Stats";
|
public string Name() => "Stats";
|
||||||
public IBaseConfiguration Generate()
|
public IBaseConfiguration Generate()
|
||||||
{
|
{
|
||||||
@ -47,6 +48,8 @@ namespace IW4MAdmin.Plugins.Stats.Config
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TopPlayersMinPlayTime = 3600 * 3;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
|||||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||||
var iqClientRatings = (from rating in context.Set<EFRating>()
|
var iqClientRatings = (from rating in context.Set<EFRating>()
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
where rating.ActivityAmount > 10800
|
where rating.ActivityAmount >= Plugin.Config.Configuration().TopPlayersMinPlayTime
|
||||||
#endif
|
#endif
|
||||||
where rating.RatingHistory.Client.Level != Player.Permission.Banned
|
where rating.RatingHistory.Client.Level != Player.Permission.Banned
|
||||||
where rating.RatingHistory.Client.LastConnection > thirtyDaysAgo
|
where rating.RatingHistory.Client.LastConnection > thirtyDaysAgo
|
||||||
|
@ -217,15 +217,6 @@ namespace SharedLibraryCore.Commands
|
|||||||
{
|
{
|
||||||
await E.Target.Ban(E.Data, E.Origin);
|
await E.Target.Ban(E.Data, E.Origin);
|
||||||
await E.Origin.Tell($"^5{E.Target} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_SUCCESS"]}");
|
await E.Origin.Tell($"^5{E.Target} ^7{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_SUCCESS"]}");
|
||||||
|
|
||||||
E.Owner.Manager.GetEventHandler().AddEvent(new GameEvent()
|
|
||||||
{
|
|
||||||
Type = GameEvent.EventType.Ban,
|
|
||||||
Data = E.Data,
|
|
||||||
Origin = E.Origin,
|
|
||||||
Target = E.Target,
|
|
||||||
Owner = E.Owner
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_FAIL"]} {E.Target.Name}");
|
await E.Origin.Tell($"{Utilities.CurrentLocalization.LocalizationIndex["COMMANDS_BAN_FAIL"]} {E.Target.Name}");
|
||||||
|
@ -28,6 +28,7 @@ namespace SharedLibraryCore.Configuration
|
|||||||
public List<string> AutoMessages { get; set; }
|
public List<string> AutoMessages { get; set; }
|
||||||
public List<string> GlobalRules { get; set; }
|
public List<string> GlobalRules { get; set; }
|
||||||
public List<MapConfiguration> Maps { get; set; }
|
public List<MapConfiguration> Maps { get; set; }
|
||||||
|
public List<int> VpnExceptionIds { get; set; }
|
||||||
|
|
||||||
public IBaseConfiguration Generate()
|
public IBaseConfiguration Generate()
|
||||||
{
|
{
|
||||||
@ -59,7 +60,7 @@ namespace SharedLibraryCore.Configuration
|
|||||||
SocialLinkTitle = Utilities.PromptString(loc["SETUP_SOCIAL_TITLE"]);
|
SocialLinkTitle = Utilities.PromptString(loc["SETUP_SOCIAL_TITLE"]);
|
||||||
SocialLinkAddress = Utilities.PromptString(loc["SETUP_SOCIAL_LINK"]);
|
SocialLinkAddress = Utilities.PromptString(loc["SETUP_SOCIAL_LINK"]);
|
||||||
}
|
}
|
||||||
|
VpnExceptionIds = new List<int>();
|
||||||
RConPollRate = 5000;
|
RConPollRate = 5000;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.1" />
|
<PackageReference Include="Jint" Version="3.0.0-beta-1249" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||||
|
<TieredCompilation>true</TieredCompilation>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user