Exemplo n.º 1
0
 public WowChatMessage(WowChat type, long timestamp, List <string> args)
 {
     Type      = type;
     Timestamp = timestamp;
     Author    = args[1];
     Channel   = args[3];
     Flags     = args[5];
     Language  = args[2];
     Message   = args[0];
 }
Exemplo n.º 2
0
        public bool TryParseMessage(WowChat type, long timestamp, List <string> args)
        {
            if (args.Count < 6)
            {
                return(false);
            }

            WowChatMessage chatMessage = new(type, timestamp, args);

            ChatMessages.Add(chatMessage);

            if (Config.ChatProtocols)
            {
                try
                {
                    string typeName = chatMessage.Type switch
                    {
                        WowChat.ADDON => "misc",
                        WowChat.CHANNEL => "channel",
                        WowChat.DND => "misc",
                        WowChat.FILTERED => "filtered",
                        WowChat.GUILD => "guild",
                        WowChat.GUILD_ACHIEVEMENT => "guild",
                        WowChat.IGNORED => "misc",
                        WowChat.MONSTER_EMOTE => "npc",
                        WowChat.MONSTER_PARTY => "npc",
                        WowChat.MONSTER_SAY => "npc",
                        WowChat.MONSTER_WHISPER => "npc",
                        WowChat.MONSTER_YELL => "npc",
                        WowChat.RAID_BOSS_EMOTE => "npc",
                        WowChat.RAID_BOSS_WHISPER => "npc",
                        WowChat.SYSTEM => "system",
                        _ => "normal",
                    };

                    string protocolName = ProtocolName(typeName);
                    string dirName      = Path.GetDirectoryName(protocolName);

                    if (!Directory.Exists(dirName))
                    {
                        Directory.CreateDirectory(dirName);
                    }

                    File.AppendAllText(protocolName, $"{chatMessage}\n");
                }
                catch { }
            }

            OnNewChatMessage?.Invoke(chatMessage);

            return(true);
        }