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);
        }
Exemple #2
0
 private static void OnNewMessageEvent(ChatMessage e)
 {
     OnNewChatMessage?.Invoke(e);
 }
Exemple #3
0
 /// <summary>
 /// Handles a ChatMessagePacket.
 /// </summary>
 /// <param name="packet"></param>
 private void HandleChatMessage(ChatMessagePacket packet)
 {
     OnNewChatMessage?.Invoke(this, packet.ChatMessage);
 }