Ejemplo n.º 1
0
    private void OnClickCreateGuildBtn(GameObject go)
    {
        InputField guildNameText   = this.GuildTransformDic.get_Item(GuildUIState.GuildCreate).FindChild("guildNameText").GetComponent <InputField>();
        InputField guildNoticeText = this.GuildTransformDic.get_Item(GuildUIState.GuildCreate).FindChild("guildNoticeText").GetComponent <InputField>();

        if (string.IsNullOrEmpty(guildNameText.get_text()))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(506030, false));
            return;
        }
        string empty = string.Empty;

        if (WordFilter.filter(guildNameText.get_text(), out empty, 1, false, false, "*"))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(515026, false));
            return;
        }
        if (WordFilter.filter(guildNoticeText.get_text(), out empty, 1, false, false, "*"))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(515026, false));
            return;
        }
        GongHuiDengJi gongHuiDengJi = DataReader <GongHuiDengJi> .Get(1);

        string chineseContent = GameDataUtils.GetChineseContent(621264, false);
        string text           = GameDataUtils.GetChineseContent(506001, false);

        text = string.Format(text, gongHuiDengJi.num);
        DialogBoxUIViewModel.Instance.ShowAsOKCancel(chineseContent, text, null, delegate
        {
            GuildManager.Instance.SendSetUpGuildReq(guildNameText.get_text(), this.currentRoleMinLv, !this.isSelected, guildNoticeText.get_text());
        }, "取 消", "确 定", "button_orange_1", "button_yellow_1", null, true, true);
    }
Ejemplo n.º 2
0
        public void FilterWords_WhenInputListIsEmpty_ThrowsException()
        {
            var wordFilter    = new WordFilter();
            var inputWordList = new List <string>();

            ExceptionAssert.Throws <ArgumentException>(() => wordFilter.FilterWords(inputWordList));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        /// <param name="lang">Language to apply</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc, LanguageID?lang = null)
        {
            var updatevalues = pk.Species != set.Species;

            if (updatevalues)
            {
                pk.Species = set.Species;
            }
            pk.ApplySetGender(set);
            if (Form != pk.Form)
            {
                pk.SetForm(Form);
            }
            pk.SetFormArgument(enc);
            if (updatevalues)
            {
                pk.RefreshAbility(pk.AbilityNumber >> 1);
            }

            var usedlang = lang ?? (LanguageID)pk.Language;

            var gen      = new LegalityAnalysis(pk).Info.Generation;
            var nickname = Legal.GetMaxLengthNickname(gen, usedlang) < set.Nickname.Length ? set.Nickname.Substring(0, Legal.GetMaxLengthNickname(gen, usedlang)) : set.Nickname;

            if (!WordFilter.IsFiltered(nickname, out _))
            {
                pk.SetNickname(nickname);
            }
            else
            {
                pk.ClearNickname();
            }
            pk.CurrentLevel = set.Level;
        }
Ejemplo n.º 4
0
    public bool checkName(string roleName)
    {
        string empty = string.Empty;

        if (string.IsNullOrEmpty(roleName))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(519002, false), 2f, 2f);
            return(false);
        }
        if (this.m_InputField.get_text().Equals(EntityWorld.Instance.EntSelf.Name))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(519003, false), 2f, 2f);
            return(false);
        }
        if (roleName.IndexOf(" ") > -1)
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(519004, false), 2f, 2f);
            return(false);
        }
        if (WordFilter.filter(roleName, out empty, 3, true, true, "*"))
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(519005, false), 2f, 2f);
            return(false);
        }
        if (roleName.get_Length() > 6)
        {
            UIManagerControl.Instance.ShowToastText(GameDataUtils.GetChineseContent(519006, false), 2f, 2f);
            return(false);
        }
        return(true);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Set Species and Level with nickname (Helps with PreEvos)
        /// </summary>
        /// <param name="pk">PKM to modify</param>
        /// <param name="set">Set to use as reference</param>
        /// <param name="Form">Form to apply</param>
        /// <param name="enc">Encounter detail</param>
        public static void SetSpeciesLevel(this PKM pk, IBattleTemplate set, int Form, IEncounterable enc)
        {
            pk.Species = set.Species;
            pk.ApplySetGender(set);
            pk.SetAltForm(Form);
            pk.SetFormArgument(enc);
            pk.RefreshAbility(pk.AbilityNumber >> 1);

            var gen      = new LegalityAnalysis(pk).Info.Generation;
            var nickname = Legal.GetMaxLengthNickname(gen, LanguageID.English) < set.Nickname.Length ? set.Nickname.Substring(0, Legal.GetMaxLengthNickname(gen, LanguageID.English)) : set.Nickname;

            if (!WordFilter.IsFiltered(nickname, out _))
            {
                pk.SetNickname(nickname);
            }
            else
            {
                pk.ClearNickname();
            }
            pk.CurrentLevel = set.Level;
            if (pk.CurrentLevel == 50)
            {
                pk.CurrentLevel = 100; // VGC Override
            }
        }
