mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
Added Discord Bot Status and a button to Stop/Start the discord bot
This commit is contained in:
parent
a2b811972f
commit
13713b7092
18 changed files with 439 additions and 16 deletions
|
|
@ -353,6 +353,9 @@
|
||||||
<setting name="DiscordBotHelpUrl" serializeAs="String">
|
<setting name="DiscordBotHelpUrl" serializeAs="String">
|
||||||
<value>https://arkservermanager.freeforums.net/thread/8764/get-own-discord-bot</value>
|
<value>https://arkservermanager.freeforums.net/thread/8764/get-own-discord-bot</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="DiscordBotStatusCheckTime" serializeAs="String">
|
||||||
|
<value>10</value>
|
||||||
|
</setting>
|
||||||
</ServerManagerTool.Config>
|
</ServerManagerTool.Config>
|
||||||
<ServerManagerTool.Common.CommonConfig>
|
<ServerManagerTool.Common.CommonConfig>
|
||||||
<setting name="DefaultSteamAPIKey" serializeAs="String">
|
<setting name="DefaultSteamAPIKey" serializeAs="String">
|
||||||
|
|
|
||||||
9
src/ARKServerManager/Config.Designer.cs
generated
9
src/ARKServerManager/Config.Designer.cs
generated
|
|
@ -3023,5 +3023,14 @@ namespace ServerManagerTool {
|
||||||
this["DiscordBotLogLevel"] = value;
|
this["DiscordBotLogLevel"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("10")]
|
||||||
|
public int DiscordBotStatusCheckTime {
|
||||||
|
get {
|
||||||
|
return ((int)(this["DiscordBotStatusCheckTime"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -834,5 +834,8 @@
|
||||||
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
||||||
<Value Profile="(Default)">Info</Value>
|
<Value Profile="(Default)">Info</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="DiscordBotStatusCheckTime" Type="System.Int32" Scope="Application">
|
||||||
|
<Value Profile="(Default)">10</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
|
|
@ -790,12 +790,18 @@
|
||||||
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableLabel">Enable</sys:String>
|
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableLabel">Enable</sys:String>
|
||||||
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableTooltip">Enable the auto-update scheduled task</sys:String>
|
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableTooltip">Enable the auto-update scheduled task</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskRunTimeLabel">Next Run Time:</sys:String>
|
<sys:String x:Key="MainWindow_TaskRunTimeLabel">Next Run Time:</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotStatusLabel">Discord Bot:</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStartLabel">Start</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStartTooltip">Start the discord bot</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStopLabel">Stop</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStopTooltip">Stop the discord bot</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="MainWindow_TaskStateUnknownLabel">Unknown</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateUnknownLabel">Unknown</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateDisabledLabel">Disabled</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateDisabledLabel">Disabled</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateQueuedLabel">Queued</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateQueuedLabel">Queued</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateReadyLabel">Ready</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateReadyLabel">Ready</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateRunningLabel">Running</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateRunningLabel">Running</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_TaskStateStoppedLabel">Stopped</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="MainWindow_ProfileLoad_FailedTitle">Profile failed to load</sys:String>
|
<sys:String x:Key="MainWindow_ProfileLoad_FailedTitle">Profile failed to load</sys:String>
|
||||||
<sys:String x:Key="MainWindow_ProfileLoad_FailedLabel">The profile at {0} failed to load. The error was: {1}\r\n{2}</sys:String>
|
<sys:String x:Key="MainWindow_ProfileLoad_FailedLabel">The profile at {0} failed to load. The error was: {1}\r\n{2}</sys:String>
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:3E33DCB2-ECFE-4489-B1A4-56F5D386F9DC</id>
|
<id>urn:uuid:3E33DCB2-ECFE-4489-B1A4-56F5D386F9DC</id>
|
||||||
<title>1.1.413 (1.1.413.6)</title>
|
<title>1.1.413 (1.1.413.7)</title>
|
||||||
<summary>1.1.413.6</summary>
|
<summary>1.1.413.7</summary>
|
||||||
<link href="" />
|
<link href="" />
|
||||||
<updated>2021-12-17T00:00:00Z</updated>
|
<updated>2021-12-17T00:00:00Z</updated>
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
<li>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
<li>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
||||||
<li>Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.</li>
|
<li>Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.</li>
|
||||||
<li>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
<li>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
||||||
|
<li>Main Window - Added Discord Bot Status and a button to Stop/Start the discord bot.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
<u style="font-size: .9em;">CHANGE</u>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,29 @@
|
||||||
<link href="http://arkservermanager.freeforums.net/" />
|
<link href="http://arkservermanager.freeforums.net/" />
|
||||||
<updated>2021-12-16T00:00:00Z</updated>
|
<updated>2021-12-16T00:00:00Z</updated>
|
||||||
|
|
||||||
|
<entry>
|
||||||
|
<id>urn:uuid:8EE5659C-18E6-47D3-941D-C32B129D2E06</id>
|
||||||
|
<title>1.1.413 (1.1.413.7)</title>
|
||||||
|
<summary>1.1.413.7</summary>
|
||||||
|
<link href="" />
|
||||||
|
<updated>2021-12-17T00:00:00Z</updated>
|
||||||
|
<content type="xhtml">
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||||
|
<p>
|
||||||
|
<u style="font-size: .9em;">NEW</u>
|
||||||
|
<br/>
|
||||||
|
<ul>
|
||||||
|
<li>Main Window - Added Discord Bot Status and a button to Stop/Start the discord bot.</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</content>
|
||||||
|
<author>
|
||||||
|
<name>bletch</name>
|
||||||
|
<email>bletch1971@hotmail.com</email>
|
||||||
|
</author>
|
||||||
|
</entry>
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:65A7E6B1-98D1-422D-B42F-B0EBB1D20E41</id>
|
<id>urn:uuid:65A7E6B1-98D1-422D-B42F-B0EBB1D20E41</id>
|
||||||
<title>1.1.413 (1.1.413.6)</title>
|
<title>1.1.413 (1.1.413.6)</title>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
|
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
|
||||||
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
||||||
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
|
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
|
||||||
|
xmlns:bot="clr-namespace:ServerManagerTool.DiscordBot;assembly=ServerManager.Discord"
|
||||||
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
|
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
|
||||||
Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
|
Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
|
||||||
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
|
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
|
||||||
|
|
@ -132,6 +133,7 @@
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Label Grid.Row="0" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontSize="11" Content="{DynamicResource MainWindow_TaskStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<Label Grid.Row="0" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontSize="11" Content="{DynamicResource MainWindow_TaskStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
@ -257,6 +259,61 @@
|
||||||
</Button.Style>
|
</Button.Style>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
|
||||||
|
<Label Margin="0" Background="Transparent" Foreground="White" FontSize="10" Content="{DynamicResource MainWindow_DiscordBotStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||||
|
<Label Margin="0" Background="Transparent" FontSize="10" Content="{Binding DiscordBotStateString}" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||||
|
<Label.Style>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Disabled}">
|
||||||
|
<Setter Property="Foreground" Value="DarkRed"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Stopped}">
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Running}">
|
||||||
|
<Setter Property="Foreground" Value="LightGreen"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Label.Style>
|
||||||
|
</Label>
|
||||||
|
<Button Margin="5,0,0,0" Padding="1" BorderThickness="1" BorderBrush="White" Click="DiscordBotTaskState_Click" VerticalAlignment="Center">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="{x:Type Button}">
|
||||||
|
<Setter Property="Background" Value="#00AA00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<MultiDataTrigger>
|
||||||
|
<MultiDataTrigger.Conditions>
|
||||||
|
<Condition Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Stopped}"/>
|
||||||
|
</MultiDataTrigger.Conditions>
|
||||||
|
<Setter Property="Background" Value="#00AA00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</MultiDataTrigger>
|
||||||
|
<MultiDataTrigger>
|
||||||
|
<MultiDataTrigger.Conditions>
|
||||||
|
<Condition Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Running}"/>
|
||||||
|
</MultiDataTrigger.Conditions>
|
||||||
|
<Setter Property="Background" Value="#AA8A00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStopLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStopTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</MultiDataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid DockPanel.Dock="Top" VerticalAlignment="Top" Margin="10,0,10,0" HorizontalAlignment="Center">
|
<Grid DockPanel.Dock="Top" VerticalAlignment="Top" Margin="10,0,10,0" HorizontalAlignment="Center">
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ namespace ServerManagerTool
|
||||||
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||||
private readonly ActionQueue versionChecker;
|
private readonly ActionQueue versionChecker;
|
||||||
private readonly ActionQueue scheduledTaskChecker;
|
private readonly ActionQueue scheduledTaskChecker;
|
||||||
|
private readonly ActionQueue discordBotChecker;
|
||||||
|
|
||||||
|
private bool discordBotStateClicked = false;
|
||||||
|
|
||||||
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(MainWindow), new PropertyMetadata(null));
|
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(MainWindow), new PropertyMetadata(null));
|
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
|
|
@ -40,6 +43,8 @@ namespace ServerManagerTool
|
||||||
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
||||||
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
|
public static readonly DependencyProperty DiscordBotStateProperty = DependencyProperty.Register(nameof(DiscordBotState), typeof(DiscordBot.Enums.BotState), typeof(MainWindow), new PropertyMetadata(DiscordBot.Enums.BotState.Unknown));
|
||||||
|
public static readonly DependencyProperty DiscordBotStateStringProperty = DependencyProperty.Register(nameof(DiscordBotStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
||||||
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
|
|
@ -57,6 +62,7 @@ namespace ServerManagerTool
|
||||||
this.DataContext = this;
|
this.DataContext = this;
|
||||||
this.versionChecker = new ActionQueue();
|
this.versionChecker = new ActionQueue();
|
||||||
this.scheduledTaskChecker = new ActionQueue();
|
this.scheduledTaskChecker = new ActionQueue();
|
||||||
|
this.discordBotChecker = new ActionQueue();
|
||||||
|
|
||||||
IsAdministrator = SecurityUtils.IsAdministrator();
|
IsAdministrator = SecurityUtils.IsAdministrator();
|
||||||
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
||||||
|
|
@ -139,6 +145,18 @@ namespace ServerManagerTool
|
||||||
set { SetValue(AutoUpdateNextRunTimeProperty, value); }
|
set { SetValue(AutoUpdateNextRunTimeProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DiscordBot.Enums.BotState DiscordBotState
|
||||||
|
{
|
||||||
|
get { return (DiscordBot.Enums.BotState)GetValue(DiscordBotStateProperty); }
|
||||||
|
set { SetValue(DiscordBotStateProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DiscordBotStateString
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(DiscordBotStateStringProperty); }
|
||||||
|
set { SetValue(DiscordBotStateStringProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsAdministrator
|
public bool IsAdministrator
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
@ -191,6 +209,7 @@ namespace ServerManagerTool
|
||||||
|
|
||||||
this.versionChecker.PostAction(CheckForUpdates).DoNotWait();
|
this.versionChecker.PostAction(CheckForUpdates).DoNotWait();
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_LocationChanged(object sender, EventArgs e)
|
private void MainWindow_LocationChanged(object sender, EventArgs e)
|
||||||
|
|
@ -254,6 +273,7 @@ namespace ServerManagerTool
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
||||||
|
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PatchNotes_Click(object sender, RoutedEventArgs e)
|
private void PatchNotes_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -571,6 +591,36 @@ namespace ServerManagerTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void DiscordBotTaskState_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (discordBotStateClicked)
|
||||||
|
return;
|
||||||
|
discordBotStateClicked = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (DiscordBotState)
|
||||||
|
{
|
||||||
|
case DiscordBot.Enums.BotState.Stopped:
|
||||||
|
AppInstance.StartDiscordBot();
|
||||||
|
break;
|
||||||
|
case DiscordBot.Enums.BotState.Running:
|
||||||
|
AppInstance.StopDiscordBot();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(5000);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
discordBotStateClicked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ICommand ShowWindowCommand
|
public ICommand ShowWindowCommand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -662,8 +712,8 @@ namespace ServerManagerTool
|
||||||
this.AutoBackupState = backupState;
|
this.AutoBackupState = backupState;
|
||||||
this.AutoUpdateState = updateState;
|
this.AutoUpdateState = updateState;
|
||||||
|
|
||||||
this.AutoBackupStateString = GetTaskStateString(AutoBackupState);
|
this.AutoBackupStateString = GetTaskSchedulerStateString(AutoBackupState);
|
||||||
this.AutoUpdateStateString = GetTaskStateString(AutoUpdateState);
|
this.AutoUpdateStateString = GetTaskSchedulerStateString(AutoUpdateState);
|
||||||
|
|
||||||
this.AutoBackupNextRunTime = backupnextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {backupnextRunTime:G}";
|
this.AutoBackupNextRunTime = backupnextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {backupnextRunTime:G}";
|
||||||
this.AutoUpdateNextRunTime = updatenextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {updatenextRunTime:G}";
|
this.AutoUpdateNextRunTime = updatenextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {updatenextRunTime:G}";
|
||||||
|
|
@ -680,7 +730,46 @@ namespace ServerManagerTool
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTaskStateString(Microsoft.Win32.TaskScheduler.TaskState taskState)
|
private async Task CheckForDiscordBot()
|
||||||
|
{
|
||||||
|
TaskUtils.RunOnUIThreadAsync(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var botState = DiscordBot.Enums.BotState.Unknown;
|
||||||
|
if (AppInstance.DiscordBotStarted)
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Running;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Config.DiscordBotEnabled)
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Stopped;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Disabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DiscordBotState = botState;
|
||||||
|
|
||||||
|
this.DiscordBotStateString = GetDiscordBotStateString(botState);
|
||||||
|
|
||||||
|
Logger.Info($"{nameof(CheckForDiscordBot)} performed");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
}).DoNotWait();
|
||||||
|
|
||||||
|
await Task.Delay(Config.Default.DiscordBotStatusCheckTime * 1 * 1000);
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetTaskSchedulerStateString(Microsoft.Win32.TaskScheduler.TaskState taskState)
|
||||||
{
|
{
|
||||||
switch (taskState)
|
switch (taskState)
|
||||||
{
|
{
|
||||||
|
|
@ -699,6 +788,21 @@ namespace ServerManagerTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDiscordBotStateString(DiscordBot.Enums.BotState botState)
|
||||||
|
{
|
||||||
|
switch (botState)
|
||||||
|
{
|
||||||
|
case DiscordBot.Enums.BotState.Disabled:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateDisabledLabel");
|
||||||
|
case DiscordBot.Enums.BotState.Running:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateRunningLabel");
|
||||||
|
case DiscordBot.Enums.BotState.Stopped:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateStoppedLabel");
|
||||||
|
default:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateUnknownLabel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task StartServerAsync(Server server)
|
private async Task StartServerAsync(Server server)
|
||||||
{
|
{
|
||||||
if (server == null || server.Profile == null || server.Runtime == null || server.Runtime.Status != ServerStatus.Stopped)
|
if (server == null || server.Profile == null || server.Runtime == null || server.Runtime.Status != ServerStatus.Stopped)
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,9 @@
|
||||||
<setting name="DiscordBotHelpUrl" serializeAs="String">
|
<setting name="DiscordBotHelpUrl" serializeAs="String">
|
||||||
<value>https://servermanagers.freeforums.net/thread/99/get-own-discord-bot</value>
|
<value>https://servermanagers.freeforums.net/thread/99/get-own-discord-bot</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="DiscordBotStatusCheckTime" serializeAs="String">
|
||||||
|
<value>10</value>
|
||||||
|
</setting>
|
||||||
</ServerManagerTool.Config>
|
</ServerManagerTool.Config>
|
||||||
<ServerManagerTool.Common.CommonConfig>
|
<ServerManagerTool.Common.CommonConfig>
|
||||||
<setting name="DefaultSteamAPIKey" serializeAs="String">
|
<setting name="DefaultSteamAPIKey" serializeAs="String">
|
||||||
|
|
|
||||||
9
src/ConanServerManager/Config.Designer.cs
generated
9
src/ConanServerManager/Config.Designer.cs
generated
|
|
@ -2176,5 +2176,14 @@ namespace ServerManagerTool {
|
||||||
this["DiscordBotLogLevel"] = value;
|
this["DiscordBotLogLevel"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("10")]
|
||||||
|
public int DiscordBotStatusCheckTime {
|
||||||
|
get {
|
||||||
|
return ((int)(this["DiscordBotStatusCheckTime"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -600,5 +600,8 @@
|
||||||
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
||||||
<Value Profile="(Default)">Info</Value>
|
<Value Profile="(Default)">Info</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="DiscordBotStatusCheckTime" Type="System.Int32" Scope="Application">
|
||||||
|
<Value Profile="(Default)">10</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
|
|
@ -615,12 +615,18 @@
|
||||||
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableLabel">Enable</sys:String>
|
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableLabel">Enable</sys:String>
|
||||||
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableTooltip">Enable the auto-update scheduled task</sys:String>
|
<sys:String x:Key="MainWindow_AutoUpdateTaskEnableTooltip">Enable the auto-update scheduled task</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskRunTimeLabel">Next Run Time:</sys:String>
|
<sys:String x:Key="MainWindow_TaskRunTimeLabel">Next Run Time:</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotStatusLabel">Discord Bot:</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStartLabel">Start</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStartTooltip">Start the discord bot</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStopLabel">Stop</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_DiscordBotTaskStopTooltip">Stop the discord bot</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="MainWindow_TaskStateUnknownLabel">Unknown</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateUnknownLabel">Unknown</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateDisabledLabel">Disabled</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateDisabledLabel">Disabled</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateQueuedLabel">Queued</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateQueuedLabel">Queued</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateReadyLabel">Ready</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateReadyLabel">Ready</sys:String>
|
||||||
<sys:String x:Key="MainWindow_TaskStateRunningLabel">Running</sys:String>
|
<sys:String x:Key="MainWindow_TaskStateRunningLabel">Running</sys:String>
|
||||||
|
<sys:String x:Key="MainWindow_TaskStateStoppedLabel">Stopped</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="MainWindow_ProfileLoad_FailedTitle">Profile failed to load</sys:String>
|
<sys:String x:Key="MainWindow_ProfileLoad_FailedTitle">Profile failed to load</sys:String>
|
||||||
<sys:String x:Key="MainWindow_ProfileLoad_FailedLabel">The profile at {0} failed to load. The error was: {1}\r\n{2}</sys:String>
|
<sys:String x:Key="MainWindow_ProfileLoad_FailedLabel">The profile at {0} failed to load. The error was: {1}\r\n{2}</sys:String>
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
|
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
|
||||||
<title>1.1.58 (1.1.58.5)</title>
|
<title>1.1.58 (1.1.58.7)</title>
|
||||||
<summary>1.1.58.5</summary>
|
<summary>1.1.58.7</summary>
|
||||||
<link href="" />
|
<link href="" />
|
||||||
<updated>2021-12-16T00:00:00Z</updated>
|
<updated>2021-12-16T00:00:00Z</updated>
|
||||||
<content type="xhtml">
|
<content type="xhtml">
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
<li>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
<li>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
||||||
<li>Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.</li>
|
<li>Global Settings - Discord Bot section - Added a whitelist to allow bots to send commands to the server manager.</li>
|
||||||
<li>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
<li>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
||||||
|
<li>Main Window - Added Discord Bot Status and a button to Stop/Start the discord bot.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<u style="font-size: .9em;">CHANGE</u>
|
<u style="font-size: .9em;">CHANGE</u>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,29 @@
|
||||||
<link href="http://servermanagers.freeforums.net/" />
|
<link href="http://servermanagers.freeforums.net/" />
|
||||||
<updated>2021-12-17T00:00:00Z</updated>
|
<updated>2021-12-17T00:00:00Z</updated>
|
||||||
|
|
||||||
|
<entry>
|
||||||
|
<id>urn:uuid:9A427D82-9904-44F5-8C1E-7C943049869A</id>
|
||||||
|
<title>1.1.58 (1.1.58.7)</title>
|
||||||
|
<summary>1.1.58.7</summary>
|
||||||
|
<link href="" />
|
||||||
|
<updated>2021-12-17T00:00:00Z</updated>
|
||||||
|
<content type="xhtml">
|
||||||
|
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||||
|
<p>
|
||||||
|
<u style="font-size: .9em;">NEW</u>
|
||||||
|
<br/>
|
||||||
|
<ul>
|
||||||
|
<li>Main Window - Added Discord Bot Status and a button to Stop/Start the discord bot.</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</content>
|
||||||
|
<author>
|
||||||
|
<name>bletch</name>
|
||||||
|
<email>bletch1971@hotmail.com</email>
|
||||||
|
</author>
|
||||||
|
</entry>
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
<id>urn:uuid:A189668E-DA03-471A-9C5A-7FF2A7264F9C</id>
|
<id>urn:uuid:A189668E-DA03-471A-9C5A-7FF2A7264F9C</id>
|
||||||
<title>1.1.58 (1.1.58.6)</title>
|
<title>1.1.58 (1.1.58.6)</title>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
|
xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
|
||||||
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
||||||
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
|
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
|
||||||
|
xmlns:bot="clr-namespace:ServerManagerTool.DiscordBot;assembly=ServerManager.Discord"
|
||||||
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
|
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
|
||||||
Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
|
Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
|
||||||
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
|
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
|
||||||
|
|
@ -128,6 +129,7 @@
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Label Grid.Row="0" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontSize="11" Content="{DynamicResource MainWindow_TaskStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<Label Grid.Row="0" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontSize="11" Content="{DynamicResource MainWindow_TaskStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||||
|
|
@ -253,6 +255,61 @@
|
||||||
</Button.Style>
|
</Button.Style>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
|
||||||
|
<Label Margin="0" Background="Transparent" Foreground="White" FontSize="10" Content="{DynamicResource MainWindow_DiscordBotStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||||
|
<Label Margin="0" Background="Transparent" FontSize="10" Content="{Binding DiscordBotStateString}" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||||
|
<Label.Style>
|
||||||
|
<Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Disabled}">
|
||||||
|
<Setter Property="Foreground" Value="DarkRed"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Stopped}">
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Running}">
|
||||||
|
<Setter Property="Foreground" Value="LightGreen"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Label.Style>
|
||||||
|
</Label>
|
||||||
|
<Button Margin="5,0,0,0" Padding="1" BorderThickness="1" BorderBrush="White" Click="DiscordBotTaskState_Click" VerticalAlignment="Center">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="{x:Type Button}">
|
||||||
|
<Setter Property="Background" Value="#00AA00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Collapsed"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<MultiDataTrigger>
|
||||||
|
<MultiDataTrigger.Conditions>
|
||||||
|
<Condition Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Stopped}"/>
|
||||||
|
</MultiDataTrigger.Conditions>
|
||||||
|
<Setter Property="Background" Value="#00AA00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</MultiDataTrigger>
|
||||||
|
<MultiDataTrigger>
|
||||||
|
<MultiDataTrigger.Conditions>
|
||||||
|
<Condition Binding="{Binding DiscordBotState}" Value="{x:Static bot:Enums.BotState.Running}"/>
|
||||||
|
</MultiDataTrigger.Conditions>
|
||||||
|
<Setter Property="Background" Value="#AA8A00"/>
|
||||||
|
<Setter Property="Foreground" Value="White"/>
|
||||||
|
<Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStopLabel}"/>
|
||||||
|
<Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStopTooltip}"/>
|
||||||
|
<Setter Property="Visibility" Value="Visible"/>
|
||||||
|
</MultiDataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid DockPanel.Dock="Top" VerticalAlignment="Top" Margin="10,0,10,0" HorizontalAlignment="Center">
|
<Grid DockPanel.Dock="Top" VerticalAlignment="Top" Margin="10,0,10,0" HorizontalAlignment="Center">
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ namespace ServerManagerTool
|
||||||
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||||
private readonly ActionQueue versionChecker;
|
private readonly ActionQueue versionChecker;
|
||||||
private readonly ActionQueue scheduledTaskChecker;
|
private readonly ActionQueue scheduledTaskChecker;
|
||||||
|
private readonly ActionQueue discordBotChecker;
|
||||||
|
|
||||||
|
private bool discordBotStateClicked = false;
|
||||||
|
|
||||||
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(MainWindow), new PropertyMetadata(null));
|
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(MainWindow), new PropertyMetadata(null));
|
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(MainWindow), new PropertyMetadata(null));
|
||||||
|
|
@ -40,6 +43,8 @@ namespace ServerManagerTool
|
||||||
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
public static readonly DependencyProperty AutoUpdateStateProperty = DependencyProperty.Register(nameof(AutoUpdateState), typeof(Microsoft.Win32.TaskScheduler.TaskState), typeof(MainWindow), new PropertyMetadata(Microsoft.Win32.TaskScheduler.TaskState.Unknown));
|
||||||
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateStateStringProperty = DependencyProperty.Register(nameof(AutoUpdateStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty AutoUpdateNextRunTimeProperty = DependencyProperty.Register(nameof(AutoUpdateNextRunTime), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
|
public static readonly DependencyProperty DiscordBotStateProperty = DependencyProperty.Register(nameof(DiscordBotState), typeof(DiscordBot.Enums.BotState), typeof(MainWindow), new PropertyMetadata(DiscordBot.Enums.BotState.Unknown));
|
||||||
|
public static readonly DependencyProperty DiscordBotStateStringProperty = DependencyProperty.Register(nameof(DiscordBotStateString), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsIpValidProperty = DependencyProperty.Register(nameof(IsIpValid), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
public static readonly DependencyProperty LatestServerManagerVersionProperty = DependencyProperty.Register(nameof(LatestServerManagerVersion), typeof(Version), typeof(MainWindow), new PropertyMetadata(new Version()));
|
||||||
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
public static readonly DependencyProperty NewServerManagerAvailableProperty = DependencyProperty.Register(nameof(NewServerManagerAvailable), typeof(bool), typeof(MainWindow), new PropertyMetadata(false));
|
||||||
|
|
@ -57,6 +62,7 @@ namespace ServerManagerTool
|
||||||
this.DataContext = this;
|
this.DataContext = this;
|
||||||
this.versionChecker = new ActionQueue();
|
this.versionChecker = new ActionQueue();
|
||||||
this.scheduledTaskChecker = new ActionQueue();
|
this.scheduledTaskChecker = new ActionQueue();
|
||||||
|
this.discordBotChecker = new ActionQueue();
|
||||||
|
|
||||||
IsAdministrator = SecurityUtils.IsAdministrator();
|
IsAdministrator = SecurityUtils.IsAdministrator();
|
||||||
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
if (!string.IsNullOrWhiteSpace(App.Instance.Title))
|
||||||
|
|
@ -139,6 +145,18 @@ namespace ServerManagerTool
|
||||||
set { SetValue(AutoUpdateNextRunTimeProperty, value); }
|
set { SetValue(AutoUpdateNextRunTimeProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DiscordBot.Enums.BotState DiscordBotState
|
||||||
|
{
|
||||||
|
get { return (DiscordBot.Enums.BotState)GetValue(DiscordBotStateProperty); }
|
||||||
|
set { SetValue(DiscordBotStateProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DiscordBotStateString
|
||||||
|
{
|
||||||
|
get { return (string)GetValue(DiscordBotStateStringProperty); }
|
||||||
|
set { SetValue(DiscordBotStateStringProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsAdministrator
|
public bool IsAdministrator
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
@ -191,6 +209,7 @@ namespace ServerManagerTool
|
||||||
|
|
||||||
this.versionChecker.PostAction(CheckForUpdates).DoNotWait();
|
this.versionChecker.PostAction(CheckForUpdates).DoNotWait();
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_LocationChanged(object sender, EventArgs e)
|
private void MainWindow_LocationChanged(object sender, EventArgs e)
|
||||||
|
|
@ -254,6 +273,7 @@ namespace ServerManagerTool
|
||||||
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
this.Title = _globalizer.GetResourceString("MainWindow_Title");
|
||||||
|
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PatchNotes_Click(object sender, RoutedEventArgs e)
|
private void PatchNotes_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -563,6 +583,36 @@ namespace ServerManagerTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void DiscordBotTaskState_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (discordBotStateClicked)
|
||||||
|
return;
|
||||||
|
discordBotStateClicked = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (DiscordBotState)
|
||||||
|
{
|
||||||
|
case DiscordBot.Enums.BotState.Stopped:
|
||||||
|
AppInstance.StartDiscordBot();
|
||||||
|
break;
|
||||||
|
case DiscordBot.Enums.BotState.Running:
|
||||||
|
AppInstance.StopDiscordBot();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(5000);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
discordBotStateClicked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ICommand ShowWindowCommand
|
public ICommand ShowWindowCommand
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -654,8 +704,8 @@ namespace ServerManagerTool
|
||||||
this.AutoBackupState = backupState;
|
this.AutoBackupState = backupState;
|
||||||
this.AutoUpdateState = updateState;
|
this.AutoUpdateState = updateState;
|
||||||
|
|
||||||
this.AutoBackupStateString = GetTaskStateString(AutoBackupState);
|
this.AutoBackupStateString = GetTaskSchedulerStateString(AutoBackupState);
|
||||||
this.AutoUpdateStateString = GetTaskStateString(AutoUpdateState);
|
this.AutoUpdateStateString = GetTaskSchedulerStateString(AutoUpdateState);
|
||||||
|
|
||||||
this.AutoBackupNextRunTime = backupnextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {backupnextRunTime:G}";
|
this.AutoBackupNextRunTime = backupnextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {backupnextRunTime:G}";
|
||||||
this.AutoUpdateNextRunTime = updatenextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {updatenextRunTime:G}";
|
this.AutoUpdateNextRunTime = updatenextRunTime == DateTime.MinValue ? string.Empty : $"{_globalizer.GetResourceString("MainWindow_TaskRunTimeLabel")} {updatenextRunTime:G}";
|
||||||
|
|
@ -672,7 +722,46 @@ namespace ServerManagerTool
|
||||||
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetTaskStateString(Microsoft.Win32.TaskScheduler.TaskState taskState)
|
private async Task CheckForDiscordBot()
|
||||||
|
{
|
||||||
|
TaskUtils.RunOnUIThreadAsync(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var botState = DiscordBot.Enums.BotState.Unknown;
|
||||||
|
if (AppInstance.DiscordBotStarted)
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Running;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Config.DiscordBotEnabled)
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Stopped;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
botState = DiscordBot.Enums.BotState.Disabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DiscordBotState = botState;
|
||||||
|
|
||||||
|
this.DiscordBotStateString = GetDiscordBotStateString(botState);
|
||||||
|
|
||||||
|
Logger.Info($"{nameof(CheckForDiscordBot)} performed");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// Ignore.
|
||||||
|
}
|
||||||
|
}).DoNotWait();
|
||||||
|
|
||||||
|
await Task.Delay(Config.Default.DiscordBotStatusCheckTime * 1 * 1000);
|
||||||
|
this.discordBotChecker.PostAction(CheckForDiscordBot).DoNotWait();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetTaskSchedulerStateString(Microsoft.Win32.TaskScheduler.TaskState taskState)
|
||||||
{
|
{
|
||||||
switch (taskState)
|
switch (taskState)
|
||||||
{
|
{
|
||||||
|
|
@ -691,6 +780,21 @@ namespace ServerManagerTool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDiscordBotStateString(DiscordBot.Enums.BotState botState)
|
||||||
|
{
|
||||||
|
switch (botState)
|
||||||
|
{
|
||||||
|
case DiscordBot.Enums.BotState.Disabled:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateDisabledLabel");
|
||||||
|
case DiscordBot.Enums.BotState.Running:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateRunningLabel");
|
||||||
|
case DiscordBot.Enums.BotState.Stopped:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateStoppedLabel");
|
||||||
|
default:
|
||||||
|
return _globalizer.GetResourceString("MainWindow_TaskStateUnknownLabel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task StartServerAsync(Server server)
|
private async Task StartServerAsync(Server server)
|
||||||
{
|
{
|
||||||
if (server == null || server.Profile == null || server.Runtime == null || server.Runtime.Status != ServerStatus.Stopped)
|
if (server == null || server.Profile == null || server.Runtime == null || server.Runtime.Status != ServerStatus.Stopped)
|
||||||
|
|
|
||||||
10
src/ServerManager.Discord/Enums/BotStatus.cs
Normal file
10
src/ServerManager.Discord/Enums/BotStatus.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace ServerManagerTool.DiscordBot.Enums
|
||||||
|
{
|
||||||
|
public enum BotState
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
Disabled,
|
||||||
|
Stopped,
|
||||||
|
Running,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,17 +30,17 @@ namespace ServerManagerTool.DiscordBot
|
||||||
|
|
||||||
public async Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
|
public async Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token)
|
||||||
{
|
{
|
||||||
if (Started)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Started = true;
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(commandPrefix) || string.IsNullOrWhiteSpace(discordToken) || handleTranslationCallback is null || handleCommandCallback is null)
|
if (string.IsNullOrWhiteSpace(commandPrefix) || string.IsNullOrWhiteSpace(discordToken) || handleTranslationCallback is null || handleCommandCallback is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Started)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Started = true;
|
||||||
Token = token;
|
Token = token;
|
||||||
|
|
||||||
var settings = new Dictionary<string, string>
|
var settings = new Dictionary<string, string>
|
||||||
|
|
@ -121,6 +121,7 @@ namespace ServerManagerTool.DiscordBot
|
||||||
}
|
}
|
||||||
|
|
||||||
await provider?.GetRequiredService<ShutdownService>().StopAsync();
|
await provider?.GetRequiredService<ShutdownService>().StopAsync();
|
||||||
|
Started = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue