Skip to content

Commit

Permalink
New options:
Browse files Browse the repository at this point in the history
kicking - FamilyShare
threshold - MinDaysSinceLastBan

You have to add them to the configuration file.
Also fixed a bug, where one cant disable the VAC check
Sapd committed Jan 24, 2021
1 parent 8529128 commit 5c9634a
Showing 2 changed files with 139 additions and 63 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ Default configuration:
"PrivateProfile": true,
"LimitedAccount": true,
"NoProfile": true,
"FamilyShare": false,
"ForceHoursPlayedKick": false
},
"LogInsteadofKick": false,
@@ -101,13 +102,15 @@ You can also use a group for that:

The plugin does the checks in this order:
1. Bans
2. Player Summaries (is profile private, account creation time)
2. Is game lended (family share)
3. Player Summaries (is profile private, account creation time)
* Limited Profile and Steam-Commmunty profile

Only when profile public:

3. Player Level
4. Game Hours and Count
5. Game badges, to get amount of games
4. Player Level
5. Game Hours and Count
6. Game badges, to get amount of games
- Only done if the user has his game hours hidden

The checks are completly asynchronous.
191 changes: 132 additions & 59 deletions SteamChecks.cs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@

namespace Oxide.Plugins
{
[Info("Steam Checks", "Sapd", "5.0.2")]
[Info("Steam Checks", "Sapd", "5.0.3")]
[Description("Kick players depending on information on their Steam profile")]
public class SteamChecks : CovalencePlugin
{
@@ -30,6 +30,11 @@ public class SteamChecks : CovalencePlugin
/// </remarks>
private HashSet<string> failedList;

/// <summary>
/// AppID of the game, where the plugin is loaded
/// </summary>
private uint appId;

/// <summary>
/// Url to the Steam Web API
/// </summary>
@@ -88,6 +93,10 @@ public class SteamChecks : CovalencePlugin
/// </summary>
private bool kickNoProfile;
/// <summary>
/// Kick when the user is using a lended game
/// </summary>
private bool kickFamilyShare;
/// <summary>
/// Kick user, when his hours are hidden
/// </summary>
/// <remarks>
@@ -154,6 +163,7 @@ protected override void LoadDefaultConfig()
["PrivateProfile"] = true,
["LimitedAccount"] = true,
["NoProfile"] = true,
["FamilyShare"] = false,
["ForceHoursPlayedKick"] = false,
};
Config["Thresholds"] = new Dictionary<string, long>
@@ -187,6 +197,7 @@ private void InitializeConfig()
kickPrivateProfile = Config.Get<bool>("Kicking", "PrivateProfile");
kickLimitedAccount = Config.Get<bool>("Kicking", "LimitedAccount");
kickNoProfile = Config.Get<bool>("Kicking", "NoProfile");
kickFamilyShare = Config.Get<bool>("Kicking", "FamilyShare");
forceHoursPlayedKick = Config.Get<bool>("Kicking", "ForceHoursPlayedKick");

maxVACBans = Config.Get<int>("Thresholds", "MaxVACBans");
@@ -239,6 +250,7 @@ protected override void LoadDefaultMessages()
["ErrorPrivateProfile"] = "This player has a private profile, therefore SteamChecks cannot check their hours.",

["KickCommunityBan"] = "You have a Steam Community ban on record.",
["KickFamilyShare"] = "Please buy the game instead of lending it via family share.",
["KickVacBan"] = "You have too many VAC bans on record.",
["KickGameBan"] = "You have too many Game bans on record.",
["KickTradeBan"] = "You have a Steam Trade ban on record.",
@@ -277,6 +289,8 @@ private void Init()
return;
}

appId = covalence.ClientAppId;

passedList = new HashSet<string>();
failedList = new HashSet<string>();

@@ -390,91 +404,109 @@ private void CheckPlayer(string steamid, Action<bool, string> callback)
callback(false, Lang("KickVacBan"));
return;
}
if (banResponse.LastBan < minDaysSinceLastBan && minDaysSinceLastBan > 0)
if (banResponse.LastBan > 0 && banResponse.LastBan < minDaysSinceLastBan && minDaysSinceLastBan > 0)
{
callback(false, Lang("KickVacBan"));
return;
}