Ejemplo n.º 6
0
    private void OnClickCreate(GameObject go)
    {
        string empty = string.Empty;
        string text  = this.inputField.get_text();

        if (string.IsNullOrEmpty(text))
        {
            UIManagerControl.Instance.ShowToastText("别闹了,你没有输入名字", 2f, 2f);
            return;
        }
        if (text.IndexOf(" ") > -1)
        {
            UIManagerControl.Instance.ShowToastText("名字中不能带有空格哦", 2f, 2f);
            return;
        }
        if (WordFilter.filter(text, out empty, 3, true, true, "*"))
        {
            UIManagerControl.Instance.ShowToastText("名字含有敏感词", 2f, 2f);
            return;
        }
        if (text.get_Length() > 6)
        {
            UIManagerControl.Instance.ShowToastText("名字长度不能超过六个字符", 2f, 2f);
            return;
        }
        WaitUI.OpenUI(10000u);
        LoginManager.Instance.CreateRole(SelectRoleUI.createMapIDs.get_Item(this.careerPrimaryCurr), text);
    }
Ejemplo n.º 7
0
    public void Rename(BaseEntity.RPCMessage msg)
    {
        if (!msg.player.CanInteract())
        {
            return;
        }
        string str1 = msg.read.String();

        if (Interface.CallHook("CanRenameBed", (object)msg.player, (object)this, (object)str1) != null)
        {
            return;
        }
        string str2 = WordFilter.Filter(str1);

        if (string.IsNullOrEmpty(str2))
        {
            str2 = "Unnamed Sleeping Bag";
        }
        if (str2.Length > 24)
        {
            str2 = str2.Substring(0, 22) + "..";
        }
        this.niceName = str2;
        this.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
    }
Ejemplo n.º 8
0
    private void OnWordFilterError(Messages.PluginMessage msg)
    {
        ResultCode result = default(ResultCode);

        WordFilter.GetLastError(out result);
        OnScreenLog.Add(result.className + ": " + result.lastError + ", sce error 0x" + result.lastErrorSCE.ToString("X8"));
    }
