forked from provincialcxz/BlumAutoBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acbcec4
commit 64e8a6c
Showing
8 changed files
with
304 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Net; | ||
using System.Text.Json.Nodes; | ||
|
||
namespace BlumBot | ||
{ | ||
public class BlumClient: IDisposable | ||
{ | ||
Settings _settings; | ||
HttpClient _httpClient; | ||
private static string GetUserAgent(BlumPlatform platform) => | ||
platform switch | ||
{ | ||
BlumPlatform.iOS15 => "Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1", | ||
BlumPlatform.iOS16 => "Mozilla/5.0 (iPhone; CPU iPhone OS 16_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1", | ||
BlumPlatform.Android => "Mozilla/5.0 (Linux; Android 13; SM-G998B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36", | ||
BlumPlatform.Windows => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0", | ||
BlumPlatform.MacOS => "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/537.36 (KHTML, like Gecko) Version/16.0 Safari/537.36", | ||
_ => throw new ArgumentException($"Invalid platform {platform.ToString()}") | ||
}; | ||
|
||
public BlumClient(Settings settings) | ||
{ | ||
_settings = settings; | ||
_httpClient = new HttpClient(); | ||
|
||
_httpClient.DefaultRequestHeaders.Clear(); | ||
_httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd(GetUserAgent(_settings.Platform)); | ||
_httpClient.DefaultRequestHeaders.Accept.TryParseAdd("application/json, text/plain, */*"); | ||
_httpClient.DefaultRequestHeaders.AcceptLanguage.TryParseAdd("en-US,en;q=0.9"); | ||
_httpClient.DefaultRequestHeaders.Add("origin", "https://telegram.blum.codes"); | ||
_httpClient.DefaultRequestHeaders.Add("priority", "u=1, i"); | ||
_httpClient.DefaultRequestHeaders.Add("sec-fetch-dest", "empty"); | ||
_httpClient.DefaultRequestHeaders.Add("sec-fetch-mode", "cors"); | ||
_httpClient.DefaultRequestHeaders.Add("sec-fetch-site", "same-site"); | ||
|
||
_httpClient.DefaultRequestHeaders.Authorization = new("Bearer", _settings.AuthorizationToken); | ||
|
||
if (_settings.Platform == BlumPlatform.Windows) | ||
{ | ||
_httpClient.DefaultRequestHeaders.Add("sec-ch-ua", "\"Microsoft Edge\";v=\"126\", \"Chromium\";v=\"126\", \"Not.A/Brand\";v=\"8\", \"Microsoft Edge WebView2\";v=\"126\""); | ||
_httpClient.DefaultRequestHeaders.Add("sec-ch-ua-mobile", "?0"); | ||
_httpClient.DefaultRequestHeaders.Add("sec-ch-ua-platform", "\"Windows\""); | ||
} | ||
} | ||
|
||
private async Task<(bool, string?)> MakeRequestAsync(HttpMethod method, Uri uri, StringContent? payload = null) | ||
{ | ||
HttpRequestMessage request = new() | ||
{ | ||
Method = method, | ||
RequestUri = uri | ||
}; | ||
|
||
if (payload != null) | ||
request.Content = payload; | ||
|
||
var response = await _httpClient.SendAsync(request); | ||
|
||
if (response.StatusCode == HttpStatusCode.Unauthorized) | ||
{ | ||
Console.WriteLine("Invalid token. Please recheck"); | ||
return (false, null); | ||
} | ||
|
||
if (response.StatusCode != HttpStatusCode.OK) | ||
{ | ||
Console.WriteLine($"Invalid HTTP Status Code: {response.StatusCode}"); | ||
return (false, null); | ||
} | ||
|
||
var content = await response.Content.ReadAsStringAsync(); | ||
return (true, content); | ||
} | ||
|
||
private async Task<(bool, uint)> GetBalanceAsync() | ||
{ | ||
Uri uri = new("https://game-domain.blum.codes/api/v1/user/balance"); | ||
var (success, response) = await MakeRequestAsync(HttpMethod.Get, uri); | ||
|
||
if (!success) | ||
return (false, 0); | ||
|
||
if (response == null) | ||
{ | ||
Console.WriteLine("Balance content is null"); | ||
return (false, 0); | ||
} | ||
|
||
using (JsonDocument document = JsonDocument.Parse(response)) | ||
{ | ||
var playPasses = document.RootElement.GetProperty("playPasses").GetUInt32(); | ||
return (true, playPasses); | ||
} | ||
} | ||
|
||
private async Task<(bool, string?)> GetGameIdAsync() | ||
{ | ||
Uri uri = new("https://game-domain.blum.codes/api/v1/game/play"); | ||
var (success, response) = await MakeRequestAsync(HttpMethod.Post, uri); | ||
|
||
if (!success) | ||
return (false, null); | ||
|
||
if (response == null) | ||
{ | ||
Console.WriteLine("GameId content is null"); | ||
return (false, null); | ||
} | ||
|
||
using (JsonDocument document = JsonDocument.Parse(response)) | ||
{ | ||
var gameId = document.RootElement.GetProperty("gameId").GetString(); | ||
return (true, gameId); | ||
} | ||
} | ||
|
||
private async Task<bool> ClaimPointsAsync(string gameId, int points) | ||
{ | ||
Uri uri = new("https://game-domain.blum.codes/api/v1/game/claim"); | ||
var payloadJson = new JsonObject | ||
{ | ||
["gameId"] = gameId, | ||
["points"] = points | ||
}; | ||
StringContent payload = new(payloadJson.ToJsonString(), Encoding.UTF8, "application/json"); | ||
|
||
var (success, _) = await MakeRequestAsync(HttpMethod.Post, uri, payload); | ||
|
||
return success; | ||
} | ||
|
||
private async Task<bool> PlayGameAsync() | ||
{ | ||
Console.WriteLine("Starting game"); | ||
var (success, gameId) = await GetGameIdAsync(); | ||
if (!success || string.IsNullOrEmpty(gameId)) | ||
{ | ||
Console.WriteLine("Unable to start game"); | ||
return false; | ||
} | ||
|
||
Console.WriteLine("Waiting 32 seconds"); | ||
await Task.Delay(TimeSpan.FromSeconds(32)); | ||
|
||
Random pointsRnd = new(); | ||
var points = pointsRnd.Next((int)_settings.MinScore, (int)_settings.MaxScore + 1); | ||
|
||
Console.WriteLine($"Claiming {points} points"); | ||
success = await ClaimPointsAsync(gameId, points); | ||
if (!success) | ||
Console.WriteLine("Unable to claim points"); | ||
return success; | ||
} | ||
|
||
public async Task<bool> StartBotAsync() | ||
{ | ||
var (success, passes) = await GetBalanceAsync(); | ||
if (!success) | ||
return false; | ||
|
||
if (passes == 0) | ||
{ | ||
Console.WriteLine("There are no passes"); | ||
return true; | ||
} | ||
|
||
Console.WriteLine($"Found {passes} passes"); | ||
for (int i = 0; i < passes; i++) | ||
{ | ||
success = await PlayGameAsync(); | ||
if (!success) | ||
return false; | ||
await Task.Delay(TimeSpan.FromSeconds(1)); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public void Dispose() => _httpClient.Dispose(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,23 @@ | ||
namespace BlumBot | ||
namespace BlumBot; | ||
|
||
public static class Program | ||
{ | ||
class Program | ||
static async Task Main() | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Helper help = new Helper(); | ||
Requests requests = new Requests(); | ||
|
||
string authorizationToken = help.GetAuthorizationToken(); | ||
|
||
while (true) | ||
{ | ||
try | ||
{ | ||
int choice = help.platform(); | ||
int repetitions = help.replay(); | ||
int points = help.scores(); | ||
|
||
List<Task<string>> tasks = new List<Task<string>>(); | ||
var settings = Settings.ReadSettings(); | ||
|
||
for (int i = 0; i < repetitions; i++) | ||
{ | ||
tasks.Add(requests.MakeRequestsAsync(authorizationToken, points, i + 1, choice)); | ||
} | ||
|
||
string[] results = await Task.WhenAll(tasks); | ||
|
||
for (int i = 0; i < results.Length; i++) | ||
{ | ||
Console.WriteLine($"Результат итерации {i + 1}:\n{results[i]}\n"); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Ошибка: {ex.Message}"); | ||
} | ||
if (settings.Length == 0) | ||
{ | ||
Console.WriteLine("Rechek accounts folder"); | ||
return; | ||
} | ||
|
||
Console.WriteLine("Еще разок? (yes/no): "); | ||
string runAgain = Console.ReadLine().ToLower(); | ||
if (runAgain != "yes" && runAgain != "y") | ||
{ | ||
break; | ||
} | ||
} | ||
for (int i = 0; i < settings.Length; i++) | ||
{ | ||
Console.WriteLine($"Working with account {i + 1}"); | ||
var client = new BlumClient(settings[i]); | ||
var success = await client.StartBotAsync(); | ||
Console.WriteLine($"Account {i + 1} sucess: {success}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.