// Next, get Player summaries - we have to check if the profile is public
GetSteamPlayerSummaries(steamid, (sumStatuscode, sumResult) =>
// Check if the game is lended
GetIsSharedGame(steamid, (sharedStatuscode, sharedResult) =>
{
if (sumStatuscode != (int)SteamChecks.StatusCode.Success)
{
APIError(steamid, "GetSteamPlayerSummaries", sumStatuscode);
return;
}

if (sumResult.LimitedAccount && kickLimitedAccount)
if (sharedStatuscode != (int)SteamChecks.StatusCode.Success)
{
callback(false, Lang("KickLimitedAccount"));
APIError(steamid, "GetIsSharedGame", sharedStatuscode);
return;
}

if (sumResult.NoProfile && kickNoProfile)
if (sharedResult && kickFamilyShare)
{
callback(false, Lang("KickNoProfile"));
callback(false, Lang("KickFamilyShare"));
return;
}

// Is profile not public?
if (sumResult.Visibility != PlayerSummary.VisibilityType.Public)
else
{
if (kickPrivateProfile)
// Next, get Player summaries - we have to check if the profile is public
GetSteamPlayerSummaries(steamid, (sumStatuscode, sumResult) =>
{
callback(false, Lang("KickPrivateProfile"));
return;
}
else
{
// If it is not public, we can cancel checks here and allow the player in
callback(true, null);
return;
}
}
if (sumStatuscode != (int)SteamChecks.StatusCode.Success)
{
APIError(steamid, "GetSteamPlayerSummaries", sumStatuscode);
return;
}

// Check how old the account is
if (maxAccountCreationTime > 0 && sumResult.Timecreated > maxAccountCreationTime)
{
callback(false, Lang("KickMaxAccountCreationTime"));
return;
}
if (sumResult.LimitedAccount && kickLimitedAccount)
{
callback(false, Lang("KickLimitedAccount"));
return;
}

// Check Steam Level
if (minSteamLevel > 0)
{
GetSteamLevel(steamid, (steamLevelStatusCode, steamLevelResult) =>
{
if (steamLevelStatusCode != (int)SteamChecks.StatusCode.Success)
if (sumResult.NoProfile && kickNoProfile)
{
APIError(steamid, "GetSteamLevel", sumStatuscode);
callback(false, Lang("KickNoProfile"));
return;
}

if (minSteamLevel > steamLevelResult)
// Is profile not public?
if (sumResult.Visibility != PlayerSummary.VisibilityType.Public)
{
callback(false, Lang("KickMinSteamLevel"));
if (kickPrivateProfile)
{
callback(false, Lang("KickPrivateProfile"));
return;
}
else
{
// If it is not public, we can cancel checks here and allow the player in
callback(true, null);
return;
}
}

// Check how old the account is
if (maxAccountCreationTime > 0 && sumResult.Timecreated > maxAccountCreationTime)
{
callback(false, Lang("KickMaxAccountCreationTime"));
return;
}
else

// Check Steam Level
if (minSteamLevel > 0)
{
GetSteamLevel(steamid, (steamLevelStatusCode, steamLevelResult) =>
{
if (steamLevelStatusCode != (int)SteamChecks.StatusCode.Success)
{
APIError(steamid, "GetSteamLevel", sumStatuscode);
return;
}

if (minSteamLevel > steamLevelResult)
{
callback(false, Lang("KickMinSteamLevel"));
return;
}
else
{
// Check game time, and amount of games
if (minGameCount > 1 || minRustHoursPlayed > 0 || maxRustHoursPlayed > 0 ||
minOtherGamesPlayed > 0 || minAllGamesHoursPlayed > 0)
CheckPlayerGameTime(steamid, callback);
}
});
}
// Else, if level check not done, Check game time, and amount of games
else if (minGameCount > 1 || minRustHoursPlayed > 0 || maxRustHoursPlayed > 0 ||
minOtherGamesPlayed > 0 || minAllGamesHoursPlayed > 0)
{
// Check game time, and amount of games
if (minGameCount > 1 || minRustHoursPlayed > 0 || maxRustHoursPlayed > 0 ||
minOtherGamesPlayed > 0 || minAllGamesHoursPlayed > 0)
CheckPlayerGameTime(steamid, callback);
CheckPlayerGameTime(steamid, callback);
}
else // Player now already passed all checks
{
callback(true, null);
}
});
}
// Else, if level check not done, Check game time, and amount of games
else if (minGameCount > 1 || minRustHoursPlayed > 0 || maxRustHoursPlayed > 0 ||
minOtherGamesPlayed > 0 || minAllGamesHoursPlayed > 0)
{
CheckPlayerGameTime(steamid, callback);
}
else // Player now already passed all checks
{
callback(true, null);
}
});
});
}
@@ -619,7 +651,12 @@ enum StatusCode
/// <summary>
/// Invalid steamid
/// </summary>
PlayerNotFound = -101
PlayerNotFound = -101,

/// <summary>
/// Can also happen, when the SteamAPI returns something unexpected
/// </summary>
ParsingFailed = -102
}

/// <summary>
@@ -873,6 +910,37 @@ private void GetSteamPlayerSummaries(string steamid64, Action<int, PlayerSummary
});
}

/// <summary>
/// Is the player playing a lended game?
/// </summary>
/// <param name="steamid64">steamid64 of the user</param>
/// <param name="callback">Callback with the statuscode <see cref="StatusCode"/> and bool which is true, if he is lending</param>
private void GetIsSharedGame(string steamid64, Action<int, bool> callback)
{
SteamWebRequest(SteamRequestType.IPlayerService, "IsPlayingSharedGame/v1", steamid64,
(httpCode, jsonResponse) =>
{
if (httpCode == (int)StatusCode.Success)
{
JToken gamesCountJSON = jsonResponse["response"]?["lender_steamid"];
if (gamesCountJSON == null)
{
callback((int)StatusCode.ParsingFailed, false);
return;
}

if ((string)gamesCountJSON != "0")
callback(httpCode, true);
else
callback(httpCode, false);
}
else
{
callback(httpCode, false);
}
}, "&appid_playing=" + appId);
}

/// <summary>
/// The badges we reference.
/// </summary>
@@ -1090,6 +1158,11 @@ private void SteamCheckTests(IPlayer player, string command, string[] args)
TestResult(player, "GetSteamPlayerSummaries", String.Format("Status {0} - Response {1}", ((StatusCode)StatusCode).ToString(), response?.ToString()));
});

GetIsSharedGame(steamid, (StatusCode, response) =>
{
TestResult(player, "GetIsSharedGame", String.Format("Status {0} - Response {1}", ((StatusCode)StatusCode).ToString(), response));
});

GetSteamBadges(steamid, (StatusCode, response) =>
{
if (((StatusCode)StatusCode) == SteamChecks.StatusCode.Success)

0 comments on commit 5c9634a

Please sign in to comment.