Apply TTS skips from message deletion & bans when merging with other chats. Fixed group permissions.
This commit is contained in:
parent
8a0e55bb95
commit
ed68cc47e6
@ -69,7 +69,7 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
// Check if command can be executed by this chatter.
|
// Check if command can be executed by this chatter.
|
||||||
var command = selectorResult.Command;
|
var command = selectorResult.Command;
|
||||||
long chatterId = long.Parse(message.ChatterUserId);
|
long chatterId = long.Parse(message.ChatterUserId);
|
||||||
//if (chatterId != _user.OwnerId)
|
if (chatterId != _user.OwnerId)
|
||||||
{
|
{
|
||||||
bool executable = command.AcceptCustomPermission ? CanExecute(chatterId, groups, $"tts.commands.{com}", selectorResult.Permissions) : false;
|
bool executable = command.AcceptCustomPermission ? CanExecute(chatterId, groups, $"tts.commands.{com}", selectorResult.Permissions) : false;
|
||||||
if (!executable)
|
if (!executable)
|
||||||
|
@ -214,8 +214,27 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _client.CreateEventSubscription("channel.chat.message", "1", _twitch.SessionId, _user.TwitchUserId.ToString(), fragment.Mention!.UserId);
|
string targetUserId = fragment.Mention!.UserId!;
|
||||||
_logger.Information($"Joined chat room [channel: {fragment.Mention.UserLogin}][channel id: {fragment.Mention.UserId}][invoker: {message.ChatterUserLogin}][id: {message.ChatterUserId}]");
|
if (targetUserId == _user.TwitchUserId.ToString())
|
||||||
|
{
|
||||||
|
_logger.Warning("Cannot join yourself.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] subscriptions = ["channel.chat.message", "channel.chat.message_delete", "channel.chat.clear_user_messages"];
|
||||||
|
foreach (var subscription in subscriptions)
|
||||||
|
{
|
||||||
|
_logger.Debug($"Attempting to subscribe to Twitch events [subscription: {subscription}]");
|
||||||
|
var data = await _client.CreateEventSubscription(subscription, "1", _twitch.SessionId, _user.TwitchUserId.ToString(), targetUserId);
|
||||||
|
var info = data?.Data?.FirstOrDefault();
|
||||||
|
if (info == null)
|
||||||
|
{
|
||||||
|
_logger.Warning("Could not find the subscription id.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
_twitch.AddSubscription(targetUserId, subscription, info.Id);
|
||||||
|
}
|
||||||
|
_logger.Information($"Joined chat room [channel: {fragment.Mention.UserLogin}][channel id: {targetUserId}][invoker: {message.ChatterUserLogin}][id: {message.ChatterUserId}]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,22 +270,33 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var subscriptionId = _twitch.GetSubscriptionId(_user.TwitchUserId.ToString(), "channel.chat.message");
|
string targetUserId = fragment.Mention!.UserId!;
|
||||||
|
if (targetUserId == _user.TwitchUserId.ToString())
|
||||||
|
{
|
||||||
|
_logger.Warning("Cannot join yourself.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] subscriptions = ["channel.chat.message", "channel.chat.message_delete", "channel.chat.clear_user_messages"];
|
||||||
|
foreach (var subscription in subscriptions)
|
||||||
|
{
|
||||||
|
var subscriptionId = _twitch.GetSubscriptionId(targetUserId, subscription);
|
||||||
if (subscriptionId == null)
|
if (subscriptionId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning("Cannot find the subscription for that channel.");
|
_logger.Warning($"Cannot find the subscription for that channel [subscription: {subscription}]");
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _client.DeleteEventSubscription(subscriptionId);
|
await _client.DeleteEventSubscription(subscriptionId);
|
||||||
_twitch.RemoveSubscription(fragment.Mention.UserId, "channel.chat.message");
|
_twitch.RemoveSubscription(targetUserId, subscription);
|
||||||
_logger.Information($"Joined chat room [channel: {fragment.Mention.UserLogin}][channel id: {fragment.Mention.UserId}][invoker: {message.ChatterUserLogin}][id: {message.ChatterUserId}]");
|
_logger.Information($"Left chat room [channel: {fragment.Mention.UserLogin}][channel id: {targetUserId}][invoker: {message.ChatterUserLogin}][id: {message.ChatterUserId}]");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "Failed to delete the subscription from Twitch.");
|
_logger.Error(ex, $"Failed to delete the subscription from Twitch [subscription: {subscription}][subscription id: {subscriptionId}]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,16 @@ namespace TwitchChatTTS.Chat.Groups.Permissions
|
|||||||
|
|
||||||
public bool? CheckIfAllowed(IEnumerable<string> groups, string path)
|
public bool? CheckIfAllowed(IEnumerable<string> groups, string path)
|
||||||
{
|
{
|
||||||
bool overall = true;
|
bool overall = false;
|
||||||
foreach (var group in groups)
|
foreach (var group in groups)
|
||||||
{
|
{
|
||||||
var result = CheckIfAllowed($"{group}.{path}");
|
var result = CheckIfAllowed($"{group}.{path}");
|
||||||
if (result == true)
|
|
||||||
return true;
|
|
||||||
if (result == false)
|
if (result == false)
|
||||||
overall = false;
|
return false;
|
||||||
|
if (result == true)
|
||||||
|
overall = true;
|
||||||
}
|
}
|
||||||
return overall ? null : false;
|
return overall ? true : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool? CheckIfDirectAllowed(IEnumerable<string> groups, string path)
|
public bool? CheckIfDirectAllowed(IEnumerable<string> groups, string path)
|
||||||
|
Loading…
Reference in New Issue
Block a user