Skip to content

Commit

Permalink
[FEAT] Added ability of reporting bad tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
alperensert committed Jul 26, 2023
1 parent ce520d1 commit a179829
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CapMonster.Cloud.Tests/TaskTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CapMonster.Cloud.Models;
using CapMonster.Cloud.Tasks;
using CapMonster.Cloud.Tasks.Responses;
using CapMonster.Cloud.Utilities;

namespace CapMonster.Cloud.Tests;

Expand Down Expand Up @@ -71,7 +72,7 @@ public async void HCaptcha_Test(string websiteUrl, string websiteKey, bool usePr
{
var client = new CapMonsterClient(Environment.GetEnvironmentVariable("APIKEY")!);
UseProxy(client, useProxy);
var task = new FunCaptchaTask(websiteUrl, websiteKey);
var task = new HCaptchaTask(websiteUrl, websiteKey);
var id = await client.CreateTask(task);
Assert.IsType<int>(id);
var response = await client.JoinTaskResult<HCaptchaResponse>(id);
Expand Down
4 changes: 2 additions & 2 deletions CapMonster.Cloud/CapMonster.Cloud.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>CapMonster.Cloud</PackageId>
<Version>1.0.0-alpha</Version>
<Version>1.0.0</Version>
<Authors>Alperen Sert</Authors>
<Company>Alperen Sert</Company>
<PackageTags>Capmonster,ReCaptcha v2 solver, Bypass captcha, anti-captcha,</PackageTags>
Expand All @@ -19,7 +19,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<None Include="../README.md" Pack="true" PackagePath="\"/>
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions CapMonster.Cloud/CapMonsterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ public async Task<double> GetBalanceAsync()
var r = await CheckResponse<GetBalance>(response);
return r.Balance;
}

public async Task<bool> ReportIncorrectCaptcha(CaptchaTypes captchaType, int taskId)
{
var data = new VanillaTask(_clientKey)
{
TaskId = taskId
};
var endpoint = captchaType switch
{
CaptchaTypes.Image => Endpoints.IncorrectImageCaptcha,
CaptchaTypes.Token => Endpoints.IncorrectTokenCaptcha,
CaptchaTypes.ReCaptcha => Endpoints.IncorrectTokenCaptcha,
CaptchaTypes.HCaptcha => Endpoints.IncorrectTokenCaptcha,
_ => throw new ArgumentOutOfRangeException(nameof(captchaType), captchaType, null)
};
var response = await MakeRequest(endpoint, JsonConvert.SerializeObject(data));
CheckResponse(JsonConvert.DeserializeObject<ErrorResponse>(await response.Content.ReadAsStringAsync()));
return true;
}

public async Task<TaskResponse<T>> GetTaskResultAsync<T>(int taskId) where T : ITaskResponse
{
Expand Down
6 changes: 5 additions & 1 deletion CapMonster.Cloud/Endpoints.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
namespace CapMonster.Cloud;

internal class Endpoints
internal static class Endpoints
{
public const string Balance = "/getBalance";

public const string CreateTask = "/createTask";

public const string TaskResult = "/getTaskResult";

public const string IncorrectImageCaptcha = "/reportIncorrectImageCaptcha";

public const string IncorrectTokenCaptcha = "/reportIncorrectTokenCaptcha";
}
9 changes: 9 additions & 0 deletions CapMonster.Cloud/Utilities/CaptchaTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CapMonster.Cloud.Utilities;

public enum CaptchaTypes
{
Image,
Token,
ReCaptcha,
HCaptcha
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dotnet add package CapMonster.Cloud --version 1.0.0

via adding PackageReference:
```xml
<PackageReference Include="CapMonster.Cloud" Version="1.0.0-alpha" />
<PackageReference Include="CapMonster.Cloud" Version="1.0.0" />
```
For projects that support PackageReference, copy this XML node into the project file to reference the package.

Expand Down

0 comments on commit a179829

Please sign in to comment.