diff --git a/NadekoBot/Classes/PermissionsHandler.cs b/NadekoBot/Classes/PermissionsHandler.cs new file mode 100644 index 00000000..654b497b --- /dev/null +++ b/NadekoBot/Classes/PermissionsHandler.cs @@ -0,0 +1,64 @@ +using Discord; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Classes { + public class PermissionsHandler { + public static ConcurrentDictionary _permissionsDict = + new ConcurrentDictionary(); + + public static void WriteToJson() { + Directory.CreateDirectory("data/permissions/"); + foreach (var kvp in _permissionsDict) { + string pathToFile = $"data/permissions/{kvp.Key.Id}.json"; + File.WriteAllText(pathToFile, Newtonsoft.Json.JsonConvert.SerializeObject(_permissionsDict[kvp.Key],Newtonsoft.Json.Formatting.Indented)); + } + } + } + /// + /// Holds a permission list + /// + public class Permissions { + /// + /// Module name with allowed/disallowed + /// + public Dictionary modules { get; set; } + /// + /// Command name with allowed/disallowed + /// + public Dictionary commands { get; set; } + } + + public class PermissionsContainer { + /// + /// The id of the thing (user/server/channel) + /// + public string Id { get; set; } //a string because of the role name. + /// + /// Permission object bound to the id of something/role name + /// + public Permissions Permissions { get; set; } + + public PermissionsContainer() { } + } + + public class ServerPermissions : PermissionsContainer { + /// + /// The guy who can edit the permissions + /// + public string PermissionsControllerRoleName { get; set; } + /// + /// Does it print the error when a restriction occurs + /// + public bool Verbose { get; set; } + + public List UserPermissions { get; set; } + public List ChannelPermissions { get; set; } + public List RolePermissions { get; set; } + } +} \ No newline at end of file diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index ce5bfaa7..09a9cc7d 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -134,6 +134,7 @@ +