Example #1
0
 public async Task <string> ShouldBeModerated()
 {
     if (this.IsWhisper)
     {
         return(string.Empty);
     }
     return(await ModerationHelper.ShouldBeModerated(this.User, this.Message, this.ContainsLink));
 }
 protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments, Dictionary <string, string> extraSpecialIdentifiers, CancellationToken token)
 {
     if (this.UseChatModeration && arguments.Count() > 0)
     {
         if (!string.IsNullOrEmpty(await ModerationHelper.ShouldBeModerated(user, arguments.ElementAt(0))))
         {
             return;
         }
     }
     await base.PerformInternal(user, arguments, extraSpecialIdentifiers, token);
 }
        public async Task <string> ShouldBeModerated()
        {
            if (this.IsWhisper)
            {
                return(string.Empty);
            }

            if ((this.IsSkill || this.IsChatSkill) && string.IsNullOrEmpty(this.Message))
            {
                return(string.Empty);
            }

            return(await ModerationHelper.ShouldBeModerated(this.User, this.Message, this.ContainsLink));
        }
Example #4
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments, CancellationToken token)
        {
            if (this.UseChatModeration && arguments.Count() > 0)
            {
                string moderationReason = await ModerationHelper.ShouldBeModerated(user, arguments.ElementAt(0));

                if (!string.IsNullOrEmpty(moderationReason))
                {
                    await ModerationHelper.SendModerationWhisper(user, moderationReason);

                    return;
                }
            }
            await base.PerformInternal(user, arguments, token);
        }
Example #5
0
        protected override async Task PerformInternal(UserViewModel user, IEnumerable <string> arguments)
        {
            if (ChannelSession.Services.TranslationService != null)
            {
                string text = await this.ReplaceStringWithSpecialModifiers(this.Text, user, arguments);

                string translationResult = await ChannelSession.Services.TranslationService.Translate(this.Culture, text, this.AllowProfanity);

                if (string.IsNullOrEmpty(translationResult))
                {
                    translationResult = this.Text;
                }

                if (!string.IsNullOrEmpty(translationResult))
                {
                    if (string.IsNullOrEmpty(await ModerationHelper.ShouldBeModerated(user, translationResult)))
                    {
                        if (this.ResponseAction == TranslationResponseActionTypeEnum.Chat)
                        {
                            if (ChannelSession.Chat != null)
                            {
                                await ChannelSession.Chat.SendMessage(await this.ReplaceSpecialIdentifiers(this.ResponseChatText, user, arguments, translationResult));
                            }
                        }
                        else if (this.ResponseAction == TranslationResponseActionTypeEnum.Command)
                        {
                            CommandBase command = ChannelSession.AllEnabledCommands.FirstOrDefault(c => c.ID.Equals(this.ResponseCommandID));
                            if (command != null)
                            {
                                string argumentsText    = (this.ResponseCommandArgumentsText != null) ? this.ResponseCommandArgumentsText : string.Empty;
                                string commandArguments = await this.ReplaceSpecialIdentifiers(this.ResponseChatText, user, arguments, translationResult);

                                await command.Perform(user, commandArguments.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries), this.GetExtraSpecialIdentifiers());
                            }
                        }
                        else if (this.ResponseAction == TranslationResponseActionTypeEnum.SpecialIdentifier)
                        {
                            string replacementText = await this.ReplaceStringWithSpecialModifiers(translationResult, user, arguments);

                            SpecialIdentifierStringBuilder.AddCustomSpecialIdentifier(this.SpecialIdentifierName, replacementText);
                        }
                    }
                }
            }
        }