Skip to content

Commit

Permalink
Merge pull request #4 from devRael1/dev
Browse files Browse the repository at this point in the history
2.2.0
  • Loading branch information
devRael1 authored Mar 15, 2024
2 parents 98e28da + d0a4407 commit 13f6560
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 261 deletions.
9 changes: 9 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
using Loly.src.Menus;
using Loly.src.Menus.Core;
using Loly.src.Tasks;
using Loly.src.Tools;
using Loly.src.Variables;
using Loly.src.Variables.Enums;

namespace Loly;

internal class Program
{
private static void Main()
{
AppDomain.CurrentDomain.UnhandledException += UnhandledException;

Settings.SetDefaultSettings();
Settings.CreateOrUpdateSettings();

Expand All @@ -29,4 +33,9 @@ private static void Main()
Interface.ShowArt();
MainMenu.StartMenu();
}

private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Utils.LogNewError("Unhandled exception", LogModule.Loly, (Exception)e.ExceptionObject);
}
}
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

A set of several small tools for League Of Legends.

### Works with the latest `14.4` update of League of Legends ([Patch Notes : 14.5](https://na.leagueoflegends.com/en-us/news/game-updates/patch-14-5-notes/))
### Works with the latest `14.5` update of League of Legends ([Patch Notes : 14.5](https://na.leagueoflegends.com/en-us/news/game-updates/patch-14-5-notes/))
![Loly - Tools](/Ressources/mainMenu.png)

## `❗ Usage`
Expand All @@ -28,6 +28,9 @@ No need to install this if you have a more recent version installed.
More features coming soon...

## `📷 Screenshots`
<details>
<summary>Click here to see all screenshots...</summary>

### Updater Menu
<details>
<summary>See screenshot...</summary>
Expand Down Expand Up @@ -64,6 +67,8 @@ More features coming soon...
<img src="/Ressources/creditsMenu.png" alt="devRael1">
</details>

</details>

## `❓ Bugs report / Suggestions`
If you want to report a bug or suggest a feature, you can open an issue [here](https://github.com/devRael1/LolyTools/issues) or contact me on Discord.<br>
My Discord: `1043813027205619804`
Expand Down
2 changes: 1 addition & 1 deletion Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class Version
public static string FullVersionNoStage => $"{Major}.{Minor}.{Hotfix}";

private static int Major => 2;
private static int Minor => 1;
private static int Minor => 2;
private static int Hotfix => 0;
}
}
8 changes: 4 additions & 4 deletions src/Logs/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ private static void ExecuteLogRequest(IRequest valueOfRequest)
{
if (!string.IsNullOrWhiteSpace(request.Method) || !string.IsNullOrWhiteSpace(request.Url))
{
contentFile.Append($"Request to API - Endpoint: {request.Url} - Method: {request.Method}");
contentFile.Append($"Request to API > Endpoint: {request.Url} - Method: {request.Method}");
if (!string.IsNullOrWhiteSpace(request.Body))
{
contentFile.Append($"- Payload: {request.Body}");
contentFile.Append($" - Payload: {request.Body}");
}
}
}
Expand All @@ -191,10 +191,10 @@ private static void ExecuteLogRequest(IRequest valueOfRequest)
{
if (!string.IsNullOrWhiteSpace(response.Method))
{
contentFile.Append($"Response from API - Status: {response.StatusCode} - Method: {response.Method}");
contentFile.Append($"Response from API > Endpoint: {response.Url} - Status: {response.StatusCode} - Method: {response.Method}");
if (response.Data != null)
{
contentFile.Append($"- Response: {response.Data[1]}");
contentFile.Append($" - Response: {response.Data[1]}");
}
}
}
Expand Down
64 changes: 21 additions & 43 deletions src/Tasks/Scheduled/AnalyzeSessionTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,79 +20,72 @@ public static void AnalyzeSession()
string[] gameSession = Requests.ClientRequest("GET", "lol-gameflow/v1/gameflow-phase", true);
if (gameSession[0] == "200")
{
string phase = gameSession[1].Replace("\\", "").Replace("\"", "");
if (Global.Session != phase)
{
Global.Session = phase;
}

SessionPhase phase = (SessionPhase)Enum.Parse(typeof(SessionPhase), gameSession[1].Replace("\\", "").Replace("\"", ""));
if (Global.Session != phase) Global.Session = phase;
HandlePhaseLogic(phase);
}
}
}

