コード例 #1
0
        private bool Filtered(ChatMessage message)
        {
            if (!SettingsHolder.ChatEnabled)
            {
                message.Dispose();
                return(true);
            }
            if (BlockedUsers.Contains(message.Author) && !(message is LfgMessage))
            {
                message.Dispose();
                return(true);
            }

            var pausedCount = _pauseQueue.Count;

            for (var i = 0; i < SettingsHolder.SpamThreshold; i++)
            {
                if (i >= pausedCount + ChatMessages.Count)
                {
                    continue;
                }
                if (Pass(message, i <= pausedCount - 1
                                                 ? _pauseQueue.ElementAt(i)
                                                 : ChatMessages[i - pausedCount]))
                {
                    continue;
                }
                message.Dispose();
                return(true);
            }
            //if (ChatMessages.Count < SettingsHolder.SpamThreshold)
            //{
            //    for (var i = 0; i < ChatMessages.Count - 1; i++)
            //    {
            //        var m = ChatMessages[i];
            //        if (Pass(message, m)) continue;
            //        message.Dispose();
            //        return false;
            //    }
            //}
            //else
            //{
            //    for (var i = 0; i < SettingsHolder.SpamThreshold; i++)
            //    {
            //        if (i > ChatMessages.Count - 1) continue;
            //        var m = ChatMessages[i];
            //        if (Pass(message, m)) continue;
            //        message.Dispose();
            //        return false;
            //    }
            //}
            return(false);
        }
コード例 #2
0
            public async Task blockuser(string user)
            {
                if (!HasExecutePermission)
                {
                    return;
                }
                if (Context.Message.MentionedUsers.Count == 0)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "who tf is that xD",
                        Description = "you didnt mention a valid user :/",
                        Color       = Color.Red
                    }.Build());

                    return;
                }

                if (!BlockedUsers.Contains(Context.Message.MentionedUsers.First().Id))
                {
                    BlockedUsers.Add(Context.Message.MentionedUsers.First().Id);
                    Global.SaveBlockedUsers();
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = $"Succes",
                        Description = $"{Context.Message.MentionedUsers.First()} cant make threads no more lmao <3",
                        Color       = Color.Green
                    }.Build());

                    return;
                }
                else
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title       = "***wait'nt***",
                        Description = "looks like there blocked already :/",
                        Color       = Color.Green
                    }.Build());
                }
            }
コード例 #3
0
            public async Task unblock(string user)
            {
                if (!HasExecutePermission)
                    return;
                if (Context.Message.MentionedUsers.Count == 0)
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title = "who tf is that xD",
                        Description = "you didnt mention a valid user :/",
                        Color = Color.Red
                    }.Build());
                    return;
                }
                if (BlockedUsers.Contains(Context.Message.MentionedUsers.First().Id))
                {
                    BlockedUsers.Remove(Context.Message.MentionedUsers.First().Id);
                    Global.SaveBlockedUsers();
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title = $"Succes!",
                        Description = $"{Context.Message.MentionedUsers.First()} can make threads again",
                        Color = Color.Green
                    }.Build());
                    return;
                }
                else
                {
                    await Context.Channel.SendMessageAsync("", false, new EmbedBuilder()
                    {
                        Title = "***wait'nt***",
                        Description = "looks like that user isnt blocked :/",
                        Color = Color.Green
                    }.Build());
                }

            }
コード例 #4
0
        //public void NotifyOpacityChange()
        //{
        //    ChatWindows.ToList().ForEach(x =>
        //    {
        //        //TODO: make this different per window
        //        x.VM.NotifyOpacityChange();
        //    });
        //}

        public void AddChatMessage(ChatMessage chatMessage)
        {
            //return;
            if (!SettingsHolder.ChatEnabled)
            {
                chatMessage.Dispose();
                return;
            }

            if (BlockedUsers.Contains(chatMessage.Author))
            {
                chatMessage.Dispose();
                return;
            }
            if (ChatMessages.Count < SettingsHolder.SpamThreshold)
            {
                for (var i = 0; i < ChatMessages.Count - 1; i++)
                {
                    var m = ChatMessages[i];
                    if (!Pass(chatMessage, m))
                    {
                        chatMessage.Dispose();
                        return;
                    }
                }
            }
            else
            {
                for (var i = 0; i < SettingsHolder.SpamThreshold; i++)
                {
                    if (i > ChatMessages.Count - 1)
                    {
                        continue;
                    }

                    var m = ChatMessages[i];
                    if (!Pass(chatMessage, m))
                    {
                        chatMessage.Dispose();

                        return;
                    }
                }
            }

            chatMessage.SplitSimplePieces();

            if (ChatWindows.All(x => !x.IsPaused))
            {
                ChatMessages.Insert(0, chatMessage);
                //_cache.Add(chatMessage);
            }
            else
            {
                _queue.Enqueue(chatMessage);
            }

            NewMessage?.Invoke(chatMessage);
            if (ChatMessages.Count > SettingsHolder.MaxMessages)
            {
                var toRemove = ChatMessages[ChatMessages.Count - 1];
                toRemove.Dispose();
                ChatMessages.RemoveAt(ChatMessages.Count - 1);
            }
            N(nameof(MessageCount));
        }