Skip to content

Commit

Permalink
Merge pull request #2 from davidarroyo1234/feature/telegram-integration
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
davidarroyo1234 committed Aug 26, 2023
2 parents 9f93bc4 + 9096720 commit 8b860b3
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 37 deletions.
Binary file added Accept.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
50 changes: 46 additions & 4 deletions AutoAccept-CSGO4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AutoAccept_CSGO4</RootNamespace>
<AssemblyName>AutoAccept_CSGO4</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,34 +33,75 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>TrollICon.ico</ApplicationIcon>
<ApplicationIcon>Accept.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Gma.System.MouseKeyHook, Version=5.6.130.0, Culture=neutral, PublicKeyToken=null">
<HintPath>packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Telegram.Bot, Version=19.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Telegram.Bot.19.0.0\lib\netstandard2.0\Telegram.Bot.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AntiAFK\AfkCommands.cs" />
<Compile Include="HideChecker\CSGOopenChecker.cs" />
<Compile Include="HideChecker\CsgoOpenChecker.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TelegramBot\TelegramBotHandler.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="AntiAFK\" />
</ItemGroup>
<ItemGroup>
<Content Include="TrollICon.ico" />
<Content Include="Accept.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AutoAccept_CSGO4.HideChecker
{
public class CsgOopenChecker
public class CsgoOpenChecker
{
[DllImport("User32.Dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
Expand Down
139 changes: 111 additions & 28 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
using System;
using System.Drawing;
using System.Media;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AutoAccept_CSGO4.HideChecker;
using AutoAccept_CSGO4.AntiAFK;

using AutoAccept_CSGO4.TelegramBot;

namespace AutoAccept_CSGO4
{
internal class Program
{
private const uint LEFTMOUSE_CLICKDOWN = 0x0002;
private const uint LEFTMOUSE_CLICKUP = 0x0004;

private TelegramBotHandler telegramBotHandler;

[DllImport("user32.dll")]
private static extern void mouse_event(uint dwflags, uint dx, uint dy, uint dwData, uint dwExtraInf);

[DllImport("user32.dll")]
public static extern bool SetCursorPos(int x, int y);


private const uint LEFTMOUSE_CLICKDOWN = 0x0002;
private const uint LEFTMOUSE_CLICKUP = 0x0004;

public static void Main(string[] args)
public static async Task Main(string[] args)
{
Console.WriteLine(@"
_____ _____ _____ _____ ___ _ ___ _
Expand All @@ -42,87 +42,170 @@ public static void Main(string[] args)
__/ | \____/ __/ |
|___/ |___/
");
new Program().Init(args);
await new Program().Init(args);
}

private void Init(string[] args)
private async Task Init(string[] args)
{
while (true)
{
try
{
await StartDecision();
}
catch (Exception e)
{
Console.WriteLine("An error has occurred Restarting..." + e.Message);
}
}
}

private async Task StartDecision()
{
Console.WriteLine(
"1- Start bot with Telegram notifications\n" +
"2- Start bot without Telegram notifications\n" +
(TelegramBotHandler.HasTelegramToken() ? "3- Delete telegram token\n" : "")
);

var input = Console.ReadLine();

switch (input)
{
case "1":
await HandleTelegramTokenBeforeInitialization();
break;
case "2":
Console.WriteLine("Starting bot without Telegram notifications...");
await BeginSearch();
break;
case "3" when TelegramBotHandler.HasTelegramToken():
TelegramBotHandler.DeleteTelegramToken();
Console.WriteLine("Token deleted");
break;
default:
Console.WriteLine("Invalid input");
break;
}

await StartDecision();
}

private async Task HandleTelegramTokenBeforeInitialization()
{
telegramBotHandler = new TelegramBotHandler();

if (TelegramBotHandler.HasTelegramToken())
{
await telegramBotHandler.InitializeTelegramBot();
Console.WriteLine("Starting bot with Telegram notifications...");
}
else
{
Console.WriteLine("Enter your telegram bot token:");
var token = Console.ReadLine();
if (!String.IsNullOrEmpty(token))
{
TelegramBotHandler.SetTelegramToken(token);
await telegramBotHandler.InitializeTelegramBot();
Console.WriteLine("Starting bot with Telegram notifications...");
}
else
{
Console.WriteLine("Invalid token");
return;
}
}

await BeginSearch();
}

private async Task BeginSearch()
{
while (true)
{
Thread.Sleep(100);

var csgOopenChecker = new CsgOopenChecker();
var csgoOpenChecker = new CsgoOpenChecker();

if (csgOopenChecker.MinimizedCheck() == -1)
if (csgoOpenChecker.MinimizedCheck() == -1)
{
Console.WriteLine("Open csgo to start");
}
else if (csgOopenChecker.MinimizedCheck() == 1)
else if (csgoOpenChecker.MinimizedCheck() == 1)
{
Console.WriteLine("Maximize CSGO");
}

while (csgOopenChecker.MinimizedCheck() != 0)
while (csgoOpenChecker.MinimizedCheck() != 0)
{
Thread.Sleep(300);
}

SearchPixel();
await SearchPixel();
Thread.Sleep(100);
}
}


//Starts searching for the accept button in the screen.
private void SearchPixel()
private async Task SearchPixel()
{
var counter = 0;
var exitLoop = false;
Console.WriteLine("Searching button...");

//Accept button color declaration.
var color = Color.FromArgb(76, 175, 80);
var color2 = Color.FromArgb(90, 203, 94);

var bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
var graphics = Graphics.FromImage(bitmap);
graphics.CopyFromScreen(0, 0, 0, 0, bitmap.Size);


//Checks the pixels from x:0 and y:0 to your screen resolution.
for (var x = 0; x < bitmap.Width && !exitLoop; x++)
{
for (var y = 0; y < bitmap.Height; y++)
{
var searchPixel = bitmap.GetPixel(x, y);
//If the current checking color matches the declared colors it will add +1 to the counter.
//This counter is used to prevent to click any other matching color that is not the accept button.
//The csgo accept button contains more than 9000 green pixels.

if (searchPixel == color || searchPixel == color2)
{
if (counter >= 9000)
{
Thread.Sleep(200);
SetCursorPos(x, y);
Console.WriteLine("Button found! Pressing...");
ClickF(x, y);
await ClickFunc(x, y);
exitLoop = true;
break;
}

counter++;
}
}
}
}

private void ClickF(int x, int y)
private async Task ClickFunc(int x, int y)
{
Console.WriteLine("Clicking...");
SetCursorPos(x, y);
mouse_event(LEFTMOUSE_CLICKDOWN, 0, 0, 0, 0);
mouse_event(LEFTMOUSE_CLICKUP, 0, 0, 0, 0);

if (telegramBotHandler != null && telegramBotHandler.isInitialized)
{
try
{
Console.WriteLine("Sending notification...");
await telegramBotHandler.SendMatchFoundToAllClients();
}
catch (Exception e)
{
Console.WriteLine("Error sending notification: " + e.Message);
}
}

Thread.Sleep(200);


}
}
}
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,32 @@ Automatically accepts a csgo match when found VAC risk free. (Will search for pi
[![Maintenance](https://img.shields.io/maintenance/yes/2023)](https://github.com/davidarroyo1234/CSGO-AutoAccept)
[![GitHub All Releases](https://img.shields.io/github/downloads/davidarroyo1234/CSGO-AutoAccept/total)](https://github.com/davidarroyo1234/CSGO-AutoAccept/releases)

Features
--------
- [x] Telegram notification when a match is found (Optional)
- [x] Auto accept a match when found
--------

How to use it:

1. Download the executable [here](https://github.com/davidarroyo1234/CSGO-AutoAccept/releases).
2. Open the executable.
3. Open csgo and search for a game.
4. When the match is ready it will accept it for you :)
* Download the executable [here](https://github.com/davidarroyo1234/CSGO-AutoAccept/releases).
* Open the executable.
* Select the mode you want to use.
* 1 Is to use the autoaccept and receive a telegram notification when a match is found.
* If you selected 1 you will need to enter your telegram bot token
* 2 Is just the autoaccept without the telegram notification.
* 3 is for deleting the telegram token in case you want to change it or delete it.
* Open csgo and search for a game.
* When the match is ready it will accept it for you :)

*CSGO must be maximized in order to work at least for now*


### Screenshoots
<img src="./assets/telegram.jpg" alt="Results screen" />

## Legal

**Disclaimer:** This is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Valve or Counter Strike/CSGO.

Use it at your own risk!.
Loading

0 comments on commit 8b860b3

Please sign in to comment.