Fixed more group stuffs.
This commit is contained in:
@ -27,8 +27,10 @@ namespace TwitchChatTTS.Chat.Groups
|
|||||||
public void Add(long chatterId, string groupId)
|
public void Add(long chatterId, string groupId)
|
||||||
{
|
{
|
||||||
if (_chatters.TryGetValue(chatterId, out var list))
|
if (_chatters.TryGetValue(chatterId, out var list))
|
||||||
|
{
|
||||||
if (!list.Contains(groupId))
|
if (!list.Contains(groupId))
|
||||||
list.Add(groupId);
|
list.Add(groupId);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_chatters.Add(chatterId, new List<string>() { groupId });
|
_chatters.Add(chatterId, new List<string>() { groupId });
|
||||||
}
|
}
|
||||||
@ -37,8 +39,9 @@ namespace TwitchChatTTS.Chat.Groups
|
|||||||
{
|
{
|
||||||
if (_chatters.TryGetValue(chatter, out var list))
|
if (_chatters.TryGetValue(chatter, out var list))
|
||||||
{
|
{
|
||||||
foreach (var group in groupIds)
|
foreach (var groupId in groupIds)
|
||||||
list.Add(group);
|
if (!list.Contains(groupId))
|
||||||
|
list.Add(groupId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_chatters.Add(chatter, groupIds);
|
_chatters.Add(chatter, groupIds);
|
||||||
@ -85,7 +88,7 @@ namespace TwitchChatTTS.Chat.Groups
|
|||||||
|
|
||||||
public void Modify(Group group)
|
public void Modify(Group group)
|
||||||
{
|
{
|
||||||
_groups[group.Name] = group;
|
_groups[group.Id] = group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(string groupId)
|
public bool Remove(string groupId)
|
||||||
@ -104,10 +107,10 @@ namespace TwitchChatTTS.Chat.Groups
|
|||||||
if (_chatters.TryGetValue(chatterId, out var groups))
|
if (_chatters.TryGetValue(chatterId, out var groups))
|
||||||
{
|
{
|
||||||
groups.Remove(groupId);
|
groups.Remove(groupId);
|
||||||
_logger.Debug($"Removed chatter from group [chatter id: {chatterId}][group name: {_groups[groupId]}][group id: {groupId}]");
|
_logger.Debug($"Removed chatter from group [chatter id: {chatterId}][group name: {_groups[groupId].Name}][group id: {groupId}]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Failed to remove chatter from group [chatter id: {chatterId}][group name: {_groups[groupId]}][group id: {groupId}]");
|
_logger.Debug($"Failed to remove chatter from group [chatter id: {chatterId}][group name: {_groups[groupId].Name}][group id: {groupId}]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,16 +33,16 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var exists = _groups.Get(groupId);
|
var group = _groups.Get(groupId);
|
||||||
if (exists == null)
|
if (group == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Group id does not exist [group id: {exists}]");
|
_logger.Warning($"Group id does not exist [group id: {group}]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Removing group [group id: {exists.Id}][group name: {exists.Name}][group priority: {exists.Priority}]");
|
_logger.Debug($"Removing group [group id: {group.Id}][group name: {group.Name}][group priority: {group.Priority}]");
|
||||||
_groups.Remove(exists.Id);
|
_groups.Remove(group.Id);
|
||||||
_logger.Information($"Group has been updated [group id: {exists.Id}]");
|
_logger.Information($"Group has been updated [group id: {group.Id}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,7 +46,10 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
|||||||
|
|
||||||
var groupsById = groupInfo.Groups.ToDictionary(g => g.Id, g => g);
|
var groupsById = groupInfo.Groups.ToDictionary(g => g.Id, g => g);
|
||||||
foreach (var group in groupInfo.Groups)
|
foreach (var group in groupInfo.Groups)
|
||||||
|
{
|
||||||
|
_logger.Debug($"Adding group [group id: {group.Id}][name: {group.Name}][priority: {group.Priority}]");
|
||||||
_groups.Add(group);
|
_groups.Add(group);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var permission in groupInfo.GroupPermissions)
|
foreach (var permission in groupInfo.GroupPermissions)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user