Skip to content

Commit

Permalink
Attempt to fix FiberCop not working
Browse files Browse the repository at this point in the history
Entirely not tested
  • Loading branch information
matteocontrini committed Jun 13, 2022
1 parent 5008ce7 commit f1404e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion FibraClickSocial/FibraClickSocial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="PlainConsoleLoggerFormatter" Version="5.0.0" />
<PackageReference Include="PlainHttp" Version="1.2.0" />
<PackageReference Include="Telegram.Bot" Version="15.0.0" />
</ItemGroup>

Expand Down
16 changes: 12 additions & 4 deletions FibraClickSocial/Services/FiberCopService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using FibraClickSocial.Interfaces;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using PlainHttp;

namespace FibraClickSocial.Services
{
Expand All @@ -28,12 +30,18 @@ public FiberCopService(HttpClient client,

public async Task<string> GetCurrentCount()
{
HttpResponseMessage resp = await this.client.GetAsync(this.config.Url);
resp.EnsureSuccessStatusCode();
IHttpRequest req = new HttpRequest(this.config.Url)
{
Headers = new Dictionary<string, string>()
{
{ "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0" }
}
};

string content = await resp.Content.ReadAsStringAsync();
IHttpResponse resp = await req.SendAsync();
resp.Message.EnsureSuccessStatusCode();

MatchCollection matches = Regex.Matches(content, "lat: \\d+\\.\\d+");
MatchCollection matches = Regex.Matches(resp.Body, "lat: \\d+\\.\\d+");

if (matches.Count == 0)
{
Expand Down

0 comments on commit f1404e6

Please sign in to comment.