private static void HandlePhaseLogic(string phase)
private static void HandlePhaseLogic(SessionPhase phase)
{
switch (phase)
{
case "Lobby":
case SessionPhase.Lobby:
Global.FetchedPlayers = false;
Global.AcceptedCurrentMatch = false;
Global.ChampSelectInProgress = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
case "Matchmaking":
case SessionPhase.Matchmaking:
Global.FetchedPlayers = false;
Global.ChampSelectInProgress = false;
Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
case "ReadyCheck":
case SessionPhase.ReadyCheck:
HandleReadyCheckPhase();
Thread.Sleep(TimeSpan.FromSeconds(1));
break;
case "ChampSelect":
case SessionPhase.ChampSelect:
HandleChampSelectPhase();
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
case "InProgress":
case SessionPhase.InProgress:
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
case "WaitingForStats":
case SessionPhase.WaitingForStats:
Thread.Sleep(TimeSpan.FromSeconds(15));
break;
case "PreEndOfGame":
case SessionPhase.PreEndOfGame:
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
case "EndOfGame":
case SessionPhase.EndOfGame:
Thread.Sleep(TimeSpan.FromSeconds(15));
break;
case "None":
Global.ChampSelectInProgress = false;
case SessionPhase.None:
Global.FetchedPlayers = false;
Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
default:
Global.ChampSelectInProgress = false;
Global.FetchedPlayers = false;
Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
}

if (phase != "ChampSelect")
{
Global.LastChatRoom = "";
}
if (phase != SessionPhase.ChampSelect) Global.LastChatRoom = "";
}

private static void HandleReadyCheckPhase()
{
Global.FetchedPlayers = false;
Global.ChampSelectInProgress = false;

if (!Settings.AutoAccept)
{
Thread.Sleep(TimeSpan.FromSeconds(5));
return;
}

AutoAccept.AutoAcceptQueue();
}

Expand All @@ -101,24 +94,9 @@ private static void HandleChampSelectPhase()
// TODO: Create the detection of dodge champ select system
Global.AcceptedCurrentMatch = false;

if (Settings.AutoAcceptOnce)
{
Settings.AutoAcceptOnce = false;
Settings.AutoAccept = false;
}

if (Settings.LobbyRevealer && !Global.FetchedPlayers)
{
CreateTask(LobbyRevealer.GetLobbyRevealing, $"LobbyRevealing the current lobby", LogModule.Loly);
}

if (Settings.AutoChat || Settings.PicknBan)
{
CreateTask(ChampSelectSession.HandleChampSelect, $"ChampSelect session analyze", LogModule.Loly);
}

Thread.Sleep(TimeSpan.FromSeconds(2));
Global.ChampSelectInProgress = true;
if (Settings.AutoAccept && Settings.AutoAcceptOnce) Settings.AutoAccept = false;
if (Settings.LobbyRevealer && !Global.FetchedPlayers) CreateBackgroundTask(LobbyRevealer.GetLobbyRevealing, $"LobbyRevealing the current lobby", LogModule.Loly);
if (Settings.AutoChat || Settings.PicknBan) ChampSelectSession.HandleChampSelect();
}
}
}
31 changes: 9 additions & 22 deletions src/Tasks/Scheduled/LeagueClientTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@ public static void LolClientTask()
Global.IsLeagueOpen = true;

Process client = Process.GetProcessesByName("LeagueClientUx").FirstOrDefault();
if (Global.AuthClient.Count == 0 && Global.AuthRiot.Count == 0)
{
GetLeagueAuth();
}

LoadSummonerId(false);
if (Global.AuthClient.Count == 0 && Global.AuthRiot.Count == 0) GetLeagueAuth();
if (Global.SummonerLogged.SummonerId == null) LoadSummonerId();

if (Global.Region == "")
{
Logger.Info(LogModule.Loly, "Fetching region of your League Of Legends Client");
string response = Requests.WaitSuccessClientRequest("GET", "/riotclient/region-locale", true)[1];
PlayerRegion regionSplit = JsonConvert.DeserializeObject<PlayerRegion>(response);
Global.Region = regionSplit.Region.ToLower();
Logger.Info(LogModule.Loly, $"Region fetched successfully : {Global.Region.ToUpper()}");
}

if (!_lcuPid.Equals(client.Id))
{
_lcuPid = client.Id;
}
if (!_lcuPid.Equals(client.Id)) _lcuPid = client.Id;
}
else
{
Expand Down Expand Up @@ -95,23 +90,15 @@ private static string Cmd(string gamename)
foreach (ManagementBaseObject managementBaseObject in mngmtClass.GetInstances())
{
ManagementObject o = (ManagementObject)managementBaseObject;
if (o["Name"].Equals(gamename))
{
commandline = "[" + o["CommandLine"] + "]";
}
if (o["Name"].Equals(gamename)) commandline = "[" + o["CommandLine"] + "]";
}

return commandline;
}