Ejemplo n.º 9
0
        private async Task HandleCommandAsync(SocketMessage arg)
        {
            try
            {
                var message = arg as SocketUserMessage;
                if (message.Author.IsBot) return;

                _ = Task.Run(() => _onMessage.MessageContainsAsync(arg));
                int argPos = 0;
                if (message.HasStringPrefix(Global.Config.CommandPrefix, ref argPos) || message.HasMentionPrefix(_client.CurrentUser, ref argPos))
                {
                    var context = new SocketCommandContext(_client, message);

                    if (await WordFilter.CheckForNaughtyWords(message.Content))
                    {
                        await WordFilter.PunishNaughtyWord(context);
                        return;
                    }
                    if (await BlacklistUser.CheckBlacklist(context.Message.Author)) return;

                    var result = await _commands.ExecuteAsync(context, argPos, _services);

                    if (!result.IsSuccess) await Logger.LogToConsole(result, context);

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 10
0
        public ActionResult DeleteConfirmed(int id)
        {
            WordFilter wordFilter = db.WordFilters.Find(id);

            db.WordFilters.Remove(wordFilter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 11
0
        public string FilterProfanity(string unfiltered)
        {
            if (this.m_wordFilters == null)
            {
                return(unfiltered);
            }
            string text = unfiltered;

            using (List <WordFilter> .Enumerator enumerator = this.m_wordFilters.FiltersList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    WordFilter current = enumerator.get_Current();
                    if (!(current.Type != "bad"))
                    {
                        Regex           regex           = new Regex(current.Regex, 1);
                        MatchCollection matchCollection = regex.Matches(text);
                        if (matchCollection.get_Count() != 0)
                        {
                            IEnumerator enumerator2 = matchCollection.GetEnumerator();
                            try
                            {
                                while (enumerator2.MoveNext())
                                {
                                    Match match = (Match)enumerator2.get_Current();
                                    if (match.get_Success())
                                    {
                                        char[] array = text.ToCharArray();
                                        if (match.get_Index() <= array.Length)
                                        {
                                            int num = match.get_Length();
                                            if (match.get_Index() + match.get_Length() > array.Length)
                                            {
                                                num = array.Length - match.get_Index();
                                            }
                                            for (int i = 0; i < num; i++)
                                            {
                                                array[match.get_Index() + i] = this.GetReplacementChar();
                                            }
                                            text = new string(array);
                                        }
                                    }
                                }
                            }
                            finally
                            {
                                IDisposable disposable = enumerator2 as IDisposable;
                                if (disposable != null)
                                {
                                    disposable.Dispose();
                                }
                            }
                        }
                    }
                }
            }
            return(text);
        }
Ejemplo n.º 12
0
        // GET: Test
        public ActionResult Index()
        {
            Dictionary <string, string> badWords = new Dictionary <string, string>();

            badWords.Add("sb", "*");
            badWords.Add("傻逼", "#");
            WordFilter.Add(1, badWords);
            return(View());
        }
Ejemplo n.º 13
0
        public void FilterWords_WhenInputListDoesNotContainAny6LetterWords_ThrowsException()
        {
            var wordFilter    = new WordFilter();
            var inputWordList = new List <string> {
                "al", "bums"
            };

            ExceptionAssert.Throws <Exception>(() => wordFilter.FilterWords(inputWordList));
        }
Ejemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "ID,word,replacedBy,boards,created,regex")] WordFilter wordFilter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(wordFilter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(wordFilter));
 }
Ejemplo n.º 15
0
 public void BadwordTest()
 {
     string[] phrases =
     {
         "censor", "buttnugget", "18넘"
     };
     foreach (var phrase in phrases)
     {
         Assert.IsTrue(WordFilter.IsFiltered(phrase, out _), $"Word not filtered: {phrase}.");
     }
 }
Ejemplo n.º 16
0
        public async Task <IActionResult> DeleteWordFilter(WordFilter word)
        {
            if (word == null)
            {
                return(BadRequest());
            }

            await wordFilterService.DeleteWordFilter(word.Id);

            return(NoContent());
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> UpdateWordFilter(int id, WordFilter word)
        {
            if (word == null)
            {
                return(BadRequest());
            }

            await wordFilterService.UpdateWordFilter(id, word);

            return(NoContent());
        }
Ejemplo n.º 18
0
        public ActionResult Create([Bind(Include = "ID,word,replacedBy,boards,created,regex")] WordFilter wordFilter)
        {
            if (ModelState.IsValid)
            {
                db.WordFilters.Add(wordFilter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(wordFilter));
        }
Ejemplo n.º 19
0
    public async Task <bool> SaveWordAsync(WordFilter wordFilter)
    {
        Log.Debug("Saving Word to Database");

        var insert = await _queryService
                     .CreateMySqlFactory()
                     .FromTable(TableName)
                     .InsertAsync(wordFilter);

        return(insert > 0);
    }
Ejemplo n.º 20
0
        public void FilterWords_WhenInputListDoesNotContainAnyWordLessThan6InLength_ThrowsException()
        {
            // Arrange
            var wordFilter    = new WordFilter();
            var inputWordList = new List <string> {
                "albums", "beaver"
            };

            // Assert                              *Act*
            ExceptionAssert.Throws <Exception>(() => wordFilter.FilterWords(inputWordList));
        }
Ejemplo n.º 21
0
        /**Creates a new WordFilter Object and scans the passed in text e.
         * Valid is assigned after a call to containsRestricted which just scans the text
         * for restricted words. May need to  be expanded upon at some point to look for
         * characters that may proceed a restricted word.
         */

        private void HandleTextChanged(object sender, TextChangedEventArgs e)
        {
            bool       IsPositive = false;
            WordFilter filter     = new WordFilter();

            IsPositive = filter.ContainsRestricted(e.NewTextValue);
            if (IsPositive)
            {
                ((Entry)sender).Text = string.Empty;
            }
        }
 private void OnWordFilterSanitized(Messages.PluginMessage msg)
 {
     WordFilter.FilteredComment result = WordFilter.GetResult();
     OnScreenLog.Add(string.Concat(new object[]
     {
         "Sanitized: changed=",
         result.wasChanged,
         ", comment='",
         result.get_comment(),
         "'"
     }));
 }
        public void CannotFilterBasedOnNullWord()
        {
            string     replacement = "*redacted*";
            WordFilter filter      = new WordFilter(replacement);
            var        messages    = ReadMessages();
            string     content     = null;

            List <Message> returnMessages = filter.Filter(messages, new string[] { content }).ToList();

            Assert.IsNotNull(returnMessages);
            CollectionAssert.AreEqual(messages, returnMessages);
        }
Ejemplo n.º 24
0
        public async Task UpdateWordFilter(int id, WordFilter wordFilter)
        {
            var entity = await GetWordFilter(id);

            if (entity == null)
            {
                throw new InvalidOperationException($"WordFilter id '{id}' not found.");
            }

            db.Entry(entity).CurrentValues.SetValues(wordFilter);
            await db.SaveChangesAsync();
        }
 public void CannotFilterNullContent()
 {
     try
     {
         WordFilter filter = new WordFilter("*redacted*");
         filter.Filter(null, new string[] { "1" });
     }
     catch (NullMessagesException)
     {
         Assert.IsTrue(true);
     }
 }
 public void Initialize()
 {
     this.menu      = new MenuLayout(this, 450, 34);
     this.ticketing = new SonyNpTicketing();
     this.dialogs   = new SonyNpDialogs();
     System.add_OnGotBandwidth(new Messages.EventHandler(this.OnSystemGotBandwidth));
     System.add_OnGotNetInfo(new Messages.EventHandler(this.OnSystemGotNetInfo));
     System.add_OnNetInfoError(new Messages.EventHandler(this.OnNetInfoError));
     WordFilter.add_OnCommentCensored(new Messages.EventHandler(this.OnWordFilterCensored));
     WordFilter.add_OnCommentNotCensored(new Messages.EventHandler(this.OnWordFilterNotCensored));
     WordFilter.add_OnCommentSanitized(new Messages.EventHandler(this.OnWordFilterSanitized));
     WordFilter.add_OnWordFilterError(new Messages.EventHandler(this.OnWordFilterError));
 }
Ejemplo n.º 27
0
        public void FilterWords_WhenInputListContains6LetterWordWith2ValidSmallWordsForConcatenation_ReturnsListWithAValid6LetterWord()
        {
            // Arrange
            var wordFilter    = new WordFilter();
            var inputWordList = new List <string> {
                "albums", "al", "bums"
            };

            // Act
            var output = wordFilter.FilterWords(inputWordList);

            // Assert
            Assert.AreEqual("albums", output[0]);
        }
    private void OnWordFilterError(Messages.PluginMessage msg)
    {
        ResultCode resultCode = default(ResultCode);

        WordFilter.GetLastError(ref resultCode);
        OnScreenLog.Add(string.Concat(new object[]
        {
            resultCode.get_className(),
            ": ",
            resultCode.lastError,
            ", sce error 0x",
            resultCode.lastErrorSCE.ToString("X8")
        }));
    }
Ejemplo n.º 29
0
        public void FilterWords_WhenInputListContainsTwo6LetterWordWith4ValidSmallWordsForConcatenation_ReturnsListWithTwo6LetterWords()
        {
            // Arrange
            var wordFilter    = new WordFilter();
            var inputWordList = new List <string> {
                "albums", "al", "jigsaw", "bums", "jig", "saw"
            };

            // Act
            var output = wordFilter.FilterWords(inputWordList);

            // Assert
            Assert.AreEqual(2, output.Count);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 加载敏感词
        /// </summary>
        public static void LoadSensitiveWords()
        {
            BLL.BLLSession   bllSession = BLLSessionFactory.GetBLLSession();
            List <Sensitive> words      = new List <Sensitive>();

            words = bllSession.ISensitiveBLL.GetList(" `Lock` =0 ").ToList();
            Dictionary <string, string> badWords = new Dictionary <string, string>();

            foreach (var word in words)
            {
                badWords.Add(word.Name, "*");
            }
            WordFilter.Add(1, badWords);
        }