Fixed group permissions

This commit is contained in:
Tom
2024-08-06 20:32:02 +00:00
parent 4d27492e55
commit d019935392
3 changed files with 26 additions and 22 deletions

View File

@ -69,12 +69,12 @@ namespace TwitchChatTTS.Chat.Commands
// Check if command can be executed by this chatter.
var command = selectorResult.Command;
long chatterId = long.Parse(message.ChatterUserId);
if (chatterId != _user.OwnerId)
//if (chatterId != _user.OwnerId)
{
bool executable = command.AcceptCustomPermission ? CanExecute(chatterId, groups, $"tts.command.{com}", selectorResult.Permissions) : false;
bool executable = command.AcceptCustomPermission ? CanExecute(chatterId, groups, $"tts.commands.{com}", selectorResult.Permissions) : false;
if (!executable)
{
_logger.Debug($"Denied permission to use command [chatter id: {chatterId}][command: {com}]");
_logger.Warning($"Denied permission to use command [chatter id: {chatterId}][args: {arg}][command type: {command.GetType().Name}]");
return ChatCommandResult.Permission;
}
}
@ -116,7 +116,7 @@ namespace TwitchChatTTS.Chat.Commands
private bool CanExecute(long chatterId, IEnumerable<string> groups, string path, string[]? additionalPaths)
{
_logger.Debug($"Checking for permission [chatter id: {chatterId}][group: {string.Join(", ", groups)}][path: {path}]{(additionalPaths != null ? "[paths: " + string.Join('|', additionalPaths) + "]" : string.Empty)}");
if (_permissionManager.CheckIfAllowed(groups, path) != false)
if (_permissionManager.CheckIfAllowed(groups, path) == true)
{
if (additionalPaths == null)
return true;

View File

@ -25,7 +25,7 @@ namespace TwitchChatTTS.Chat.Commands
b.CreateVoiceNameParameter("voiceName", true)
.CreateCommand(new TTSVoiceSelector(_user, _logger))
.CreateMentionParameter("chatter", enabled: true, optional: true)
.AddPermission("tts.command.voice.admin")
.AddPermission("tts.commands.voice.admin")
.CreateCommand(new TTSVoiceSelectorAdmin(_user, _logger));
});
}
@ -56,12 +56,12 @@ namespace TwitchChatTTS.Chat.Commands
if (_user.VoicesSelected.ContainsKey(chatterId))
{
await hermes.UpdateTTSUser(chatterId, voice.Key);
_logger.Debug($"Sent request to create chat TTS voice [voice: {voice.Value}][username: {message.ChatterUserLogin}][reason: command]");
_logger.Debug($"Sent request to update chat TTS voice [voice: {voice.Value}][username: {message.ChatterUserLogin}][reason: command]");
}
else
{
await hermes.CreateTTSUser(chatterId, voice.Key);
_logger.Debug($"Sent request to update chat TTS voice [voice: {voice.Value}][username: {message.ChatterUserLogin}][reason: command]");
_logger.Debug($"Sent request to create chat TTS voice [voice: {voice.Value}][username: {message.ChatterUserLogin}][reason: command]");
}
}
}
@ -99,12 +99,12 @@ namespace TwitchChatTTS.Chat.Commands
if (_user.VoicesSelected.ContainsKey(chatterId))
{
await hermes.UpdateTTSUser(chatterId, voice.Key);
_logger.Debug($"Sent request to create chat TTS voice [voice: {voice.Value}][username: {mention.UserLogin}][reason: command]");
_logger.Debug($"Sent request to update chat TTS voice [voice: {voice.Value}][username: {mention.UserLogin}][reason: command]");
}
else
{
await hermes.CreateTTSUser(chatterId, voice.Key);
_logger.Debug($"Sent request to update chat TTS voice [voice: {voice.Value}][username: {mention.UserLogin}][reason: command]");
_logger.Debug($"Sent request to create chat TTS voice [voice: {voice.Value}][username: {mention.UserLogin}][reason: command]");
}
}
}