Пример #1
0
        public ActionResult ReportSpam(ReportSpamViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Session["Username"] != null)
                {
                    string        username         = Session["Username"] as string;
                    Spam          spam             = new Spam(model, username);
                    SuccessAndMsg addNewSpamResult = spamDAO.AddNewSpam(spam);
                    if (!addNewSpamResult.IsSuccess)
                    {
                        // thêm báo cáo vi phạm thất bại, chuyển đến trang lỗi
                        TempData["Error"] = new ErrorViewModel(addNewSpamResult.Message);
                        return(RedirectToAction("SharedError", "Error"));
                    }
                    else
                    {
                        ViewBag.AddNewSpamMsg = addNewSpamResult.Message;
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", ActionMessage.MissingOrInvalidInfo);
            }

            return(View(model));
        }
        public async Task <IActionResult> PutSpam([FromRoute] int id, [FromBody] Spam spam)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != spam.Id)
            {
                return(BadRequest());
            }

            _context.Entry(spam).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SpamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #3
0
    public static void Main()
    {
        var b = new Beacon();
        var s = new Spam();

        b.Bar(s)(1, 2, 3, 4);
    }
Пример #4
0
        //Saves the messages amount
        public static async Task SaveMessagesAmount(ulong UserId, uint Amount, string name)
        {
            //uses the Database
            using (var DbContext = new SqliteDbContext())
            {
                //sees if there isnt a record for that user and makes one
                if (DbContext.spam.Where(x => x.UserId == UserId).Count() < 1)
                {
                    DbContext.spam.Add(new Spam
                    {
                        UserId       = UserId,
                        MessagesSend = Amount,
                        Name         = name
                    });
                }
                //if there is a record updates the curent Amount
                else
                {
                    Spam Curent = DbContext.spam.Where(x => x.UserId == UserId).FirstOrDefault();
                    Curent.MessagesSend += Amount;
                    DbContext.spam.Update(Curent);
                }

                //restores the real time message amount to 0
                MessageAmmount = 0;

                //Syncs the Database
                await DbContext.SaveChangesAsync();
            }
        }
Пример #5
0
 public InterfaceArrayTest()
 {
     items    = new ISpam[5];
     items[0] = new Spam("0");
     items[1] = new Spam("1");
     items[2] = new Spam("2");
     items[3] = new Spam("3");
     items[4] = new Spam("4");
 }
Пример #6
0
 public TypedArrayTest()
 {
     items    = new Spam[5];
     items[0] = new Spam("0");
     items[1] = new Spam("1");
     items[2] = new Spam("2");
     items[3] = new Spam("3");
     items[4] = new Spam("4");
 }
Пример #7
0
 public ObjectArrayTest()
 {
     items    = new object[5];
     items[0] = new Spam("0");
     items[1] = new Spam("1");
     items[2] = new Spam("2");
     items[3] = new Spam("3");
     items[4] = new Spam("4");
 }
        public async Task <IActionResult> PostSpam([FromBody] Spam spam)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Spams.Add(spam);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSpam", new { id = spam.Id }, spam));
        }
Пример #9
0
        public void CanSerializeInterface()
        {
            var serializer = new JsonSerializer <ISpam>();

            ISpam ham = new Spam {
                Eggs = 123
            };

            var json = serializer.Serialize(ham);

            Assert.That(json, Is.EqualTo(@"{""Eggs"":123}"));
        }
Пример #10
0
 public MainForm()
 {
     InitializeComponent();
     HitTimer.Interval      = 1;
     HitTimer.Elapsed      += HitTimer_Tick;
     antiSpamTimer.Interval = 1000;
     antiSpamTimer.Elapsed += AntiSpamTimer_Elapsed;
     DatabaseManager.Initalise();
     SetColor(DatabaseManager.Color.ToColor());
     Spam         = DatabaseManager.Interval;
     tb_Spam.Text = Spam.ToString();
 }
Пример #11
0
            public SimoTimer(Spam IrcSay, string nick, int delay, string message)
            {
                this.IrcSay = IrcSay;
                this.nick = nick;
                this.delay = delay;
                this.message = message;

                timer = new System.Timers.Timer(delay);
                timer.Elapsed += new ElapsedEventHandler(TimerFiring);
                timer.Start();
                IrcSay(TimerMessage());
            }
