public async Task CtyInfoAsync([Summary("This will provide country information based on the number provided.")][Remainder] string cnum) { try { int countryNumber = 0; if (int.TryParse(cnum, out countryNumber)) { var jsonOutput = GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/bynumber/" + countryNumber); var cty = JsonConvert.DeserializeObject <Country>(jsonOutput); if (cty != null) { //Output FORMAT // Max 32 Chars 7 Chars 9 Chars 10 chars 12 chars 6 chars Max 25 chars // Country Name (#1) [Tag] | Net:999.9M | Land:999,999 | DR:999 | User: | string countryName = MessageFormattingModels.AddSpacesToMessage(cty.Name, MessageFormattingModels.DetermineSpacing(34, cty.Name.Length)); string countryNum = MessageFormattingModels.AddSpacesToMessage("(#" + cty.Number + ")", MessageFormattingModels.DetermineSpacing(9, ("(#" + cty.Number + ")").Length)); string tag; if (cty.Tag != "" || cty.Tag != null) { tag = MessageFormattingModels.AddSpacesToMessage(cty.Tag, MessageFormattingModels.DetermineSpacing(11, cty.Tag.Length)); } else { tag = MessageFormattingModels.AddSpacesToMessage("[]", MessageFormattingModels.DetermineSpacing(11, "[]".Length)); } string net = MessageFormattingModels.ConvertNumberToAbrNumberString(cty.Networth); string netMsg = MessageFormattingModels.AddSpacesToMessage("Net:" + net, MessageFormattingModels.DetermineSpacing(12, ("Net:" + net).Length)); string land = MessageFormattingModels.ConvertNumberToAbrNumberString(cty.Land); string landMsg = MessageFormattingModels.AddSpacesToMessage("Land:" + land, MessageFormattingModels.DetermineSpacing(14, ("Land:" + land).Length)); int dr = DetermineDR(cty.Number); string drMsg = MessageFormattingModels.AddSpacesToMessage("DR:" + dr.ToString(), MessageFormattingModels.DetermineSpacing(8, ("DR:" + dr).Length)); string user = cty.User; if (user == "" || user == null) { user = "******"; } string userMsg = MessageFormattingModels.AddSpacesToMessage("User:"******"User:"******"```" + countryName + countryNum + tag + "|" + netMsg + "|" + landMsg + "|" + drMsg + "|" + userMsg + "```"); } else { await Context.Message.Author.SendMessageAsync("I was unable to locate country #" + cnum + "."); } } else { await Context.Message.Author.SendMessageAsync("Please only provide me an actual number for the country you are looking for, do not include a # sign."); } } catch (Exception c) { Program.Errors.Add(new ErrorModel(c)); await ReplyAsync("I encountered a problem, and it was documented, please contact MadNudist."); } }
public async Task MarketStats([Summary("This command will provide market stats for users.")] string timePerioid) { string message = "```", tempMessage = ""; List <Transaction> Transactions; // | 65 chars | // | Prod | Min | Avg | Max | Sold | #Trans | %Trans | // | 14 chars |7 chars|7 chars|7 chars|8 chars | 8 chars| 8 chars| if (timePerioid.Contains('h')) { Transactions = JsonConvert.DeserializeObject <List <Transaction> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/market/AllGoodsByDate/" + DateTime.UtcNow.AddHours(-int.Parse(timePerioid.ToLower().TrimEnd('h'))).ToShortDateString() + "/" + DateTime.UtcNow.ToShortDateString())); //Transactions = Program.storage.GetMarketTransactions(DateTime.UtcNow.AddHours(-int.Parse(timePerioid.ToLower().TrimEnd('h'))), DateTime.UtcNow); // "| Start: 20:00 GMT - To: 23:50 GMT | string temp = "Start: " + DateTime.UtcNow.AddHours(-int.Parse(timePerioid.ToLower().TrimEnd('h'))).ToShortTimeString() + " GMT - To: " + DateTime.UtcNow.ToShortTimeString() + " GMT"; message += "|" + MessageFormattingModels.AddSpacesToMessage(temp, MessageFormattingModels.DetermineSpacing(65, temp.Length)) + "|" + Environment.NewLine; //message += "| Start: "+ DateTime.UtcNow.AddHours(-int.Parse(timePerioid.ToLower().TrimEnd('h'))).ToShortTimeString() + " GMT - To: "+ DateTime.UtcNow.ToShortTimeString() + " GMT |"; message += "| Prod | Min | Avg | Max | Sold | #Trans | %Trans |" + Environment.NewLine; } else if (timePerioid.Contains('d')) { Transactions = JsonConvert.DeserializeObject <List <Transaction> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/market/AllGoodsByDate/" + DateTime.UtcNow.AddDays(-int.Parse(timePerioid.ToLower().TrimEnd('d'))).ToShortDateString() + "/" + DateTime.UtcNow.ToShortDateString())); //Transactions = Program.storage.GetMarketTransactions(DateTime.UtcNow.AddDays(-int.Parse(timePerioid.ToLower().TrimEnd('d'))), DateTime.UtcNow); // "| Start: 12/31/2017 - To: 12/31/2018 | string temp = "Start: " + DateTime.UtcNow.AddDays(-int.Parse(timePerioid.ToLower().TrimEnd('d'))).ToShortDateString() + " - To: " + DateTime.UtcNow.ToShortDateString(); message += "|" + MessageFormattingModels.AddSpacesToMessage(temp, MessageFormattingModels.DetermineSpacing(65, temp.Length)) + "|" + Environment.NewLine; //message += "| Start: "+ DateTime.UtcNow.AddDays(-int.Parse(timePerioid.ToLower().TrimEnd('d'))).ToShortDateString() + " - To: "+ DateTime.UtcNow.ToShortDateString() + " |"; message += "| Prod | Min | Avg | Max | Sold | #Trans | %Trans |" + Environment.NewLine; } else { Transactions = JsonConvert.DeserializeObject <List <Transaction> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/market/AllGoodsByDate/" + DateTime.UtcNow.AddDays(-1).ToShortDateString() + "/" + DateTime.UtcNow.ToShortDateString())); //Transactions = Program.storage.GetMarketTransactions(DateTime.UtcNow.AddDays(-1), DateTime.UtcNow); string temp = "Start: " + DateTime.UtcNow.AddDays(-1).ToShortDateString() + " - To: " + DateTime.UtcNow.ToShortDateString(); message += "|" + MessageFormattingModels.AddSpacesToMessage(temp, MessageFormattingModels.DetermineSpacing(65, temp.Length)) + "|" + Environment.NewLine; //message += "| Start: " + DateTime.UtcNow.AddDays(-1).ToShortDateString() + " - To: " + DateTime.UtcNow.ToShortDateString() + " |"; message += "| Prod | Min | Avg | Max | Sold | #Trans | %Trans |" + Environment.NewLine; } var marketStats = new marketStatModel(Transactions); foreach (var productStat in marketStats.ProductStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.Good.ToString(), MessageFormattingModels.DetermineSpacing(14, productStat.Good.ToString().Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.Min, MessageFormattingModels.DetermineSpacing(7, productStat.Min.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.Avg, MessageFormattingModels.DetermineSpacing(7, productStat.Avg.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.Max, MessageFormattingModels.DetermineSpacing(7, productStat.Max.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.Sold, MessageFormattingModels.DetermineSpacing(8, productStat.Sold.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.NumTrans, MessageFormattingModels.DetermineSpacing(8, productStat.NumTrans.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(productStat.PercTrans, MessageFormattingModels.DetermineSpacing(8, productStat.PercTrans.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } if (message.Length > 3) { message += "```"; await ReplyAsync(message); } }
public async Task WarStats() { string message = "```", tempMessage = ""; //| 84 chars | //|_______________________________________24 Hrs_______________________________________| //| Username | GS | BR | AB | Missiles | CM | NM | Kills | Deaths | Defs | //| 14 chars |6 char|6 char|6 char| 10 chars |6 char|6 char|7 chars| 8 chars|6 char| // get list of users var userList = JsonConvert.DeserializeObject <List <string> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/GetClaimedCountryUserList")); // Get news data 24 hrs ago and build warstat object var news = JsonConvert.DeserializeObject <List <Event> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/news/ByDate/" + DateTime.UtcNow.AddDays(-3).ToShortDateString().Replace('/', '-') + "/" + DateTime.UtcNow.ToShortDateString().Replace('/', '-'))); var CurrentRankings = JsonConvert.DeserializeObject <List <Country> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/currentRanks")); var warstat_24hrs_ago = new warStatModel(userList, news.Where(c => c.timestamp > DateTime.UtcNow.AddDays(-1)).ToList(), CurrentRankings); //Build 24 hour stat message message += "|_______________________________________24 Hrs_______________________________________|" + Environment.NewLine; message += "| Username | GS | BR | AB | Missiles | CM | NM | Kills | Deaths | Defs |" + Environment.NewLine; foreach (var userStat in warstat_24hrs_ago.WarUserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GS, MessageFormattingModels.DetermineSpacing(6, userStat.GS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.BR, MessageFormattingModels.DetermineSpacing(6, userStat.BR.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.AB, MessageFormattingModels.DetermineSpacing(6, userStat.AB.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Missiles, MessageFormattingModels.DetermineSpacing(10, userStat.Missiles.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.CM, MessageFormattingModels.DetermineSpacing(6, userStat.CM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NM, MessageFormattingModels.DetermineSpacing(6, userStat.NM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Kills, MessageFormattingModels.DetermineSpacing(7, userStat.Kills.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Deaths, MessageFormattingModels.DetermineSpacing(8, userStat.Deaths.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Defends, MessageFormattingModels.DetermineSpacing(6, userStat.Defends.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } var warstat_48hrs_ago = new warStatModel(userList, news.Where(c => c.timestamp > DateTime.UtcNow.AddDays(-2)).ToList(), CurrentRankings); //Build 48 hour stat message message += "|_______________________________________48 Hrs_______________________________________|" + Environment.NewLine; message += "| Username | GS | BR | AB | Missiles | CM | NM | Kills | Deaths | Defs |" + Environment.NewLine; foreach (var userStat in warstat_48hrs_ago.WarUserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GS, MessageFormattingModels.DetermineSpacing(6, userStat.GS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.BR, MessageFormattingModels.DetermineSpacing(6, userStat.BR.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.AB, MessageFormattingModels.DetermineSpacing(6, userStat.AB.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Missiles, MessageFormattingModels.DetermineSpacing(10, userStat.Missiles.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.CM, MessageFormattingModels.DetermineSpacing(6, userStat.CM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NM, MessageFormattingModels.DetermineSpacing(6, userStat.NM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Kills, MessageFormattingModels.DetermineSpacing(7, userStat.Kills.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Deaths, MessageFormattingModels.DetermineSpacing(8, userStat.Deaths.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Defends, MessageFormattingModels.DetermineSpacing(6, userStat.Defends.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } var warstat_72hrs_ago = new warStatModel(userList, news, CurrentRankings); //Build 48 hour stat message message += "|_______________________________________72 Hrs_______________________________________|" + Environment.NewLine; message += "| Username | GS | BR | AB | Missiles | CM | NM | Kills | Deaths | Defs |" + Environment.NewLine; foreach (var userStat in warstat_72hrs_ago.WarUserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GS, MessageFormattingModels.DetermineSpacing(6, userStat.GS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.BR, MessageFormattingModels.DetermineSpacing(6, userStat.BR.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.AB, MessageFormattingModels.DetermineSpacing(6, userStat.AB.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Missiles, MessageFormattingModels.DetermineSpacing(10, userStat.Missiles.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.CM, MessageFormattingModels.DetermineSpacing(6, userStat.CM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NM, MessageFormattingModels.DetermineSpacing(6, userStat.NM.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Kills, MessageFormattingModels.DetermineSpacing(7, userStat.Kills.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Deaths, MessageFormattingModels.DetermineSpacing(8, userStat.Deaths.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.Defends, MessageFormattingModels.DetermineSpacing(6, userStat.Defends.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } if (message.Length > 3) { message += "```"; await ReplyAsync(message); } }
public async Task StatsNet() { /* | 73 chars | * |__________________________________24 Hrs_________________________________| * | Username | SS | PS | Land+/- | GA+ | Net+/- | * | 14 chars | 9 chars | 9 chars | 12 chars | 12 chars | 12 chars | * |__________________________________48 Hrs_________________________________| * | Username | SS | PS | Land+/- | GA+ | Net+/- | * |__________________________________72 Hrs_________________________________| * | Username | SS | PS | Land+/- | GA+ | Net+/- | */ string message = "```", tempMessage = ""; // Get list of Users based on who has claimed countries var userList = JsonConvert.DeserializeObject <List <string> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/GetClaimedCountryUserList")); var news = JsonConvert.DeserializeObject <List <Event> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/news/ByDate/" + DateTime.UtcNow.AddDays(-3).ToShortDateString().Replace('/', '-') + "/" + DateTime.UtcNow.ToShortDateString().Replace('/', '-'))); var CurrentRankings = JsonConvert.DeserializeObject <List <Country> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/currentRanks")); // Get ranking data 24 hrs ago and build netstat object var netstat_24hrs_ago = new netStatModel( userList, CurrentRankings, JsonConvert.DeserializeObject <List <Country> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/ByDate/" + DateTime.UtcNow.AddDays(-1).ToShortDateString().Replace('/', '-'))), news.Where(c => c.timestamp > DateTime.UtcNow.AddDays(-1)).ToList()); // Build 24 hour message lines message += "|__________________________________24 Hrs_________________________________|" + Environment.NewLine; message += "| Username | SS | PS | Land+/- | GA+ | Net+/- |" + Environment.NewLine; foreach (var userStat in netstat_24hrs_ago.UserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.SS, MessageFormattingModels.DetermineSpacing(9, userStat.SS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.PS, MessageFormattingModels.DetermineSpacing(9, userStat.PS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.LandChanges, MessageFormattingModels.DetermineSpacing(12, userStat.LandChanges.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GhostAcreGains, MessageFormattingModels.DetermineSpacing(12, userStat.GhostAcreGains.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NetworthChanges, MessageFormattingModels.DetermineSpacing(12, userStat.NetworthChanges.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } // Get Ranking data 48 hrs ago and build netstat object var netstat_48hrs_ago = new netStatModel( userList, CurrentRankings, JsonConvert.DeserializeObject <List <Country> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/ByDate/" + DateTime.UtcNow.AddDays(-2).ToShortDateString().Replace('/', '-'))), news.Where(c => c.timestamp > DateTime.UtcNow.AddDays(-2)).ToList()); // build 48 hour message lines message += Environment.NewLine; message += "|__________________________________48 Hrs_________________________________|" + Environment.NewLine; message += "| Username | SS | PS | Land+/- | GA+ | Net+/- |" + Environment.NewLine; foreach (var userStat in netstat_48hrs_ago.UserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.SS, MessageFormattingModels.DetermineSpacing(9, userStat.SS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.PS, MessageFormattingModels.DetermineSpacing(9, userStat.PS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.LandChanges, MessageFormattingModels.DetermineSpacing(12, userStat.LandChanges.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GhostAcreGains, MessageFormattingModels.DetermineSpacing(12, userStat.GhostAcreGains.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NetworthChanges, MessageFormattingModels.DetermineSpacing(12, userStat.NetworthChanges.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } // Get Ranking data 72 hours ago and build netstat object var netstat_72hrs_ago = new netStatModel( userList, CurrentRankings, JsonConvert.DeserializeObject <List <Country> >(GetFromAPI("http://loc-ee.us-east-1.elasticbeanstalk.com/api/countries/ByDate/" + DateTime.UtcNow.AddDays(-3).ToShortDateString().Replace('/', '-'))), news); // build 72 hour lines message += Environment.NewLine; message += "|__________________________________72 Hrs_________________________________|" + Environment.NewLine; message += "| Username | SS | PS | Land+/- | GA+ | Net+/- |" + Environment.NewLine; foreach (var userStat in netstat_72hrs_ago.UserStats) { tempMessage = ""; tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.userName, MessageFormattingModels.DetermineSpacing(14, userStat.userName.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.SS, MessageFormattingModels.DetermineSpacing(9, userStat.SS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.PS, MessageFormattingModels.DetermineSpacing(9, userStat.PS.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.LandChanges, MessageFormattingModels.DetermineSpacing(12, userStat.LandChanges.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.GhostAcreGains, MessageFormattingModels.DetermineSpacing(12, userStat.GhostAcreGains.Length)); tempMessage += "|" + MessageFormattingModels.AddSpacesToMessage(userStat.NetworthChanges, MessageFormattingModels.DetermineSpacing(12, userStat.NetworthChanges.Length)) + "|"; tempMessage += Environment.NewLine; if ((message.Length + tempMessage.Length) < 2000) { message += tempMessage; } else { message += "```"; await ReplyAsync(message); message = "```" + tempMessage; } } if (message.Length > 3) { message += "```"; await ReplyAsync(message); } }