예제 #1
0
파일: BannerTest.cs 프로젝트: destinygg/bot
        public void ShortSpam()
        {
            InitializeDatastore.Run();

              var testList = new List<Tuple<string, bool>> {
            new Tuple<string, bool> ("a somewhat short message1", false),
            new Tuple<string, bool> ("Waterboyy I'm not, leblanc is just annoying to play against", false),
            new Tuple<string, bool> ("i see you're a master theory crafter", false),
            new Tuple<string, bool> ("a somewhat short message2", false),
            new Tuple<string, bool> ("a somewhat short message3", true),
              };

              var total = new List<Message>();
              foreach (var tuple in testList) {
            total.Add(new PublicMessage(tuple.Item1));
            var op = total.First();
            var context = total.Skip(1).ToList();
            var testCase = new Banner(op, null, context).SelfSpam();
            if (tuple.Item2) {
              Assert.IsNotNull(testCase);
            } else {
              Assert.IsNull(testCase);
            }
              }
        }
예제 #2
0
파일: BannerTest.cs 프로젝트: destinygg/bot
        public void AutoMutedWordDatatbaseIncrementTest()
        {
            const string nick = "simpleuser";
              const string mutedWord = "mutephrase";

              InitializeDatastore.Run();
              Datastore.AddToStateString(MagicStrings.MutedWords, mutedWord, TimeSpan.FromMinutes(10).TotalSeconds, Datastore.MutedWords);

              var banner = new Banner(new PublicMessage(nick, mutedWord), null, new List<Message>());

              foreach (var i in Enumerable.Range(1, 10)) {
            banner.BanParser(true);
            Assert.AreEqual(i, Datastore.UserHistory(nick).History[MagicStrings.MutedWords][mutedWord]);
              }

              var testMute = new Mute { Duration = TimeSpan.FromDays(8) };
              Assert.AreEqual(testMute.Duration, TimeSpan.FromDays(7));
        }
예제 #3
0
파일: BannerTest.cs 프로젝트: destinygg/bot
        public void DownloadData_Imgur()
        {
            var testList = new List<string>() {
            "http://i.imgur.com/6HQv5Rz.jpg",
            "http://imgur.com/a/VVcZ2",
            "test http://i.imgur.com/6HQv5Rz.jpg",
            "test http://imgur.com/a/VVcZ2",
            "http://i.imgur.com/6HQv5Rz.jpg test",
            "http://imgur.com/a/VVcZ2 test",
            "test http://i.imgur.com/6HQv5Rz.jpg test",
            "test http://imgur.com/a/VVcZ2 test",
              };

              foreach (var text in testList) {
            var actualAnswer = new Banner(new PublicMessage(text), null).ImgurNsfw().Duration;
            var expectedAnswer = TimeSpan.FromMinutes(5);
            Assert.AreEqual(expectedAnswer, actualAnswer);
              }
        }
예제 #4
0
 private void Ban(Message message)
 {
     var recentMessages = _contextDictionary.Where(x => x.Key < message.Ordinal && x.Key >= message.Ordinal - Settings.MessageLogSize).Select(x => x.Value).ToList();
       var bantest = new Banner(message, this, recentMessages).BanParser();
       if (bantest == null) {
     if (message.SanitizedText[0] == '!' && (NextCommandTime <= DateTime.UtcNow))
       _commander.Post(message);
       } else {
     Sender.Post(bantest);
       }
       DoneWithContext(message);
 }