Пример #12
0
            public SimoTimer(Spam IrcSay, string nick, int delay, string message)
            {
                this.IrcSay  = IrcSay;
                this.nick    = nick;
                this.delay   = delay;
                this.message = message;

                timer          = new System.Timers.Timer(delay);
                timer.Elapsed += new ElapsedEventHandler(TimerFiring);
                timer.Start();
                IrcSay(TimerMessage());
            }
Пример #13
0
        public async Task <IActionResult> Put(string endPointUri, [FromBody] Spam spam)
        {
            var existing = repository.Spams
                           .SingleOrDefault(s => s.EndPointUri.Equals(endPointUri));

            if (existing == null)
            {
                return(await Post(spam));
            }
            else
            {
                repository.Update(spam);
                return(Ok(spam));
            }
        }
Пример #14
0
        /// <summary>
        /// Thêm 1 báo cáo vi phạm mới
        /// </summary>
        /// <param name="spam">Thông tin báo cáo vi phạm</param>
        /// <returns></returns>
        public SuccessAndMsg AddNewSpam(Spam spam)
        {
            try
            {
                db.Spams.Add(spam);
                db.SaveChanges();

                return(new SuccessAndMsg(true, SpamDAOMsg.AddNewSpamSuccessful));
            }
            catch (Exception e)
            {
                string s = e.ToString();
                return(new SuccessAndMsg(false, SpamDAOMsg.AddNewSpamFailed));
            }
        }
Пример #15
0
    static void Main(string[] args)
    {
        Handler spam   = new Spam();
        Handler normal = new NormalEmail();

        spam.setNext(normal);
        Email email1 = new Email("First", "test", 1);

        spam.handleRequest(email1);
        Email email2 = new Email("Second", "test", 0);

        spam.handleRequest(email2);


        Console.ReadKey();
    }
Пример #16
0
            public async Task Leaderboard()
            {
                //Initializes the data of the database
                List <Spam> spam       = Data.Data.GetTop3Spams();
                Spam        firstSpam  = spam[0];
                Spam        secondSpam = spam[1];
                Spam        thirdSpam  = spam[2];

                //Makes the embed and executes
                EmbedBuilder Embed = new EmbedBuilder();

                Embed.WithAuthor("Spam LeaderBoard");
                Embed.WithDescription("Here is the list of top 3 spammers");
                Embed.WithColor(0, 128, 255);
                Embed.AddField($"1st Spammer - {firstSpam.Name}", $"with {firstSpam.MessagesSend} messages sent.");
                Embed.AddField($"2nd Spammer - {secondSpam.Name}", $"with {secondSpam.MessagesSend} messages sent.");
                Embed.AddField($"3rd Spammer - {thirdSpam.Name}", $"with {thirdSpam.MessagesSend} messages sent.");
                Embed.WithFooter("Made by sami119 and theBug");
                await Context.Channel.SendMessageAsync("", false, Embed.Build());
            }
Пример #17
0
 public bool SaveSpam(spamItem spam)
 {
     try
     {
         logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ started SaveSpam/{complaintId}", null);
         context = new SocialCopsEntities();
         Spam temp = new Spam();
         temp.date        = spam.date;
         temp.complaintId = spam.complaintId;
         temp.userId      = spam.userId;
         context.Spams.Add(temp);
         context.SaveChanges();
         logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ finished SaveSpam/{complaintId}", null);
         return(true);
     }
     catch (Exception ex)
     {
         error.Result       = false;
         error.ErrorMessage = "Something happened. Sorry.";
         error.ErrorDetails = ex.ToString();
         logger.LogMethod("ERROR", "SaveSpam/{complaintId}", spam.complaintId + ex.ToString(), null);
         throw new FaultException <Bug>(error, ex.Message.ToString());
     }
 }
Пример #18
0
 public System.Action <int, int, int, int> Bar(Spam instance)
 {
     return(instance.PrintFourNumbers);
 }
Пример #19
0
 public ConversionTest()
 {
     EnumField   = ShortEnum.Zero;
     SpamField   = new Spam("spam");
     StringField = "spam";
 }
Пример #20
0
        public void CheckingForSpam()
        {
            Spam a = new Spam();

            Assert.IsTrue(a.AutorizeAndCheckSpam());
        }
