Skip to content

Commit eeec51f

Browse files
committed
update 1.4.2.0
added vac blacklist support
1 parent d208cf7 commit eeec51f

File tree

6 files changed

+333
-22
lines changed

6 files changed

+333
-22
lines changed

Socialboost/CSharedFiles.cs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,30 @@ internal static async Task<ResultadoCombinado> EnviarLikeEFavorito(Bot bot, EAcc
291291
return access >= EAccess.Owner ? FormatarResposta(Strings.BotNotFound) : null;
292292
}
293293

294-
// Verifica quantos bots estão online
294+
// === Obtém o AppID do sharedfile (opcional para blacklist) ===
295+
Bot firstBot = bots.First(b => b.IsConnectedAndLoggedOn);
296+
string? appId = await AppIdHelper.ObterAppIdDoSharedfile(firstBot, sharedfileId).ConfigureAwait(false);
297+
298+
HashSet<string> botsBlacklisted = [];
299+
300+
if (!string.IsNullOrEmpty(appId)) {
301+
// === Obtém bots na blacklist ===
302+
botsBlacklisted = await BlacklistHelper.ObterBotsNaBlacklist(appId).ConfigureAwait(false);
303+
if (botsBlacklisted.Count > 0) {
304+
ASF.ArchiLogger.LogGenericInfo($"Socialboost|SHAREDFILES => {botsBlacklisted.Count} bot(s) na blacklist do AppID {appId}");
305+
}
306+
} else {
307+
ASF.ArchiLogger.LogGenericWarning($"Socialboost|SHAREDFILES => Não foi possível obter AppID, sistema de blacklist desabilitado para este sharedfile");
308+
}
309+
310+
if (botsBlacklisted.Count > 0) {
311+
ASF.ArchiLogger.LogGenericInfo($"Socialboost|SHAREDFILES => {botsBlacklisted.Count} bot(s) na blacklist do AppID {appId}");
312+
}
313+
314+
// Verifica quantos bots estão online (e não na blacklist)
295315
int botsOnline = 0;
296316
foreach (Bot bot in bots) {
297-
if (bot.IsConnectedAndLoggedOn) {
317+
if (bot.IsConnectedAndLoggedOn && !botsBlacklisted.Contains(bot.BotName)) {
298318
botsOnline++;
299319
}
300320
}
@@ -305,20 +325,6 @@ internal static async Task<ResultadoCombinado> EnviarLikeEFavorito(Bot bot, EAcc
305325
: null;
306326
}
307327

308-
// Obtém o AppID do sharedfile usando o primeiro bot disponível
309-
Bot firstBot = bots.First(b => b.IsConnectedAndLoggedOn);
310-
string? appId = await SessionHelper.FetchAppIDShared(
311-
firstBot,
312-
$"https://steamcommunity.com/sharedfiles/filedetails/?id={sharedfileId}",
313-
sharedfileId
314-
).ConfigureAwait(false);
315-
316-
if (string.IsNullOrEmpty(appId)) {
317-
return access >= EAccess.Owner
318-
? FormatarResposta($"Erro ao obter AppID do sharedfile {sharedfileId}")
319-
: null;
320-
}
321-
322328
// Listas para armazenar resultados
323329
List<ResultadoCombinado> resultados = [];
324330
int likesEnviados = 0;
@@ -333,6 +339,11 @@ internal static async Task<ResultadoCombinado> EnviarLikeEFavorito(Bot bot, EAcc
333339
break;
334340
}
335341

342+
// === NOVO: Pula bots na blacklist ===
343+
if (botsBlacklisted.Contains(bot.BotName)) {
344+
continue;
345+
}
346+
336347
// Pula bots offline
337348
if (!bot.IsConnectedAndLoggedOn) {
338349
continue;
@@ -359,7 +370,7 @@ internal static async Task<ResultadoCombinado> EnviarLikeEFavorito(Bot bot, EAcc
359370
bot,
360371
Commands.GetProxyAccess(bot, access, steamID),
361372
sharedfileId,
362-
appId,
373+
appId!,
363374
jaEnviouLike == true,
364375
jaEnviouFav == true
365376
).ConfigureAwait(false);
@@ -369,6 +380,11 @@ internal static async Task<ResultadoCombinado> EnviarLikeEFavorito(Bot bot, EAcc
369380
continue;
370381
}
371382

383+
// === Se detectou VAC ban, adiciona à blacklist (se tiver AppID) ===
384+
if (resultado.VacBan && !string.IsNullOrEmpty(appId)) {
385+
await BlacklistHelper.AdicionarBotNaBlacklist(bot.BotName, appId).ConfigureAwait(false);
386+
}
387+
372388
resultados.Add(resultado);
373389

374390
if (resultado.LikeSucesso) {

Socialboost/CSharedLike.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Text.Json.Serialization;
45
using System.Threading;
56
using System.Threading.Tasks;
@@ -193,10 +194,30 @@ internal sealed class SteamVoteResponse {
193194
return access >= EAccess.Owner ? FormatarResposta(Strings.BotNotFound) : null;
194195
}
195196

196-
// Verifica quantos bots estão online e disponíveis (não limitados)
197+
// === Obtém o AppID do sharedfile (opcional para blacklist) ===
198+
Bot firstBot = bots.First(b => b.IsConnectedAndLoggedOn);
199+
string? appId = await AppIdHelper.ObterAppIdDoSharedfile(firstBot, sharedfileId).ConfigureAwait(false);
200+
201+
HashSet<string> botsBlacklisted = [];
202+
203+
if (!string.IsNullOrEmpty(appId)) {
204+
// === Obtém bots na blacklist ===
205+
botsBlacklisted = await BlacklistHelper.ObterBotsNaBlacklist(appId).ConfigureAwait(false);
206+
if (botsBlacklisted.Count > 0) {
207+
ASF.ArchiLogger.LogGenericInfo($"Socialboost|LIKE => {botsBlacklisted.Count} bot(s) na blacklist do AppID {appId}");
208+
}
209+
} else {
210+
ASF.ArchiLogger.LogGenericWarning($"Socialboost|LIKE => Não foi possível obter AppID, sistema de blacklist desabilitado para este sharedfile");
211+
}
212+
213+
if (botsBlacklisted.Count > 0) {
214+
ASF.ArchiLogger.LogGenericInfo($"Socialboost|LIKE => {botsBlacklisted.Count} bot(s) na blacklist do AppID {appId}");
215+
}
216+
217+
// Verifica quantos bots estão online e disponíveis (não limitados e não na blacklist)
197218
int botsOnline = 0;
198219
foreach (Bot bot in bots) {
199-
if (bot.IsConnectedAndLoggedOn && !bot.IsAccountLimited) {
220+
if (bot.IsConnectedAndLoggedOn && !bot.IsAccountLimited && !botsBlacklisted.Contains(bot.BotName)) {
200221
botsOnline++;
201222
}
202223
}
@@ -219,6 +240,11 @@ internal sealed class SteamVoteResponse {
219240
break;
220241
}
221242

243+
// === NOVO: Pula bots na blacklist ===
244+
if (botsBlacklisted.Contains(bot.BotName)) {
245+
continue;
246+
}
247+
222248
// Pula bots offline ou com conta limitada
223249
if (!bot.IsConnectedAndLoggedOn || bot.IsAccountLimited) {
224250
continue;
@@ -251,7 +277,11 @@ internal sealed class SteamVoteResponse {
251277
continue;
252278
}
253279

254-
280+
// === Se detectou VAC ban, adiciona à blacklist (se tiver AppID) ===
281+
if (resultado.VacBan && !string.IsNullOrEmpty(appId)) {
282+
await BlacklistHelper.AdicionarBotNaBlacklist(bot.BotName, appId).ConfigureAwait(false);
283+
}
284+
255285
resultados.Add(resultado);
256286

257287
if (resultado.Sucesso) {

Socialboost/Helpers/AppIdHelper.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Text.RegularExpressions;
3+
using System.Threading.Tasks;
4+
using ArchiSteamFarm.Core;
5+
using ArchiSteamFarm.Steam;
6+
using ArchiSteamFarm.Web.Responses;
7+
using static ArchiSteamFarm.Steam.Integration.ArchiWebHandler;
8+
9+
namespace Socialboost.Helpers;
10+
11+
internal static partial class AppIdHelper {
12+
private static readonly Regex AppIdRegex = DataAppId();
13+
14+
/// <summary>
15+
/// Obtém o AppID de um sharedfile através da página
16+
/// </summary>
17+
internal static async Task<string?> ObterAppIdDoSharedfile(Bot bot, string sharedfileId) {
18+
if (string.IsNullOrEmpty(sharedfileId)) {
19+
ASF.ArchiLogger.LogNullError(nameof(sharedfileId));
20+
return null;
21+
}
22+
23+
try {
24+
Uri requestViewPage = new(SteamCommunityURL, $"/sharedfiles/filedetails/?id={sharedfileId}");
25+
26+
string cookieName = $"wants_mature_content_item_{sharedfileId}";
27+
string cookieValue = "1";
28+
29+
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, string>> headers = [
30+
new("Cookie", $"{cookieName}={cookieValue}")
31+
];
32+
33+
HtmlDocumentResponse? response = await bot.ArchiWebHandler.UrlGetToHtmlDocumentWithSession(
34+
requestViewPage,
35+
headers: headers,
36+
referer: SteamCommunityURL
37+
).ConfigureAwait(false);
38+
39+
if (response?.Content == null) {
40+
ASF.ArchiLogger.LogGenericWarning($"Socialboost|APPID => Falha ao obter página do sharedfile {sharedfileId}");
41+
return null;
42+
}
43+
44+
// Obtém o HTML como string
45+
string htmlContent = response.Content.Source.Text;
46+
47+
// Extrai o AppID usando regex
48+
Match match = AppIdRegex.Match(htmlContent);
49+
if (match.Success && match.Groups.Count > 1) {
50+
string appId = match.Groups[1].Value;
51+
ASF.ArchiLogger.LogGenericInfo($"Socialboost|APPID => AppID {appId} detectado para sharedfile {sharedfileId}");
52+
return appId;
53+
}
54+
55+
ASF.ArchiLogger.LogGenericWarning($"Socialboost|APPID => Não foi possível extrair AppID do sharedfile {sharedfileId}");
56+
return null;
57+
58+
} catch (Exception ex) {
59+
ASF.ArchiLogger.LogGenericException(ex);
60+
return null;
61+
}
62+
}
63+
64+
[GeneratedRegex(@"data-appid=""(\d+)""", RegexOptions.IgnoreCase | RegexOptions.Compiled, "pt-BR")]
65+
private static partial Regex DataAppId();
66+
}

0 commit comments

Comments
 (0)