Merge pull request #1109 from tgstation/unbased

Adds a toggle for based mode
This commit is contained in:
AffectedArc07
2020-08-22 15:38:34 +01:00
committed by GitHub
2 changed files with 25 additions and 3 deletions
@@ -18,6 +18,11 @@ namespace Tgstation.Server.Api.Models
/// <remarks>See https://discordapp.com/developers/docs/topics/oauth2#bots</remarks>
public string? BotToken { get; set; }
/// <summary>
/// <see cref="bool"/> 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.
/// </summary>
public bool BasedMeme { get; set; }
/// <summary>
/// The <see cref="DiscordDMOutputDisplayType"/>.
/// </summary>
@@ -26,7 +31,10 @@ namespace Tgstation.Server.Api.Models
/// <summary>
/// Construct a <see cref="DiscordConnectionStringBuilder"/>
/// </summary>
public DiscordConnectionStringBuilder() { }
public DiscordConnectionStringBuilder()
{
BasedMeme = true;
}
/// <summary>
/// Construct a <see cref="DiscordConnectionStringBuilder"/> from a <paramref name="connectionString"/>
@@ -42,9 +50,17 @@ namespace Tgstation.Server.Api.Models
if (splits.Length < 2 || !Enum.TryParse<DiscordDMOutputDisplayType>(splits[1], out var dMOutputDisplayType))
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:
}
}
/// <inheritdoc />
public override string ToString() => $"{BotToken};{(int)DMOutputDisplay}";
public override string ToString() => $"{BotToken};{(int)DMOutputDisplay};{Convert.ToInt32(BasedMeme)}";
}
}
@@ -52,6 +52,11 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
/// </summary>
readonly string botToken;
/// <summary>
/// <see cref="bool"/> 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.
/// </summary>
readonly bool basedMeme;
/// <summary>
/// The <see cref="DiscordDMOutputDisplayType"/>.
/// </summary>
@@ -82,6 +87,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString);
botToken = csb.BotToken;
basedMeme = csb.BasedMeme;
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 (basedMeme && e.Content.Equals("Based on what?", StringComparison.OrdinalIgnoreCase))
{
StartTyping();