cleanup
This commit is contained in:
parent
d8182a663a
commit
55221b7bf5
@ -278,7 +278,7 @@ namespace NadekoBot.Classes
|
||||
}
|
||||
|
||||
public bool Equals(StreamNotificationConfig other) =>
|
||||
this.Username.ToLower().Trim() == other.Username.ToLower().Trim() &&
|
||||
this.Username.ToUpperInvariant().Trim() == other.Username.ToUpperInvariant().Trim() &&
|
||||
this.Type == other.Type &&
|
||||
this.ServerId == other.ServerId;
|
||||
|
||||
|
@ -56,7 +56,9 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
|
||||
// start the userpresence queue
|
||||
|
||||
NadekoBot.OnReady += () => Task.Run(async () =>
|
||||
NadekoBot.OnReady += () =>
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -83,6 +85,7 @@ namespace NadekoBot.Modules.Administration.Commands
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private async void ChannelUpdated(object sender, ChannelUpdatedEventArgs e)
|
||||
|
@ -23,7 +23,9 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
|
||||
public ClashOfClansModule()
|
||||
{
|
||||
NadekoBot.OnReady += () => Task.Run(async () =>
|
||||
NadekoBot.OnReady += () =>
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
if (File.Exists("data/clashofclans/wars.json"))
|
||||
{
|
||||
@ -109,6 +111,7 @@ namespace NadekoBot.Modules.ClashOfClans
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
private static void Save()
|
||||
|
@ -4,7 +4,6 @@ using Discord.Commands.Permissions;
|
||||
using NadekoBot.Classes.JSONModels;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Permissions.Classes
|
||||
@ -14,10 +13,8 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
{
|
||||
public static PermissionChecker Instance { get; } = new PermissionChecker();
|
||||
|
||||
//key - sid:command
|
||||
//value - userid
|
||||
private ConcurrentDictionary<string, ulong> commandCooldowns = new ConcurrentDictionary<string, ulong>();
|
||||
private HashSet<ulong> timeBlackList { get; } = new HashSet<ulong>();
|
||||
private ConcurrentDictionary<ulong, bool> timeBlackList { get; } = new ConcurrentDictionary<ulong, bool>();
|
||||
|
||||
static PermissionChecker() { }
|
||||
private PermissionChecker()
|
||||
@ -26,7 +23,6 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//blacklist is cleared every 1.00 seconds. That is the most time anyone will be blocked
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
timeBlackList.Clear();
|
||||
}
|
||||
@ -43,21 +39,28 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
if (channel.IsPrivate || channel.Server == null)
|
||||
return command.Category == "Help";
|
||||
|
||||
if (user == null)
|
||||
return false;
|
||||
|
||||
if (ConfigHandler.IsUserBlacklisted(user.Id) ||
|
||||
(!channel.IsPrivate &&
|
||||
(ConfigHandler.IsServerBlacklisted(channel.Server.Id) || ConfigHandler.IsChannelBlacklisted(channel.Id))))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (timeBlackList.Contains(user.Id))
|
||||
try
|
||||
{
|
||||
if (timeBlackList.ContainsKey(user.Id))
|
||||
return false;
|
||||
}
|
||||
catch { return false; }
|
||||
|
||||
if (!channel.IsPrivate && !channel.Server.CurrentUser.GetPermissions(channel).SendMessages)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
timeBlackList.Add(user.Id);
|
||||
timeBlackList.TryAdd(user.Id, true);
|
||||
|
||||
ServerPermissions perms;
|
||||
PermissionsHandler.PermissionsDict.TryGetValue(user.Server.Id, out perms);
|
||||
|
@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
}
|
||||
|
||||
|
||||
public static void Initialize()
|
||||
public static Task Initialize() => Task.Run(() =>
|
||||
{
|
||||
Console.WriteLine("Reading from the permission files.");
|
||||
Directory.CreateDirectory("data/permissions");
|
||||
@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
catch { }
|
||||
}
|
||||
Console.WriteLine("Permission initialization complete.");
|
||||
}
|
||||
});
|
||||
|
||||
internal static Permissions GetRolePermissionsById(Server server, ulong id)
|
||||
{
|
||||
@ -428,11 +428,13 @@ namespace NadekoBot.Modules.Permissions.Classes
|
||||
{
|
||||
var serverPerms = PermissionsDict.GetOrAdd(server.Id,
|
||||
new ServerPermissions(server.Id, server.Name));
|
||||
if (value == 0) {
|
||||
if (value == 0)
|
||||
{
|
||||
int throwaway;
|
||||
serverPerms.CommandCooldowns.TryRemove(commandName, out throwaway);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
serverPerms.CommandCooldowns.AddOrUpdate(commandName, value, (str, v) => value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user