Пример #1
0
        public void Chat()
        {
            ChatEvent chat   = null;
            var       parser = new LogParser(PLAYER);

            parser.OnChat += (args) => chat = args;

            // NPCs tend to use "say" without the coma but those can be ignored
            // [Fri May 20 17:28:40 2016] a crazed digger says 'No. We can't stop the digging.'

            chat = null;
            parser.ParseLine("[Fri May 20 17:18:54 2016] Rumstil says, 'adventure'");
            Assert.NotNull(chat);
            Assert.Equal("Rumstil", chat.Source);
            Assert.Equal("say", chat.Channel);
            Assert.Equal("adventure", chat.Message);

            chat = null;
            parser.ParseLine("[Fri May 20 09:27:46 2016] You say, 'fish'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("say", chat.Channel);
            Assert.Equal("fish", chat.Message);

            chat = null;
            parser.ParseLine("[Sat Mar 19 21:12:37 2016] Fred tells you, 'hola!'");
            Assert.NotNull(chat);
            Assert.Equal("Fred", chat.Source);
            Assert.Equal("tell", chat.Channel);
            Assert.Equal("hola!", chat.Message);

            chat = null;
            parser.ParseLine("[Sat Mar 19 21:12:48 2016] You told Fred, 'hi'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("tell", chat.Channel);
            Assert.Equal("hi", chat.Message);

            chat = null;
            parser.ParseLine("[Tue Nov 03 21:52:01 2015] Dude tells the guild, 'k thx bye'");
            Assert.NotNull(chat);
            Assert.Equal("Dude", chat.Source);
            Assert.Equal("guild", chat.Channel);
            Assert.Equal("k thx bye", chat.Message);

            chat = null;
            parser.ParseLine("[Sun May 08 20:33:17 2016] You say to your guild, 'rofl'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("guild", chat.Channel);
            Assert.Equal("rofl", chat.Message);

            chat = null;
            parser.ParseLine("[Sat Aug 28 23:39:13 2010] Dude tells the group, 'lol'");
            Assert.NotNull(chat);
            Assert.Equal("Dude", chat.Source);
            Assert.Equal("group", chat.Channel);
            Assert.Equal("lol", chat.Message);

            chat = null;
            parser.ParseLine("[Fri May 06 12:21:25 2016] You tell your party, 'omg'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("group", chat.Channel);
            Assert.Equal("omg", chat.Message);

            chat = null;
            parser.ParseLine("[Sat Aug 28 23:16:46 2010] You tell your raid, 'afk 2 hours'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("raid", chat.Channel);
            Assert.Equal("afk 2 hours", chat.Message);

            // there is a double space in raid tells
            chat = null;
            parser.ParseLine("[Sat Aug 28 23:16:46 2010] Leader tells the raid,  'begin zerg'");
            Assert.NotNull(chat);
            Assert.Equal("Leader", chat.Source);
            Assert.Equal("raid", chat.Channel);
            Assert.Equal("begin zerg", chat.Message);

            chat = null;
            parser.ParseLine("[Tue May 24 13:06:43 2016] You tell testing:4, 'talking to myself again'");
            Assert.NotNull(chat);
            Assert.Equal(PLAYER, chat.Source);
            Assert.Equal("testing", chat.Channel);
            Assert.Equal("talking to myself again", chat.Message);

            chat = null;
            parser.ParseLine("[Tue May 24 13:25:06 2016] Buymystuff tells General:1, 'can ne1 buy my stuff plz'");
            Assert.NotNull(chat);
            Assert.Equal("Buymystuff", chat.Source);
            Assert.Equal("General", chat.Channel);
            Assert.Equal("can ne1 buy my stuff plz", chat.Message);

            chat = null;
            parser.ParseLine("[Tue May 24 13:25:06 2016] Buymystuff shouts, 'wts fine steel sword'");
            Assert.NotNull(chat);
            Assert.Equal("Buymystuff", chat.Source);
            Assert.Equal("shout", chat.Channel);
            Assert.Equal("wts fine steel sword", chat.Message);

            // public in other language
            chat = null;
            parser.ParseLine("[Fri May 20 17:18:54 2016] Rumstil says, in an unknown tongue, 'blearg!'");
            Assert.NotNull(chat);
            Assert.Equal("Rumstil", chat.Source);
            Assert.Equal("say", chat.Channel);
            Assert.Equal("blearg!", chat.Message);

            // private in other language
            chat = null;
            parser.ParseLine("[Fri May 20 17:18:54 2016] Rumstil tells the group, in Elvish, 'QQ'");
            Assert.NotNull(chat);
            Assert.Equal("Rumstil", chat.Source);
            Assert.Equal("group", chat.Channel);
            Assert.Equal("QQ", chat.Message);
        }