private static void LoadSummonerId(bool force = false)
private static void LoadSummonerId()
{
if (Global.SummonerLogged?.SummonerId != null && !force)
{
return;
}

Logger.Info(LogModule.Loly, "Getting your Summoner ID");
Logger.Info(LogModule.Loly, "Fetching your Summoner ID");

string[] currentSummoner = Requests.WaitSuccessClientRequest("GET", "lol-summoner/v1/current-summoner", true);
CurrentSummoner currentSum = JsonConvert.DeserializeObject<CurrentSummoner>(currentSummoner[1]);
Expand All @@ -124,7 +111,7 @@ private static void LoadSummonerId(bool force = false)
Global.SummonerLogged.AccountId = currentSum.AccountId;
Global.SummonerLogged.Puuid = currentSum.Puuid;

Logger.Info(LogModule.Loly, $"Summoner ID loaded : {Global.SummonerLogged.SummonerId}");
Logger.Info(LogModule.Loly, $"Logged Summoner ID loaded : {Global.SummonerLogged.SummonerId}");
}
}
}
4 changes: 2 additions & 2 deletions src/Tasks/ScheduledTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Start()
{
if (runNow)
{
Utils.CreateTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
Utils.CreateBackgroundTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
}

if (!infinite)
Expand All @@ -52,7 +52,7 @@ public void Stop()

private void TimerElapsed(object sender, ElapsedEventArgs e)
{
Utils.CreateTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
Utils.CreateBackgroundTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
}
}
}
12 changes: 3 additions & 9 deletions src/Tasks/TaskCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,17 @@ public TaskCore()
{
_scheduledTasks.Add(new ScheduledTask(LeagueClientTask.LolClientTask, "LolClientTask", TimeSpan.FromSeconds(5), true, false));
_scheduledTasks.Add(new ScheduledTask(AnalyzeSessionTask.AnalyzeSession, "AnalyzeSession", TimeSpan.FromMinutes(1), true, true));
_scheduledTasks.Add(new ScheduledTask(ClearLogsFilesTask.RunClearLogsFiles, "RunClearLogsFiles", TimeSpan.FromHours(2), true, false));
_scheduledTasks.Add(new ScheduledTask(ClearLogsFilesTask.RunClearLogsFiles, "RunClearLogsFiles", TimeSpan.FromHours(1), true, false));
}

public void StartAllTasks()
{
foreach (ScheduledTask scheduledTask in _scheduledTasks)
{
scheduledTask.Start();
}
foreach (ScheduledTask scheduledTask in _scheduledTasks) scheduledTask.Start();
}

public void StopAllTasks()
{
foreach (ScheduledTask scheduledTask in _scheduledTasks)
{
scheduledTask.Stop();
}
foreach (ScheduledTask scheduledTask in _scheduledTasks) scheduledTask.Stop();
}
}
}
14 changes: 6 additions & 8 deletions src/Tools/AutoAccept.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ public class AutoAccept
{
public static void AutoAcceptQueue()
{
if (Global.AcceptedCurrentMatch) return;

string[] response = ClientRequest("POST", "lol-matchmaking/v1/ready-check/accept", true);
if (response[0] != "200")
if (response[0] != "204")
{
Logger.Info(LogModule.AutoAccept, "Failed to auto accept the current match");
Logger.Info(LogModule.AutoAccept, "Check logs to get more informations.");
Logger.Warn(LogModule.AutoAccept, "Failed to auto accept the current match");
Logger.Warn(LogModule.AutoAccept, "Check Requests logs to get more informations.");
return;
}

if (!Global.AcceptedCurrentMatch)
{
Logger.Info(LogModule.AutoAccept, "The current match has been auto accepted");
}

Logger.Info(LogModule.AutoAccept, "The current match has been auto accepted");
Global.AcceptedCurrentMatch = true;
}
}
4 changes: 2 additions & 2 deletions src/Tools/AutoChat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AutoChat

public static void HandleChampSelectAutoChat()
{
Logger.Info(LogModule.AutoChat, "Getting Chat & Summoner ID");
Logger.Info(LogModule.AutoChat, "Fetching Chat information & Summoner ID");
string[] myChatProfile = Requests.ClientRequest("GET", "lol-chat/v1/me", true);
ChatMe chatProfileJson = JsonConvert.DeserializeObject<ChatMe>(myChatProfile[1]);
string currentChatId = chatProfileJson.Id;
Expand All @@ -38,7 +38,7 @@ public static void HandleChampSelectAutoChat()
count++;
}

Thread.Sleep(attempts * 200);
Thread.Sleep(attempts * 100);
}
}

Expand Down
Loading

0 comments on commit 13f6560

Please sign in to comment.