Пример #1
0
        private static void DealWith_Death_Generic(ArkLogMsg msg, string content)
        {
            string raw = content.Substring(0, content.IndexOf(" was killed!"));

            msg.target = new Entity_ArkDino(raw, false);
            //Done
        }
Пример #2
0
 private static void DealWith_Death_Chat(ArkLogMsg msg, string content)
 {
     //Sandwichman12 (Sandwichman): uUxWU3t7
     msg.messageSteamName  = content.Split('(')[0];
     msg.messageIngameName = content.Split('(')[1].Substring(content.Split('(')[1].IndexOf(')'));
     msg.messageContent    = content.Substring(content.IndexOf("): "));
 }
Пример #3
0
        private static void DealWith_Tame(ArkLogMsg msg, string content)
        {
            string tribeRaw = content.Substring(content.IndexOf(" of Tribe ") + " of Tribe ".Length);
            string tribe    = tribeRaw.Substring(0, tribeRaw.IndexOf(" Tamed a "));
            string raw      = content.Substring(content.IndexOf(" Tamed a ") + " Tamed a ".Length).TrimEnd('!');
            string name     = content.Substring(content.IndexOf(" of Tribe"));

            //Parse
            msg.target         = new Entity_ArkDino(raw, false);
            msg.actioner       = new Entity_ArkDino();
            msg.actioner.tribe = tribe;
            msg.actioner.name  = name;
        }
Пример #4
0
        private static void DealWith_Death_KilledBy(ArkLogMsg msg, string content)
        {
            //Parse each target.
            string killedByString = " was killed by ";
            int    wasKilledBy    = content.IndexOf(killedByString);
            string rawTargetOne   = content.Substring(0, wasKilledBy);
            string rawTargetTwo   = content.Substring(wasKilledBy + killedByString.Length);

            //Parse
            msg.target   = new Entity_ArkDino(rawTargetOne, false);
            msg.actioner = new Entity_ArkDino(rawTargetTwo, false);

            //Done!
        }
Пример #5
0
        private static void DealWith_DisconnectJoin(ArkLogMsg msg, string content)
        {
            string[] split  = content.Split(':');
            string   data   = split[split.Length - 1];
            string   person = data.Replace(" joined this ARK!", "").Replace(" left this ARK!", "");
            bool     joined = content.Replace(" joined this ARK!", "").Length != content.Length; //That is jank

            msg.messageContent = "left";                                                         //If they left or joined
            if (joined)
            {
                msg.messageContent = "joined";
            }
            msg.messageIngameName = person; //Person
        }
Пример #6
0
        public static ArkLogMsg ParseMessage(string raw)
        {
            try
            {
                //First, extract the data, the time, and the header.
                string    nonHeader = raw;//.Substring(30);
                ArkLogMsg msg       = new ArkLogMsg();
                msg.time = nonHeader.Substring(0, 19);
                string content = nonHeader.Substring(21);

                //From here, work to identify what type of message this is.
                msg.type = DetermineMsg(content);

                //Deal with each
                switch (msg.type)
                {
                case ArkLogMsgType.Death_KilledBy:
                    DealWith_Death_KilledBy(msg, content);
                    break;

                case ArkLogMsgType.Death_Generic:
                    DealWith_Death_Generic(msg, content);
                    break;

                case ArkLogMsgType.NewTame:
                    DealWith_Tame(msg, content);
                    break;

                case ArkLogMsgType.Chat:
                    DealWith_Death_Chat(msg, content);
                    break;

                case ArkLogMsgType.DisconnectJoin:
                    DealWith_DisconnectJoin(msg, content);
                    break;
                }
                return(msg);
            } catch
            {
                return(null);
            }
        }
Пример #7
0
        public async Task <ArkLogMsg[]> UpdateGameLog()
        {
            try
            {
                string[] rawString = await FetchNewLogData();

                //Parse each of these
                List <ArkLogMsg> logItems = new List <ArkLogMsg>();
                foreach (string raw in rawString)
                {
                    ArkLogMsg msg = ArkLogParser.ParseMessage(raw);
                    if (msg != null)
                    {
                        logItems.Add(msg);
                    }
                }
                //Check if we got anything
                if (logItems.Count == 0)
                {
                    return(new ArkLogMsg[0]);
                }
                DSharpPlus.Entities.DiscordChannel channel = null;
                if (logItems.Count > 0)
                {
                    //Get Discord server.
                    channel = await Program.discord.GetChannelAsync(notificationChannel);
                }
                //Foreach
                foreach (ArkLogMsg msg in logItems)
                {
                    switch (msg.type)
                    {
                    case ArkLogMsgType.Death_Generic:
                        string header = msg.target.tribe + "'s " + msg.target.dinoClass + " died!";
                        if (msg.target.dinoClass == null)
                        {
                            header = msg.target.name + " of tribe " + msg.target.tribe + " died!";
                        }
                        var embed = Tools.GenerateEmbed(header, "Darn. " + msg.time, msg.target.name + " (Level " + msg.target.level.ToString() + ")", DSharpPlus.Entities.DiscordColor.DarkButNotBlack);
                        await channel.SendMessageAsync(embed : embed);

                        break;

                    case ArkLogMsgType.Death_KilledBy:
                        string headerTwo = msg.target.ToNiceString() + " was killed by " + msg.actioner.ToNiceString();
                        var    embedTwo  = Tools.GenerateEmbed(headerTwo, "Oh darn!", msg.target.ToLongString(), DSharpPlus.Entities.DiscordColor.DarkButNotBlack);
                        await channel.SendMessageAsync(embed : embedTwo);

                        break;

                    case ArkLogMsgType.NewTame:
                        var embedThree = Tools.GenerateEmbed(msg.actioner.tribe + " tamed a " + msg.target.name + "!", "Nice tame!", "Level " + msg.target.level.ToString() + "!", DSharpPlus.Entities.DiscordColor.Yellow);
                        await channel.SendMessageAsync(embed : embedThree);

                        break;

                    case ArkLogMsgType.Chat:
                        //This is a bit of a jank-fix that might break in the future.
                        string msgContent = msg.messageContent.Substring(3);
                        var    embedFour  = Tools.GenerateEmbed("Message from " + msg.messageSteamName, msg.ParseTimeString() + " - " + name, msgContent, DSharpPlus.Entities.DiscordColor.LightGray);
                        await channel.SendMessageAsync(embed : embedFour);

                        break;

                    case ArkLogMsgType.DisconnectJoin:
                        var color = DSharpPlus.Entities.DiscordColor.Red;
                        if (msg.messageContent == "joined")
                        {
                            color = DSharpPlus.Entities.DiscordColor.Green;     //They actually joined.
                        }
                        var embedFive = Tools.GenerateEmbed("Player " + msg.messageIngameName + " " + msg.messageContent + " the game", msg.ParseTimeString(), "Server " + name, color);
                        await channel.SendMessageAsync(embed : embedFive);

                        break;
                    }
                }
                return(logItems.ToArray());
            } catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(new ArkLogMsg[0]);
            }
        }