Skip to content

Commit

Permalink
Refactoring and README
Browse files Browse the repository at this point in the history
Fixed auto-update not triggering at the start of the application
  • Loading branch information
Plenyx committed Nov 10, 2022
1 parent 7a5eed1 commit f761452
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 35 deletions.
6 changes: 2 additions & 4 deletions Forms/FormArcPluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,9 @@ private async Task CheckUpdatesAsync(bool applicationStart = false)

private void TimerCheckUpdates_Tick(object sender, EventArgs e) => _ = CheckUpdatesAsync();

private static Process[] GetGW2Instances() => Process.GetProcessesByName("Gw2-64");

private async Task UpdateArcAndPluginsAsync()
{
var processes = GetGW2Instances();
var processes = Process.GetProcessesByName("Gw2-64");
if (processes.Length == 0)
{
SetStatus($"{DateTime.Now.ToString(System.Globalization.CultureInfo.CurrentCulture)}: Updates for installed plugins found, updating...");
Expand Down Expand Up @@ -253,7 +251,7 @@ private async void CheckedListBoxArcDpsPlugins_ItemCheck(object sender, ItemChec
var item = (ArcDpsComponentHelperClass)checkedListBoxArcDpsPlugins.Items[e.Index];
if (e.NewValue.Equals(CheckState.Unchecked))
{
var processes = GetGW2Instances();
var processes = Process.GetProcessesByName("Gw2-64");
if (processes.Length == 0)
{
var component = ArcDpsComponent.All.Find(x => x.Type.Equals(item.Type));
Expand Down
6 changes: 3 additions & 3 deletions Forms/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 16 additions & 25 deletions Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,11 @@ internal FormMain()
#endregion

#region form events
private void FormMain_Load(object sender, EventArgs e)
private async void FormMain_Load(object sender, EventArgs e)
{
_ = Task.Run(async () =>
{
await StartUpAndCommandArgs();
await NewReleaseCheckAsync(true);
});
Resize += FormMain_Resize;
await StartUpAndCommandArgs();
await NewReleaseCheckAsync(true);
}

private void FormMain_FormClosed(object sender, FormClosedEventArgs e)
Expand Down Expand Up @@ -867,18 +864,15 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
}
else
{
await Task.Run(async () =>
var delay = recentUploadFailCounter switch
{
var delay = recentUploadFailCounter switch
{
3 => 45000,
2 => 15000,
_ => 3000,
};
AddToText($">:> Retrying in {delay / 1000}s...");
await Task.Delay(delay);
await HttpUploadLogAsync(file, postData, bypassMessage);
});
3 => 45000,
2 => 15000,
_ => 3000,
};
AddToText($">:> Retrying in {delay / 1000}s...");
await Task.Delay(delay);
await HttpUploadLogAsync(file, postData, bypassMessage);
}
}
}
Expand Down Expand Up @@ -1042,11 +1036,8 @@ protected async void OnIrcStateChanged(object sender, IrcChangedEventArgs e)
if (reconnectedFailCounter <= 4)
{
AddToText($"<-?-> TRYING TO RECONNECT TO TWITCH IN {reconnectedFailCounter * 15}s");
await Task.Run(async () =>
{
await Task.Delay(reconnectedFailCounter * 15000);
await ReconnectTwitchBot();
});
await Task.Delay(reconnectedFailCounter * 15000);
await ReconnectTwitchBot();
}
else
{
Expand Down Expand Up @@ -1206,14 +1197,14 @@ private async Task SpotifySongCheck()
AddToText("> (Spotify) SONG COMMAND USED");
try
{
var process = Array.Find(Process.GetProcessesByName("Spotify"), x => !string.IsNullOrWhiteSpace(x.MainWindowTitle));
if (process.MainWindowTitle.Contains("Spotify"))
var spotifyProcess = Array.Find(Process.GetProcessesByName("Spotify"), x => !string.IsNullOrWhiteSpace(x.MainWindowTitle));
if (spotifyProcess.MainWindowTitle.Contains("Spotify"))
{
await chatConnect.SendChatMessageAsync(ApplicationSettings.Current.Twitch.ChannelName, "No song is being played.");
}
else
{
await chatConnect.SendChatMessageAsync(ApplicationSettings.Current.Twitch.ChannelName, process.MainWindowTitle);
await chatConnect.SendChatMessageAsync(ApplicationSettings.Current.Twitch.ChannelName, spotifyProcess.MainWindowTitle);
}
}
catch
Expand Down
3 changes: 2 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ static class Program
static void Main()
{
var currProcess = Process.GetCurrentProcess();
var otherProcesses = Process.GetProcessesByName("PlenBotLogUploader")
var processName = Path.GetFileNameWithoutExtension(Application.ExecutablePath.AsSpan()).ToString();
var otherProcesses = Process.GetProcessesByName(processName)
.Where(x => !x.Id.Equals(currProcess.Id))
.ToArray();
var args = Environment.GetCommandLineArgs();
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# PlenBotLogUploader [![Build and test](https://github.com/HardstuckGuild/PlenBotLogUploader/actions/workflows/build-and-test.yml/badge.svg?branch=netv6)](https://github.com/HardstuckGuild/PlenBotLogUploader/actions/workflows/build-and-test.yml)
# PlenBotLogUploader [![Build and test](https://github.com/HardstuckGuild/PlenBotLogUploader/actions/workflows/build-and-test.yml/badge.svg?branch=main)](https://github.com/HardstuckGuild/PlenBotLogUploader/actions/workflows/build-and-test.yml)
The all-in-one solution for all your arcdps logs.

If you need any help to set-up the bot, be up-to-date with latest features or have a direct contact with other users of the uploader, you can join a special Discord server "[PlenBot support line](https://discord.gg/khMDaym)"!

*Maintained by @Plenyx & @sobrinth.*

**Requires .NET 6.0 - Desktop Runtime ([link](https://dotnet.microsoft.com/en-us/download/dotnet/6.0))**
**Fully standalone or requires .NET 6.0 - Desktop Runtime ([link](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)) if using netv6 version**

## Installation ([download](https://github.com/HardstuckGuild/PlenBotLogUploader/releases)) | [Screenshots](https://plenbot.net/uploader/?utm_source=github&utm_medium=referral&utm_campaign=readme)

Expand Down

0 comments on commit f761452

Please sign in to comment.