예제 #1
0
        public async Task <string> ShouldTextBeModerated(UserViewModel user, string text, bool containsLink = false)
        {
            string reason = null;

            if (string.IsNullOrEmpty(text) || user.IgnoreForQueries)
            {
                return(reason);
            }

            reason = await ShouldTextBeFilteredWordModerated(user, text);

            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationFilteredWordsApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            reason = ShouldTextBeExcessiveModerated(user, text);
            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationChatTextApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            reason = ShouldTextBeLinkModerated(user, text, containsLink);
            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationBlockLinksApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            return(reason);
        }
예제 #2
0
        public static async Task <string> ShouldBeModerated(UserViewModel user, string text, bool containsLink = false)
        {
            if (UserContainerViewModel.SpecialUserAccounts.Contains(user.UserName))
            {
                return(null);
            }

            string reason = await ShouldBeFilteredWordModerated(user, text);

            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationFilteredWordsApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            reason = ShouldBeTextModerated(user, text);
            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationChatTextApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            reason = ShouldBeLinkModerated(user, text, containsLink);
            if (!string.IsNullOrEmpty(reason))
            {
                if (ChannelSession.Settings.ModerationBlockLinksApplyStrikes)
                {
                    await user.AddModerationStrike(reason);
                }
                return(reason);
            }

            return(null);
        }
예제 #3
0
        protected override async Task PerformInternal(CommandParametersModel parameters)
        {
            if (this.ActionType == ModerationActionTypeEnum.ClearChat)
            {
                await ChannelSession.Services.Chat.ClearMessages();
            }
            else
            {
                UserViewModel targetUser = null;
                if (!string.IsNullOrEmpty(this.TargetUsername))
                {
                    string username = await ReplaceStringWithSpecialModifiers(this.TargetUsername, parameters);

                    targetUser = ChannelSession.Services.User.GetActiveUserByUsername(username, parameters.Platform);
                }
                else
                {
                    targetUser = parameters.User;
                }

                if (targetUser != null)
                {
                    if (this.ActionType == ModerationActionTypeEnum.PurgeUser)
                    {
                        await ChannelSession.Services.Chat.PurgeUser(targetUser);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.BanUser)
                    {
                        await ChannelSession.Services.Chat.BanUser(targetUser);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.UnbanUser)
                    {
                        await ChannelSession.Services.Chat.UnbanUser(targetUser);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.ModUser)
                    {
                        await ChannelSession.Services.Chat.ModUser(targetUser);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.UnmodUser)
                    {
                        await ChannelSession.Services.Chat.UnmodUser(targetUser);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.AddModerationStrike)
                    {
                        string moderationReason = "Manual Moderation Strike";
                        if (!string.IsNullOrEmpty(this.ModerationReason))
                        {
                            moderationReason = await ReplaceStringWithSpecialModifiers(this.ModerationReason, parameters);
                        }
                        await targetUser.AddModerationStrike(moderationReason);
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.RemoveModerationStrike)
                    {
                        await targetUser.RemoveModerationStrike();
                    }
                    else if (this.ActionType == ModerationActionTypeEnum.TimeoutUser)
                    {
                        if (!string.IsNullOrEmpty(this.TimeoutAmount))
                        {
                            string timeAmountString = await ReplaceStringWithSpecialModifiers(this.TimeoutAmount, parameters);

                            if (uint.TryParse(timeAmountString, out uint timeAmount))
                            {
                                await ChannelSession.Services.Chat.TimeoutUser(targetUser, timeAmount);
                            }
                        }
                    }
                }
            }
        }