From 1e694c1ae6edd9b11133fc703a14b3f393a0a135 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:54:21 +0100 Subject: [PATCH 1/8] Based Mode Toggle --- .../Models/DiscordConnectionStringBuilder.cs | 5 +++++ .../Components/Chat/Providers/DiscordProvider.cs | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 57fba95013..383bc6fa25 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -18,6 +18,11 @@ namespace Tgstation.Server.Api.Models /// See https://discordapp.com/developers/docs/topics/oauth2#bots public string? BotToken { get; set; } + /// + /// Boolean to enable based mode (Will auto reply with 'based on the hardware thats installed in it' to anyone saying 'based on what') + /// + public bool BasedMode { get; set; } + /// /// The . /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index d624c960d4..df732cee8c 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -52,6 +52,11 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// readonly string botToken; + /// + /// Boolean to enable based mode (Will auto reply with 'based on the hardware thats installed in it' to anyone saying 'based on what') + /// + readonly bool BasedMode; + /// /// The . /// @@ -82,6 +87,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString); botToken = csb.BotToken; + BasedMode = csb.BasedMode; outputDisplayType = csb.DMOutputDisplay; client = new DiscordSocketClient(); @@ -110,7 +116,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers void StartTyping() => typingState = e.Channel.EnterTypingState(); try { - if (e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) + if (BasedMode && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) { StartTyping(); From c188a0cb189b1040da98c402b855c33c7d580ae3 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 17:01:27 +0100 Subject: [PATCH 2/8] CI --- .../Components/Chat/Providers/DiscordProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index df732cee8c..e411d9183a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// Boolean to enable based mode (Will auto reply with 'based on the hardware thats installed in it' to anyone saying 'based on what') /// - readonly bool BasedMode; + readonly bool basedMode; /// /// The . @@ -87,7 +87,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString); botToken = csb.BotToken; - BasedMode = csb.BasedMode; + basedMode = csb.BasedMode; outputDisplayType = csb.DMOutputDisplay; client = new DiscordSocketClient(); @@ -116,7 +116,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers void StartTyping() => typingState = e.Channel.EnterTypingState(); try { - if (BasedMode && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) + if (basedMode && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) { StartTyping(); From 1b06d158d495b88d20b9130665cbee2c2bf44d2f Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 18:15:50 +0100 Subject: [PATCH 3/8] Needs Testing --- .../Models/DiscordConnectionStringBuilder.cs | 9 +++++---- .../Components/Chat/Providers/DiscordProvider.cs | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 383bc6fa25..797ea72be2 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -19,9 +19,9 @@ namespace Tgstation.Server.Api.Models public string? BotToken { get; set; } /// - /// Boolean to enable based mode (Will auto reply with 'based on the hardware thats installed in it' to anyone saying 'based on what') + /// to enable based mode. Will auto reply with a youtube link to a video that says "based on the hardware that's installed in it" to anyone saying 'based on what?' case-insensitive. /// - public bool BasedMode { get; set; } + public bool BasedMeme { get; set; } /// /// The . @@ -46,10 +46,11 @@ namespace Tgstation.Server.Api.Models BotToken = splits.First(); if (splits.Length < 2 || !Enum.TryParse(splits[1], out var dMOutputDisplayType)) dMOutputDisplayType = DiscordDMOutputDisplayType.Always; - DMOutputDisplay = dMOutputDisplayType; + if (splits.Length < 3 || !bool.TryParse(splits[2], out bool basedMeme)) + basedMeme = false; } /// - public override string ToString() => $"{BotToken};{(int)DMOutputDisplay}"; + public override string ToString() => $"{BotToken};{(int)DMOutputDisplay};{BasedMeme.ToString()}"; } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index e411d9183a..df097473ae 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -53,9 +53,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers readonly string botToken; /// - /// Boolean to enable based mode (Will auto reply with 'based on the hardware thats installed in it' to anyone saying 'based on what') + /// to enable based mode. Will auto reply with a youtube link to a video that says "based on the hardware that's installed in it" to anyone saying 'based on what?' case-insensitive. /// - readonly bool basedMode; + readonly bool basedMeme; /// /// The . @@ -87,7 +87,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString); botToken = csb.BotToken; - basedMode = csb.BasedMode; + basedMeme = csb.BasedMeme; outputDisplayType = csb.DMOutputDisplay; client = new DiscordSocketClient(); @@ -116,7 +116,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers void StartTyping() => typingState = e.Channel.EnterTypingState(); try { - if (basedMode && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) + if (basedMeme && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase)) { StartTyping(); From befa96104d720517f1243bdd785d5f6458d1abd8 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 18:38:20 +0100 Subject: [PATCH 4/8] Woot --- .../Models/DiscordConnectionStringBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 797ea72be2..00a284a248 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -46,8 +46,10 @@ namespace Tgstation.Server.Api.Models BotToken = splits.First(); if (splits.Length < 2 || !Enum.TryParse(splits[1], out var dMOutputDisplayType)) dMOutputDisplayType = DiscordDMOutputDisplayType.Always; + DMOutputDisplay = dMOutputDisplayType; if (splits.Length < 3 || !bool.TryParse(splits[2], out bool basedMeme)) basedMeme = false; + BasedMeme = basedMeme; } /// From 0c7f32e330cf99e2058a13dababac3e766c29fda Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 18:51:34 +0100 Subject: [PATCH 5/8] Try this --- .../Models/DiscordConnectionStringBuilder.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 00a284a248..7d851e40d5 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -47,12 +47,12 @@ namespace Tgstation.Server.Api.Models if (splits.Length < 2 || !Enum.TryParse(splits[1], out var dMOutputDisplayType)) dMOutputDisplayType = DiscordDMOutputDisplayType.Always; DMOutputDisplay = dMOutputDisplayType; - if (splits.Length < 3 || !bool.TryParse(splits[2], out bool basedMeme)) - basedMeme = false; - BasedMeme = basedMeme; + if (splits.Length < 3 || !Int32.TryParse(splits[2], out Int32 basedMeme)) + basedMeme = 0; + BasedMeme = Convert.ToBoolean(basedMeme); } /// - public override string ToString() => $"{BotToken};{(int)DMOutputDisplay};{BasedMeme.ToString()}"; + public override string ToString() => $"{BotToken};{(int)DMOutputDisplay};{Convert.ToInt32(BasedMeme)}"; } } From 2e1cff508876223212c1c2c483d4a2d729f054ab Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Wed, 19 Aug 2020 19:26:12 +0100 Subject: [PATCH 6/8] Update src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs Co-authored-by: Jordan Brown --- .../Models/DiscordConnectionStringBuilder.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 7d851e40d5..77410f056c 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -47,9 +47,8 @@ namespace Tgstation.Server.Api.Models if (splits.Length < 2 || !Enum.TryParse(splits[1], out var dMOutputDisplayType)) dMOutputDisplayType = DiscordDMOutputDisplayType.Always; DMOutputDisplay = dMOutputDisplayType; - if (splits.Length < 3 || !Int32.TryParse(splits[2], out Int32 basedMeme)) - basedMeme = 0; - BasedMeme = Convert.ToBoolean(basedMeme); + if (splits.Length > 1 && Int32.TryParse(splits[2], out Int32 basedMeme)) + BasedMeme = Convert.ToBoolean(basedMeme); } /// From 526761eb1ed15a61f23ac7d2e7f9437859bdcf65 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sat, 22 Aug 2020 09:00:44 +0100 Subject: [PATCH 7/8] Did I do this right? --- .../Models/DiscordConnectionStringBuilder.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 77410f056c..8df7bece6e 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -48,7 +48,13 @@ namespace Tgstation.Server.Api.Models dMOutputDisplayType = DiscordDMOutputDisplayType.Always; DMOutputDisplay = dMOutputDisplayType; if (splits.Length > 1 && Int32.TryParse(splits[2], out Int32 basedMeme)) + { BasedMeme = Convert.ToBoolean(basedMeme); + } + else + { + BasedMeme = true; // Oranges said this needs to be true by default :pensive: + } } /// From 32ada7e44334cd8d84438940a1a4abda821483a2 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sat, 22 Aug 2020 15:17:33 +0100 Subject: [PATCH 8/8] *whine* --- .../Models/DiscordConnectionStringBuilder.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs index 8df7bece6e..dc85593090 100644 --- a/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs +++ b/src/Tgstation.Server.Api/Models/DiscordConnectionStringBuilder.cs @@ -31,7 +31,10 @@ namespace Tgstation.Server.Api.Models /// /// Construct a /// - public DiscordConnectionStringBuilder() { } + public DiscordConnectionStringBuilder() + { + BasedMeme = true; + } /// /// Construct a from a