Added lock down functions, and modified search on QuickChats to include soundfiles

This commit is contained in:
Christopher Darnell committed 2021-04-26 16:09:20 -07:00
1 parent e7a882724b
commit 4c286d5c15
11 files changed
+138 -8

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Text;
using DSharpPlus;
namespace StarsiegeBot
{
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("Group")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class GroupManagement : BotSettings
{
public GroupManagement()
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("GroupRole")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class GroupRoleManagement : BotSettings
{
public GroupRoleManagement()
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("Level")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class LevelManagement : BotSettings
{
public LevelManagement()
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("LevelRole")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class LevelRoleManagement : BotSettings
{
public LevelRoleManagement()
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("prefix")]
[RequireGuild, RequirePermissions(Permissions.ManageRoles)]
class PrefixManagement : BotSettings
{
public PrefixManagement()
+1 -1
View File
@@ -62,7 +62,7 @@ namespace StarsiegeBot
if (args.Length > 0)
BotName = args[0].ToLower();
else
BotName = "sspdev";
BotName = "ssp";
BotEventId = new EventId(276, BotName);
}
+1
View File
@@ -23,6 +23,7 @@ using System.Threading;
namespace StarsiegeBot
{
[Group("role")]
[RequireGuild,RequirePermissions(Permissions.ManageRoles)]
class RoleManagement : BotSettings
{
public RoleManagement()
+37
View File
@@ -54,6 +54,43 @@ namespace StarsiegeBot
}
}
[Command("toggle"), Aliases("t")]
[RequireOwner]
public async Task ToggleQC(CommandContext ctx, [RemainingText] string isEnabled = null)
{
await ctx.TriggerTypingAsync();
isEnabled = isEnabled.ToLower();
string output = "";
string[] turnOn = { "on", "true", "1" };
string[] turnOff = { "off", "false", "0" };
if (File.Exists("DeathMessages.json"))
{
if (turnOn.Contains(isEnabled))
{
DeathMessagesEnabled = true;
}
else if (turnOff.Contains(isEnabled))
{
DeathMessagesEnabled = false;
}
else
{
}
output = $"DeathMessages Enabled: {DeathMessagesEnabled}";
}
else
{
DeathMessagesEnabled = false;
output = "DeathMessages.json file is missing, and it can not be enabled.";
}
await ctx.RespondAsync(output);
}
[GroupCommand]
public async Task DeathMessage(CommandContext ctx, [Description("Optional. Person you want to see kill you. If blank, will show generic death message.")]DiscordMember target = null)
{
+37 -1
View File
@@ -31,7 +31,7 @@ namespace StarsiegeBot
DiscordColor.Violet, DiscordColor.Wheat, DiscordColor.White, DiscordColor.Yellow };
private readonly Random rnd = new Random();
private readonly Dictionary<string, SSFunction> ssFunctions;
private readonly bool FunctionsEnabled;
private bool FunctionsEnabled;
public Functions()
{
@@ -136,6 +136,42 @@ namespace StarsiegeBot
await ctx.RespondAsync($"There are {ssFunctions.Count} functions in the known list.");
}
[Command("toggle"), Aliases("t")]
[RequireOwner]
public async Task ToggleQC(CommandContext ctx, [RemainingText] string isEnabled = null)
{
await ctx.TriggerTypingAsync();
isEnabled = isEnabled.ToLower();
string output = "";
string[] turnOn = { "on", "true", "1" };
string[] turnOff = { "off", "false", "0" };
if (File.Exists("functions.json"))
{
if (turnOn.Contains(isEnabled))
{
FunctionsEnabled = true;
}
else if (turnOff.Contains(isEnabled))
{
FunctionsEnabled = false;
}
else
{
}
output = $"Functions Enabled: {FunctionsEnabled}";
}
else
{
FunctionsEnabled = false;
output = "Functions.json file is missing, and it can not be enabled.";
}
await ctx.RespondAsync(output);
}
}
public class SSFunction
+56 -6
View File
@@ -24,7 +24,7 @@ namespace StarsiegeBot
{
private readonly List<Quickchats> Quickchats;
private readonly Random rnd = new Random();
private readonly bool QuickChatsEnabled;
private bool QuickChatsEnabled;
public Quickchat()
{
@@ -170,8 +170,9 @@ namespace StarsiegeBot
}
// We're going to build a message.
using StreamWriter file = new StreamWriter("tempQC.txt");
DiscordMessageBuilder msg = new DiscordMessageBuilder();
msg.Content = "";
int Content = 0;
// We're going to search each QC for the stuff in toSearch.
for (int i = 0; i < Quickchats.Count; i++)
{
@@ -179,18 +180,67 @@ namespace StarsiegeBot
if (Quickchats[i].text.ToLower().Contains(toSearch.ToLower()))
{
// add it to the list!
msg.Content += $"[{i}] {Quickchats[i].text}\r\n";
await file.WriteLineAsync($"[{i}][T] {Quickchats[i].text}\r\n");
Content++;
}
if (Quickchats[i].soundFile.ToLower().Contains(toSearch.ToLower()))
{
// add it to the list!
await file.WriteLineAsync($"[{i}][S] {Quickchats[i].text}\r\n");
Content++;
}
}
file.Close();
// If message content is still nothing, report we found nothing.
if (msg.Content == "")
if (Content == 0)
{
msg.Content = "No results found.";
await ctx.RespondAsync(msg);
}
else
{
msg.Content = "Here are your results.";
FileStream upload = new FileStream($"tempQC.txt", FileMode.Open);
msg.WithFile(upload);
await ctx.RespondAsync(msg);
upload.Close();
}
}
[Command("toggle"), Aliases("t")]
[RequireOwner]
public async Task ToggleQC (CommandContext ctx, [RemainingText] string isEnabled = null)
{
await ctx.TriggerTypingAsync();
isEnabled = isEnabled.ToLower();
string output = "";
string[] turnOn = { "on", "true", "1" };
string[] turnOff = { "off", "false", "0" };
if (File.Exists("quickchats.json"))
{
if (turnOn.Contains(isEnabled))
{
QuickChatsEnabled = true;
}
else if (turnOff.Contains(isEnabled))
{
QuickChatsEnabled = false;
}
else
{
// we wont do anything here.
}
output = $"Quickchats Enabled: {QuickChatsEnabled}";
}
else
{
QuickChatsEnabled = false;
output = "QuickChats.json file is missing, and it can not be enabled.";
}
// Tell the end user our results, or lack of.
await ctx.RespondAsync(msg);
await ctx.RespondAsync(output);
}
}
public class Quickchats