private async Task Worker(TelegramBotClient client, long chatId) { bool forloop = true; string GoogleVersion = string.Empty, FpdaVersion = null; for (int i = 1; forloop; i++) { var source = await Dloader.GetSourceById(i); if (source == default) { forloop = false; } var domParser = new HtmlParser(); var document = await domParser.ParseDocumentAsync(source); var urls = dparser.GetAppUrls(document); foreach (var url in urls) { string DropGameVersion = null, DropGameName = null, ApkVersion = "0"; try { source = await GPloader.GetSourceBylink(url); document = await domParser.ParseDocumentAsync(source); DropGameName = dparser.GetName(document); DropGameVersion = dparser.GetVersion(document); if (MissGames.Contains(DropGameName)) { continue; } if (Games.Contains(DropGameName)) { await client.SendTextMessageAsync(chatId, $"Солнце, эту игру нужно посмотреть самостоятельно\n{url}"); continue; } //string engname = await GoogleParser.GetEngNameAsync(DropGameName); string engname = DropGameName; SearchResult result = await GoogleParser.GetResultAsync(engname); source = await GoogleParser.GetResult(engname); document = await domParser.ParseDocumentAsync(source); string urlstr = googleparser.GetAppUrl(document, engname); try { string appUrl = await GetUrlApp(DropGameName); GoogleVersion = await GetVersionAsync(appUrl); } catch (NullReferenceException) { Console.WriteLine("NullReferenceException"); } if (result != null && result.Title.StartsWith(engname)) { source = await GPloader.GetSourceBylink(result.Link.ToString()); document = await domParser.ParseDocumentAsync(source); string version = fpdaparser.GetVersion(document); if (version is null) { break; } FpdaVersion = version; } source = await ApkLoader.GetSourceByName(DropGameName); document = await domParser.ParseDocumentAsync(source); string apkurl = apkParser.GetUrl(document, DropGameName); if (apkurl is null) { Console.WriteLine("url is null"); } else { source = await GPloader.GetSourceBylink("https://apkcombo.com" + apkurl); document = await domParser.ParseDocumentAsync(source); ApkVersion = apkParser.GetVersion(document); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("With name " + DropGameName); } string str = string.Empty; DropGameVersion = ChangeVersion(DropGameVersion); GoogleVersion = ChangeVersion(GoogleVersion); ApkVersion = ChangeVersion(ApkVersion); Console.WriteLine(DropGameName); Console.WriteLine($"{DropGameVersion} {GoogleVersion} {ApkVersion} {FpdaVersion}"); string Version; if (FpdaVersion == null) { Version = CompareVersion(ApkVersion, GoogleVersion); } else { FpdaVersion = ChangeVersion(FpdaVersion); Version = CompareVersion(FpdaVersion, GoogleVersion); Version = CompareVersion(Version, ApkVersion); } if (DropGameVersion == Version) { Console.WriteLine(Version); Console.WriteLine(new string('-', 30)); } else { str = $"{DropGameName} {DropGameVersion} -- {Version}\n{url}"; } if (str != string.Empty) { Console.WriteLine(Version); Console.WriteLine(new string('-', 30)); await Send_NewData(client, chatId, str); } } } await Parser_OnCompleted(client, chatId); }