Пример #21
0
 public FieldTest()
 {
     EnumField   = ShortEnum.Zero;
     SpamField   = new Spam("spam");
     StringField = "spam";
 }
 public void Delete(Spam channel)
 {
     throw new NotImplementedException();
 }
Пример #23
0
 public bool SaveSpam(spamItem spam)
 {
     try
     {
         logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ started SaveSpam/{complaintId}", null);
         context = new SocialCopsEntities();
         Spam temp = new Spam();
         temp.date = spam.date;
         temp.complaintId = spam.complaintId;
         temp.userId = spam.userId;
         context.Spams.Add(temp);
         context.SaveChanges();
         logger.LogMethod("DEBUG", "SaveSpam/{complaintId}", spam.complaintId + "/ finished SaveSpam/{complaintId}", null);
         return true;
     }
     catch (Exception ex)
     {
         error.Result = false;
         error.ErrorMessage = "Something happened. Sorry.";
         error.ErrorDetails = ex.ToString();
         logger.LogMethod("ERROR", "SaveSpam/{complaintId}", spam.complaintId + ex.ToString(), null);
         throw new FaultException<Bug>(error, ex.Message.ToString());
     }
 }
Пример #24
0
        private static async Task AutoModAsync(SocketCommandContext Context, bool isCommand)
        {
            Task <bool>[] isZalgo =
            {
                Zalgo.IsZalgoAsync(Context),
                configDatabase.AntiZalgo.GetAntiZalgoAsync(Context.Guild)
            };
            Task <bool>[] isSpam =
            {
                Spam.IsSpamAsync(Context),
                configDatabase.AntiSpam.GetAntiSpamAsync(Context.Guild)
            };
            Task <bool>[] isSingleSpam =
            {
                Spam.IsSingleSpamAsync(Context),
                configDatabase.AntiSingleSpam.GetAntiSingleSpamAsync(Context.Guild)
            };
            Task <bool>[] isMassMention =
            {
                MassMention.IsMassMentionAsync(Context),
                configDatabase.AntiMassMention.GetAntiMassMentionAsync(Context.Guild)
            };
            Task <bool>[] isCaps =
            {
                CAPS.ISCAPSASYNC(Context),
                configDatabase.AntiCaps.GetAntiCapsAsync(Context.Guild)
            };
            Task <bool>[] isInvite =
            {
                Invite.HasInviteAsync(Context),
                configDatabase.AntiInvite.GetAntiInviteAsync(Context.Guild)
            };
            Task <bool>[] isLink =
            {
                Link.IsLinkAsync(Context),
                configDatabase.AntiLink.GetAntiLinkAsync(Context.Guild)
            };

            if (await configDatabase.AutoSurveillance.GetAutoSurveillanceAsync(Context.Guild))
            {
                if (await AutoSurveillanceAsync(Context))
                {
                    return;
                }
            }

            if ((await Task.WhenAll(isZalgo)).All(x => x))
            {
                await new Zalgo(Context).WarnAsync();
            }
            else if (((await Task.WhenAll(isSpam)).All(x => x) || (await Task.WhenAll(isSingleSpam)).All(x => x)) && !isCommand)
            {
                await new Spam(Context).WarnAsync();
            }
            else if ((await Task.WhenAll(isMassMention)).All(x => x))
            {
                await new MassMention(Context).WarnAsync();
            }
            else if ((await Task.WhenAll(isCaps)).All(x => x))
            {
                await new CAPS(Context).WARNASYNC();
            }
            else if ((await Task.WhenAll(isInvite)).All(x => x))
            {
                await new Invite(Context).RemoveAsync();
            }
            else if ((await Task.WhenAll(isLink)).All(x => x))
            {
                await new Link(Context).RemoveAsync();
            }
        }
Пример #25
0
        public async Task <IActionResult> Post([FromBody] Spam spam)
        {
            await Task.FromResult(repository.Add(spam));

            return(Created($"/api/spams/{spam.EndPointUri}", spam));
        }
        public void CanSerializeInterface()
        {
            var serializer = new JsonSerializer<ISpam>();

            ISpam ham = new Spam { Eggs = 123 };

            var json = serializer.Serialize(ham);

            Assert.That(json, Is.EqualTo(@"{""Eggs"":123}"));
        }