GroupVerify 0.3.0: check players with the Steam Web API as they join, clan tag for other plugins
Steam rate-limits its community member lists by IP (429), so the whole-list download is gone. Each player is checked as they join with ISteamUser/GetUserGroupList: a member's 'group' row is added or refreshed, a non-member's deleted, and when Steam won't say (private profile, bad key, outage) the database stands. A player is asked about at most once per min_forced_refresh_seconds; css_verify rechecks its targets, offline SteamIDs too. Changing the group clears the old group's rows. refresh_minutes is gone. The Web API key goes in configs/plugins/GroupVerify/GroupVerify.json (SteamWebApiKey); every other setting stays in the database. New clan_tag setting and css_gv_clantag <tag|-> (@css/root): the scoreboard tag for verified players without a rank, applied by CS2-Tags. The API gains ClanTag and OnClanTagChanged, so shared/GroupVerifyApi changes: needs a server restart.
This commit is contained in:
parent
1f61958099
commit
10e5fe9f3c
11 changed files with 436 additions and 204 deletions
32
Settings.cs
32
Settings.cs
|
|
@ -4,12 +4,12 @@ namespace GroupVerify;
|
|||
internal sealed record Settings(
|
||||
bool Enabled,
|
||||
ulong GroupId64,
|
||||
int RefreshMinutes,
|
||||
int MinForcedRefreshSeconds,
|
||||
int DbReloadSeconds,
|
||||
TimeZoneInfo TimeZone,
|
||||
string VerifyMinRank,
|
||||
string[] VerifyExtraRanks)
|
||||
string[] VerifyExtraRanks,
|
||||
string ClanTag)
|
||||
{
|
||||
// Written to gv_settings when missing. The rank defaults are our real SimpleAdmin groups (see
|
||||
// the fork's Helper.StaffRanks and the web panel's site config). Only the names are set here:
|
||||
|
|
@ -18,12 +18,12 @@ internal sealed record Settings(
|
|||
[
|
||||
("enabled", "1"), // 0 turns verification off (css_gv_enable/css_gv_disable)
|
||||
("group_id64", "0"), // the Steam group's 64-bit ID (103582791...); 0 turns verification off (css_gv_group)
|
||||
("refresh_minutes", "10"), // how often the group's member list is fetched
|
||||
("min_forced_refresh_seconds", "60"), // css_verify refetches/reloads only when older than this
|
||||
("min_forced_refresh_seconds", "60"), // a player is rechecked with Steam (css_verify, rejoining) at most this often
|
||||
("db_reload_seconds", "60"), // how often gv_verified and gv_settings are reread
|
||||
("timezone", "UTC"), // must match CS2-SimpleAdmin's Timezone
|
||||
("verify_min_rank", "#rank/admin"), // css_verify: this group's immunity or higher
|
||||
("verify_extra_ranks", "#rank/guardian") // css_verify: these groups too, comma-separated
|
||||
("verify_extra_ranks", "#rank/guardian"), // css_verify: these groups too, comma-separated
|
||||
("clan_tag", "") // scoreboard tag for verified players without a rank (css_gv_clantag)
|
||||
];
|
||||
|
||||
public static readonly Settings Default = Parse(new Dictionary<string, string>(), _ => { });
|
||||
|
|
@ -61,14 +61,32 @@ internal sealed record Settings(
|
|||
return new Settings(
|
||||
Get("enabled") != "0",
|
||||
groupId,
|
||||
GetInt("refresh_minutes", 1),
|
||||
GetInt("min_forced_refresh_seconds", 0),
|
||||
GetInt("db_reload_seconds", 10),
|
||||
timeZone,
|
||||
Get("verify_min_rank"),
|
||||
Get("verify_extra_ranks").Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries));
|
||||
Get("verify_extra_ranks").Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries),
|
||||
ParseClanTag(Get("clan_tag"), warn));
|
||||
}
|
||||
|
||||
// Steam's own group tags are at most 12 characters. Quotes and control characters are refused,
|
||||
// since the tag travels in console commands.
|
||||
public const int ClanTagMaxLength = 12;
|
||||
|
||||
public static bool ValidClanTag(string tag) =>
|
||||
tag.Length <= ClanTagMaxLength && !tag.Any(c => char.IsControl(c) || c == '"' || c == ';');
|
||||
|
||||
private static string ParseClanTag(string tag, Action<string> warn)
|
||||
{
|
||||
if (ValidClanTag(tag))
|
||||
return tag;
|
||||
warn($"gv_settings clan_tag \"{tag}\" must be at most {ClanTagMaxLength} characters, without quotes, ; or control characters; ignoring it");
|
||||
return "";
|
||||
}
|
||||
|
||||
// The tag other plugins see: none while verification is off.
|
||||
public string EffectiveClanTag => Active ? ClanTag : "";
|
||||
|
||||
// Verification only runs when enabled with a group set; otherwise nobody is verified.
|
||||
public bool Active => Enabled && GroupId64 != 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue