mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added a log level droplist
This commit is contained in:
parent
708031dcbb
commit
430bfe7bbb
21 changed files with 224 additions and 59 deletions
|
|
@ -814,7 +814,7 @@
|
|||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotPrefix" serializeAs="String">
|
||||
<value>asm</value>
|
||||
<value>asm!</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotToken" serializeAs="String">
|
||||
<value />
|
||||
|
|
@ -851,14 +851,15 @@
|
|||
</setting>
|
||||
<setting name="DiscordBotWhitelist" serializeAs="Xml">
|
||||
<value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string />
|
||||
</ArrayOfString>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
|
||||
</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotPrefixFixed" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotLogLevel" serializeAs="String">
|
||||
<value>Info</value>
|
||||
</setting>
|
||||
</ServerManagerTool.Config>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -287,7 +287,8 @@ namespace ServerManagerTool
|
|||
}
|
||||
if (!Config.Default.DiscordBotPrefixFixed)
|
||||
{
|
||||
Config.Default.DiscordBotPrefix += "!";
|
||||
if (!Config.Default.DiscordBotPrefix.EndsWith("!"))
|
||||
Config.Default.DiscordBotPrefix += "!";
|
||||
Config.Default.DiscordBotPrefixFixed = true;
|
||||
Config.Default.Save();
|
||||
Config.Default.Reload();
|
||||
|
|
@ -507,7 +508,7 @@ namespace ServerManagerTool
|
|||
discordWhiteList.AddRange(Config.Default.DiscordBotWhitelist.Cast<string>());
|
||||
}
|
||||
|
||||
await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
|
||||
await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken, Config.Default.DiscordBotPrefix, Config.Default.DataDir, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
|
||||
}, _tokenSource.Token)
|
||||
.ContinueWith(t => {
|
||||
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;
|
||||
|
|
|
|||
17
src/ARKServerManager/Config.Designer.cs
generated
17
src/ARKServerManager/Config.Designer.cs
generated
|
|
@ -2827,7 +2827,7 @@ namespace ServerManagerTool {
|
|||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("asm")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("asm!")]
|
||||
public string DiscordBotPrefix {
|
||||
get {
|
||||
return ((string)(this["DiscordBotPrefix"]));
|
||||
|
|
@ -2990,8 +2990,7 @@ namespace ServerManagerTool {
|
|||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
|
||||
"tring />\r\n</ArrayOfString>")]
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />")]
|
||||
public global::System.Collections.Specialized.StringCollection DiscordBotWhitelist {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["DiscordBotWhitelist"]));
|
||||
|
|
@ -3012,5 +3011,17 @@ namespace ServerManagerTool {
|
|||
this["DiscordBotPrefixFixed"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Info")]
|
||||
public global::ServerManagerTool.DiscordBot.Enums.LogLevel DiscordBotLogLevel {
|
||||
get {
|
||||
return ((global::ServerManagerTool.DiscordBot.Enums.LogLevel)(this["DiscordBotLogLevel"]));
|
||||
}
|
||||
set {
|
||||
this["DiscordBotLogLevel"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -783,7 +783,7 @@
|
|||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotPrefix" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">asm</Value>
|
||||
<Value Profile="(Default)">asm!</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotToken" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
|
|
@ -826,12 +826,13 @@
|
|||
</Setting>
|
||||
<Setting Name="DiscordBotWhitelist" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string />
|
||||
</ArrayOfString></Value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /></Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotPrefixFixed" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
||||
<Value Profile="(Default)">Info</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
|
@ -83,12 +83,21 @@
|
|||
<sys:String x:Key="ProcessorAffinity_All">All</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Processor Window States -->
|
||||
<!--#region Window States -->
|
||||
<sys:String x:Key="WindowState_Normal">Normal</sys:String>
|
||||
<sys:String x:Key="WindowState_Minimized">Minimized</sys:String>
|
||||
<sys:String x:Key="WindowState_Maximized">Maximized</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Discord Bot Log Levels -->
|
||||
<sys:String x:Key="DiscordBotLogLevel_Critical">Critical</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Error">Error</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Warning">Warning</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Info">Info</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Verbose">Verbose</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Debug">Debug</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Application -->
|
||||
<sys:String x:Key="Application_RunAsAdministratorTitle">Run as Administrator</sys:String>
|
||||
<sys:String x:Key="Application_RunAsAdministratorLabel">This application requires administration priviledges to access ALL functionality. Would you like to Run as Administrator?</sys:String>
|
||||
|
|
@ -622,6 +631,7 @@
|
|||
<sys:String x:Key="GlobalSettings_DiscordBotServerTooltip">The id of the discord server the bot will listen to.</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotPrefixLabel">Prefix:</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotPrefixTooltip">The prefix that must be used when sending a command via discord.</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotLogLevelLabel">Log Level:</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotApplyButtonLabel">Get Token...</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotHelpButtonLabel">Help...</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotWhitelistLabel">Bot Whitelist</sys:String>
|
||||
|
|
|
|||
|
|
@ -618,6 +618,8 @@
|
|||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding Config.DiscordBotServerId}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotServerTooltip}"/>
|
||||
<Label Grid.Row="2" Grid.Column="3" Content="{DynamicResource GlobalSettings_DiscordBotPrefixLabel}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="4" Margin="1" Text="{Binding Config.DiscordBotPrefix}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotPrefixTooltip}"/>
|
||||
<Label Grid.Row="2" Grid.Column="6" Margin="1" Content="{DynamicResource GlobalSettings_DiscordBotLogLevelLabel}" VerticalAlignment="Center"/>
|
||||
<ComboBox Name="DiscordBotLogLevelComboBox" Grid.Row="2" Grid.Column="7" Margin="1" ItemsSource="{Binding ElementName=GlobalSettings, Path=DiscordBotLogLevels}" SelectedValue="{Binding Config.DiscordBotLogLevel}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" VerticalContentAlignment="Center" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1" Margin="0,5,0,0" IsChecked="{Binding Config.AllowDiscordBackup}" Content="{DynamicResource ServerSettings_AllowDiscordBackupLabel}" HorizontalAlignment="Left" ToolTip="{DynamicResource GlobalSettings_DiscordBotAllowBackupTooltip}"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="4" Margin="0,5,0,0" IsChecked="{Binding Config.AllowDiscordUpdate}" Content="{DynamicResource ServerSettings_AllowDiscordUpdateLabel}" HorizontalAlignment="Left" ToolTip="{DynamicResource GlobalSettings_DiscordBotAllowUpdateTooltip}"/>
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ namespace ServerManagerTool
|
|||
public static readonly DependencyProperty ConfigProperty = DependencyProperty.Register(nameof(Config), typeof(Config), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty CommonConfigProperty = DependencyProperty.Register(nameof(CommonConfig), typeof(CommonConfig), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelist>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
|
||||
public GlobalSettingsControl()
|
||||
|
|
@ -43,7 +44,11 @@ namespace ServerManagerTool
|
|||
this.CommonConfig = CommonConfig.Default;
|
||||
this.DataContext = this;
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
PopulateWindowsStatesComboBox();
|
||||
PopulateDiscordBotLogLevelsComboBox();
|
||||
|
||||
DiscordBotWhitelist = new List<DiscordBotWhitelist>();
|
||||
if (Config.DiscordBotWhitelist != null)
|
||||
|
|
@ -54,9 +59,6 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
this.IsAdministrator = SecurityUtils.IsAdministrator();
|
||||
}
|
||||
|
||||
|
|
@ -90,6 +92,12 @@ namespace ServerManagerTool
|
|||
set { SetValue(WindowStatesProperty, value); }
|
||||
}
|
||||
|
||||
public ComboBoxItemList DiscordBotLogLevels
|
||||
{
|
||||
get { return (ComboBoxItemList)GetValue(DiscordBotLogLevelsProperty); }
|
||||
set { SetValue(DiscordBotLogLevelsProperty, value); }
|
||||
}
|
||||
|
||||
public List<DiscordBotWhitelist> DiscordBotWhitelist
|
||||
{
|
||||
get { return (List<DiscordBotWhitelist>)GetValue(DiscordBotWhitelistProperty); }
|
||||
|
|
@ -476,21 +484,39 @@ namespace ServerManagerTool
|
|||
private void PopulateWindowsStatesComboBox()
|
||||
{
|
||||
var selectedValue = this.WindowStateComboBox?.SelectedValue ?? Config.MainWindow_WindowState;
|
||||
var windowStates = new ComboBoxItemList();
|
||||
var comboBoxList = new ComboBoxItemList();
|
||||
|
||||
foreach (WindowState windowState in Enum.GetValues(typeof(WindowState)))
|
||||
{
|
||||
var displayMember = _globalizer.GetResourceString($"WindowState_{windowState}") ?? windowState.ToString();
|
||||
windowStates.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
|
||||
comboBoxList.Add(new Common.Model.ComboBoxItem(windowState.ToString(), displayMember));
|
||||
}
|
||||
|
||||
this.WindowStates = windowStates;
|
||||
this.WindowStates = comboBoxList;
|
||||
if (this.WindowStateComboBox != null)
|
||||
{
|
||||
this.WindowStateComboBox.SelectedValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
private void PopulateDiscordBotLogLevelsComboBox()
|
||||
{
|
||||
var selectedValue = this.DiscordBotLogLevelComboBox?.SelectedValue ?? Config.DiscordBotLogLevel;
|
||||
var comboBoxList = new ComboBoxItemList();
|
||||
|
||||
foreach (DiscordBot.Enums.LogLevel logLevel in Enum.GetValues(typeof(DiscordBot.Enums.LogLevel)))
|
||||
{
|
||||
var displayMember = _globalizer.GetResourceString($"DiscordBotLogLevel_{logLevel}") ?? logLevel.ToString();
|
||||
comboBoxList.Add(new Common.Model.ComboBoxItem(logLevel.ToString(), displayMember));
|
||||
}
|
||||
|
||||
this.DiscordBotLogLevels = comboBoxList;
|
||||
if (this.DiscordBotLogLevelComboBox != null)
|
||||
{
|
||||
this.DiscordBotLogLevelComboBox.SelectedValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
#region Discord Bot Whitelist
|
||||
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<entry>
|
||||
<id>urn:uuid:3E33DCB2-ECFE-4489-B1A4-56F5D386F9DC</id>
|
||||
<title>1.1.413 (1.1.413.4)</title>
|
||||
<summary>1.1.413.4</summary>
|
||||
<title>1.1.413 (1.1.413.5)</title>
|
||||
<summary>1.1.413.5</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-16T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
<u style="font-size: .9em;">NEW</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<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>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@
|
|||
<link href="http://arkservermanager.freeforums.net/" />
|
||||
<updated>2021-12-16T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:65A7E6B1-98D1-422D-B42F-B0EBB1D20E41</id>
|
||||
<title>1.1.413 (1.1.413.5)</title>
|
||||
<summary>1.1.413.5</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-16T00: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>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:98FFBFA1-4E99-4801-BF2B-CA68BE300C27</id>
|
||||
<title>1.1.413 (1.1.413.4)</title>
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@
|
|||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotPrefix" serializeAs="String">
|
||||
<value>csm</value>
|
||||
<value>csm!</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotToken" serializeAs="String">
|
||||
<value />
|
||||
|
|
@ -617,14 +617,15 @@
|
|||
</setting>
|
||||
<setting name="DiscordBotWhitelist" serializeAs="Xml">
|
||||
<value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string />
|
||||
</ArrayOfString>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
|
||||
</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotPrefixFixed" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DiscordBotLogLevel" serializeAs="String">
|
||||
<value>Info</value>
|
||||
</setting>
|
||||
</ServerManagerTool.Config>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
|
@ -280,7 +280,8 @@ namespace ServerManagerTool
|
|||
}
|
||||
if (!Config.Default.DiscordBotPrefixFixed)
|
||||
{
|
||||
Config.Default.DiscordBotPrefix += "!";
|
||||
if (!Config.Default.DiscordBotPrefix.EndsWith("!"))
|
||||
Config.Default.DiscordBotPrefix += "!";
|
||||
Config.Default.DiscordBotPrefixFixed = true;
|
||||
Config.Default.Save();
|
||||
Config.Default.Reload();
|
||||
|
|
@ -488,7 +489,7 @@ namespace ServerManagerTool
|
|||
discordWhiteList.AddRange(Config.Default.DiscordBotWhitelist.Cast<string>());
|
||||
}
|
||||
|
||||
await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotToken,Config.Default.DiscordBotPrefix, Config.Default.DataPath, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
|
||||
await ServerManagerBotFactory.GetServerManagerBot()?.StartAsync(Config.Default.DiscordBotLogLevel, Config.Default.DiscordBotToken,Config.Default.DiscordBotPrefix, Config.Default.DataPath, discordWhiteList, DiscordBotHelper.HandleDiscordCommand, DiscordBotHelper.HandleTranslation, _tokenSource.Token);
|
||||
}, _tokenSource.Token)
|
||||
.ContinueWith(t => {
|
||||
var message = t.Exception.InnerException is null ? t.Exception.Message : t.Exception.InnerException.Message;
|
||||
|
|
|
|||
17
src/ConanServerManager/Config.Designer.cs
generated
17
src/ConanServerManager/Config.Designer.cs
generated
|
|
@ -1980,7 +1980,7 @@ namespace ServerManagerTool {
|
|||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("csm")]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("csm!")]
|
||||
public string DiscordBotPrefix {
|
||||
get {
|
||||
return ((string)(this["DiscordBotPrefix"]));
|
||||
|
|
@ -2143,8 +2143,7 @@ namespace ServerManagerTool {
|
|||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
|
||||
"tring />\r\n</ArrayOfString>")]
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />")]
|
||||
public global::System.Collections.Specialized.StringCollection DiscordBotWhitelist {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["DiscordBotWhitelist"]));
|
||||
|
|
@ -2165,5 +2164,17 @@ namespace ServerManagerTool {
|
|||
this["DiscordBotPrefixFixed"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("Info")]
|
||||
public global::ServerManagerTool.DiscordBot.Enums.LogLevel DiscordBotLogLevel {
|
||||
get {
|
||||
return ((global::ServerManagerTool.DiscordBot.Enums.LogLevel)(this["DiscordBotLogLevel"]));
|
||||
}
|
||||
set {
|
||||
this["DiscordBotLogLevel"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@
|
|||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotPrefix" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">csm</Value>
|
||||
<Value Profile="(Default)">csm!</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotToken" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
|
|
@ -592,12 +592,13 @@
|
|||
</Setting>
|
||||
<Setting Name="DiscordBotWhitelist" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string />
|
||||
</ArrayOfString></Value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /></Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotPrefixFixed" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DiscordBotLogLevel" Type="ServerManagerTool.DiscordBot.Enums.LogLevel" Scope="User">
|
||||
<Value Profile="(Default)">Info</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
|
@ -57,12 +57,21 @@
|
|||
<sys:String x:Key="ProcessorAffinity_All">All</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Processor Window States -->
|
||||
<!--#region Window States -->
|
||||
<sys:String x:Key="WindowState_Normal">Normal</sys:String>
|
||||
<sys:String x:Key="WindowState_Minimized">Minimized</sys:String>
|
||||
<sys:String x:Key="WindowState_Maximized">Maximized</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Discord Bot Log Levels -->
|
||||
<sys:String x:Key="DiscordBotLogLevel_Critical">Critical</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Error">Error</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Warning">Warning</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Info">Info</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Verbose">Verbose</sys:String>
|
||||
<sys:String x:Key="DiscordBotLogLevel_Debug">Debug</sys:String>
|
||||
<!--#endregion-->
|
||||
|
||||
<!--#region Unit strings -->
|
||||
<sys:String x:Key="SliderUnits_Multiplier">x</sys:String>
|
||||
<sys:String x:Key="SliderUnits_Percentage">%</sys:String>
|
||||
|
|
@ -780,6 +789,7 @@
|
|||
<sys:String x:Key="GlobalSettings_DiscordBotServerTooltip">The id of the discord server the bot will listen to.</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotPrefixLabel">Prefix:</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotPrefixTooltip">The prefix that must be used when sending a command via discord.</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotLogLevelLabel">Log Level:</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotApplyButtonLabel">Get Token...</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotHelpButtonLabel">Help...</sys:String>
|
||||
<sys:String x:Key="GlobalSettings_DiscordBotWhitelistLabel">Bot Whitelist</sys:String>
|
||||
|
|
|
|||
|
|
@ -566,6 +566,8 @@
|
|||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding Config.DiscordBotServerId}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotServerTooltip}"/>
|
||||
<Label Grid.Row="2" Grid.Column="3" Content="{DynamicResource GlobalSettings_DiscordBotPrefixLabel}" VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="4" Margin="1" Text="{Binding Config.DiscordBotPrefix}" IsReadOnlyCaretVisible="True" VerticalContentAlignment="Center" ToolTip="{DynamicResource GlobalSettings_DiscordBotPrefixTooltip}"/>
|
||||
<Label Grid.Row="2" Grid.Column="6" Margin="1" Content="{DynamicResource GlobalSettings_DiscordBotLogLevelLabel}" VerticalAlignment="Center"/>
|
||||
<ComboBox Name="DiscordBotLogLevelComboBox" Grid.Row="2" Grid.Column="7" Margin="1" ItemsSource="{Binding ElementName=GlobalSettings, Path=DiscordBotLogLevels}" SelectedValue="{Binding Config.DiscordBotLogLevel}" SelectedValuePath="ValueMember" DisplayMemberPath="DisplayMember" VerticalContentAlignment="Center" PreviewMouseWheel="ComboBox_PreviewMouseWheel"/>
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1" Margin="0,5,0,0" IsChecked="{Binding Config.AllowDiscordBackup}" Content="{DynamicResource ServerSettings_AllowDiscordBackupLabel}" HorizontalAlignment="Left" ToolTip="{DynamicResource GlobalSettings_DiscordBotAllowBackupTooltip}"/>
|
||||
<CheckBox Grid.Row="3" Grid.Column="4" Margin="0,5,0,0" IsChecked="{Binding Config.AllowDiscordUpdate}" Content="{DynamicResource ServerSettings_AllowDiscordUpdateLabel}" HorizontalAlignment="Left" ToolTip="{DynamicResource GlobalSettings_DiscordBotAllowUpdateTooltip}"/>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ namespace ServerManagerTool
|
|||
public static readonly DependencyProperty AppInstanceProperty = DependencyProperty.Register(nameof(AppInstance), typeof(App), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty IsAdministratorProperty = DependencyProperty.Register(nameof(IsAdministrator), typeof(bool), typeof(GlobalSettingsControl), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty WindowStatesProperty = DependencyProperty.Register(nameof(WindowStates), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotLogLevelsProperty = DependencyProperty.Register(nameof(DiscordBotLogLevels), typeof(ComboBoxItemList), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DiscordBotWhitelistProperty = DependencyProperty.Register(nameof(DiscordBotWhitelist), typeof(List<DiscordBotWhitelist>), typeof(GlobalSettingsControl), new PropertyMetadata(null));
|
||||
|
||||
public GlobalSettingsControl()
|
||||
|
|
@ -42,7 +43,11 @@ namespace ServerManagerTool
|
|||
this.IsAdministrator = SecurityUtils.IsAdministrator();
|
||||
this.Version = GetDeployedVersion();
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
PopulateWindowsStatesComboBox();
|
||||
PopulateDiscordBotLogLevelsComboBox();
|
||||
|
||||
DiscordBotWhitelist = new List<DiscordBotWhitelist>();
|
||||
if (Config.DiscordBotWhitelist != null)
|
||||
|
|
@ -53,9 +58,6 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
|
|
@ -95,6 +97,12 @@ namespace ServerManagerTool
|
|||
set;
|
||||
}
|
||||
|
||||
public ComboBoxItemList DiscordBotLogLevels
|
||||
{
|
||||
get { return (ComboBoxItemList)GetValue(DiscordBotLogLevelsProperty); }
|
||||
set { SetValue(DiscordBotLogLevelsProperty, value); }
|
||||
}
|
||||
|
||||
public List<DiscordBotWhitelist> DiscordBotWhitelist
|
||||
{
|
||||
get { return (List<DiscordBotWhitelist>)GetValue(DiscordBotWhitelistProperty); }
|
||||
|
|
@ -500,6 +508,24 @@ namespace ServerManagerTool
|
|||
}
|
||||
}
|
||||
|
||||
private void PopulateDiscordBotLogLevelsComboBox()
|
||||
{
|
||||
var selectedValue = this.DiscordBotLogLevelComboBox?.SelectedValue ?? Config.DiscordBotLogLevel;
|
||||
var comboBoxList = new ComboBoxItemList();
|
||||
|
||||
foreach (DiscordBot.Enums.LogLevel logLevel in Enum.GetValues(typeof(DiscordBot.Enums.LogLevel)))
|
||||
{
|
||||
var displayMember = _globalizer.GetResourceString($"DiscordBotLogLevel_{logLevel}") ?? logLevel.ToString();
|
||||
comboBoxList.Add(new Common.Model.ComboBoxItem(logLevel.ToString(), displayMember));
|
||||
}
|
||||
|
||||
this.DiscordBotLogLevels = comboBoxList;
|
||||
if (this.DiscordBotLogLevelComboBox != null)
|
||||
{
|
||||
this.DiscordBotLogLevelComboBox.SelectedValue = selectedValue;
|
||||
}
|
||||
}
|
||||
|
||||
#region Discord Bot Whitelist
|
||||
private void AddDiscordBotWhitelist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<entry>
|
||||
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
|
||||
<title>1.1.58 (1.1.58.4)</title>
|
||||
<summary>1.1.58.4</summary>
|
||||
<title>1.1.58 (1.1.58.5)</title>
|
||||
<summary>1.1.58.5</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-16T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
<u style="font-size: .9em;">NEW</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<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>Server Settings - Discord Bot section - Added an alias that can be used with the discord command instead of the profile id.</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@
|
|||
<link href="http://servermanagers.freeforums.net/" />
|
||||
<updated>2021-12-16T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:A189668E-DA03-471A-9C5A-7FF2A7264F9C</id>
|
||||
<title>1.1.58 (1.1.58.5)</title>
|
||||
<summary>1.1.58.5</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-16T00: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>Global Settings - Discord Bot section - Added a log level droplist.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:F3C22842-A089-46F7-AB1A-5D3DED105412</id>
|
||||
<title>1.1.58 (1.1.58.4)</title>
|
||||
|
|
|
|||
25
src/ServerManager.Discord/Enums/LogLevel.cs
Normal file
25
src/ServerManager.Discord/Enums/LogLevel.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using Discord;
|
||||
using System;
|
||||
|
||||
namespace ServerManagerTool.DiscordBot.Enums
|
||||
{
|
||||
public enum LogLevel
|
||||
{
|
||||
Critical = 0,
|
||||
Error = 1,
|
||||
Warning = 2,
|
||||
Info = 3,
|
||||
Verbose = 4,
|
||||
Debug = 5
|
||||
}
|
||||
|
||||
public class LogLevelHelper
|
||||
{
|
||||
public static LogSeverity GetLogSeverity(LogLevel logLevel)
|
||||
{
|
||||
if (Enum.TryParse(logLevel.ToString(), out LogSeverity logSeverity))
|
||||
return logSeverity;
|
||||
return LogSeverity.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using ServerManagerTool.DiscordBot.Delegates;
|
||||
using ServerManagerTool.DiscordBot.Enums;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -9,6 +10,6 @@ namespace ServerManagerTool.DiscordBot.Interfaces
|
|||
{
|
||||
CancellationToken Token { get; }
|
||||
|
||||
Task StartAsync(string discordToken, string commandPrefix, string dataDirectory, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token);
|
||||
Task StartAsync(LogLevel logLevel, string discordToken, string commandPrefix, string dataDirectory, IEnumerable<string> botWhitelist, HandleCommandDelegate handleCommandCallback, HandleTranslationDelegate handleTranslationCallback, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Discord.WebSocket;
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ServerManagerTool.DiscordBot.Delegates;
|
||||
using ServerManagerTool.DiscordBot.Enums;
|
||||
using ServerManagerTool.DiscordBot.Interfaces;
|
||||
using ServerManagerTool.DiscordBot.Models;
|
||||
using ServerManagerTool.DiscordBot.Services;
|
||||
|
|
@ -28,7 +29,7 @@ namespace ServerManagerTool.DiscordBot
|
|||
public CancellationToken Token { get; private set; }
|
||||
public bool Started { get; private set; }
|
||||
|
||||
public async Task StartAsync(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)
|
||||
{
|
||||
|
|
@ -43,11 +44,6 @@ namespace ServerManagerTool.DiscordBot
|
|||
|
||||
Token = token;
|
||||
|
||||
//if (commandPrefix.Any(c => !char.IsLetterOrDigit(c)))
|
||||
//{
|
||||
// throw new Exception("#DiscordBot_InvalidPrefixError");
|
||||
//}
|
||||
|
||||
var settings = new Dictionary<string, string>
|
||||
{
|
||||
{ "DiscordSettings:Token", discordToken },
|
||||
|
|
@ -62,12 +58,7 @@ namespace ServerManagerTool.DiscordBot
|
|||
|
||||
var socketConfig = new DiscordSocketConfig
|
||||
{
|
||||
//#if DEBUG
|
||||
LogLevel = LogSeverity.Verbose,
|
||||
//#else
|
||||
// LogLevel = LogSeverity.Info,
|
||||
//#endif
|
||||
// Tell Discord.Net to cache 1000 messages per channel
|
||||
LogLevel = LogLevelHelper.GetLogSeverity(logLevel),
|
||||
MessageCacheSize = 1000,
|
||||
};
|
||||
if (Environment.OSVersion.Version < new Version(6, 2))
|
||||
|
|
@ -80,11 +71,7 @@ namespace ServerManagerTool.DiscordBot
|
|||
{
|
||||
// Force all commands to run async
|
||||
DefaultRunMode = RunMode.Async,
|
||||
//#if DEBUG
|
||||
LogLevel = LogSeverity.Verbose,
|
||||
//#else
|
||||
// LogLevel = LogSeverity.Info,
|
||||
//#endif
|
||||
LogLevel = LogLevelHelper.GetLogSeverity(logLevel),
|
||||
};
|
||||
|
||||
var discordBotWhitelistConfig = new DiscordBotWhitelistConfig
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue