Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
Added more config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Dec 4, 2018
1 parent 50c020f commit 1447eca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion SCPDiscordPlugin/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using YamlDotNet.Serialization;

Expand Down Expand Up @@ -304,14 +305,28 @@ public static void ValidateConfig(SCPDiscord plugin)
foreach (KeyValuePair<string, string[]> node in configArrays)
{
sb.Append(node.Key + ": [ " + string.Join(", ", node.Value) + " ]\n");
if (node.Key.StartsWith("channels."))
{
foreach(string s in node.Value)
{
if(!GetDict("aliases").ContainsKey(s))
{
sb.Append("WARNING: Channel alias '" + s + "' does not exist!\n");
}
}
}
}

sb.Append("------------ Config dictionaries ------------\n");
foreach (KeyValuePair<string, Dictionary<string, string>> node in configDicts)
{
sb.Append(node.Key + ":");
sb.Append(node.Key + ":\n");
foreach (KeyValuePair<string, string> subNode in node.Value)
{
if(!Regex.IsMatch(subNode.Value, @"^\d+$"))
{
sb.Append("WARNING: Invalid channel ID: " + subNode.Value + "!\n");
}
sb.Append(" " + subNode.Key + ": " + subNode.Value + "\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion SCPDiscordPlugin/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ settings:
configvalidation: false

# Name your channels here, this name is used in the channels section below. The left value is a name of your choice and the right is a channel id you want it to represent.
aliases: ["default":"447577341024010241","staff":"509276080323166208"]
aliases: ["default":"add-role-id-here","staff":"add-role-id-here"]

# Using the channel aliases above you can direct events to different channels here
# Set to [] to disable an event.
Expand Down

0 comments on commit 1447eca

Please sign in to comment.