internal async Task PerformWeighIn(CommandInput message) { var weight = _Bot.Info.Weight; var response = string.Format(Resources.UseScales, weight) + '\n'; response += GetWeightCommend(weight, true); await message.Respond(response); }
public async Task Process(CommandInput message) { try { string msg = message.Text.Substring(10, message.Text.Length - 10); var date = new DateTime(int.Parse(msg.Substring(6, 4)), int.Parse(msg.Substring(3, 2)), int.Parse(msg.Substring(0, 2))); TimeSpan time; string timeStr = "", dateStr = ""; int dayCounter = 0; if (int.TryParse(msg.Substring(11, 2), out int hh) && int.TryParse(msg.Substring(14, 2), out int mm) && int.TryParse(msg.Substring(18, 2), out int tzhh) && int.TryParse(msg.Substring(21, 2), out int tzmm)) { //here used to be a comment but I fixed it, yay! (yes this code used to be even worse...) var timeZoneOffset = new TimeSpan(tzhh, tzmm, 0); var userTime = new TimeSpan(hh, mm, 0); time = msg[17] == '-' ? userTime + timeZoneOffset : userTime - timeZoneOffset; timeStr = time.ToString(); //23:11:00 = Less than 24h / 1.23:11:00 = between 1 and 10 days if (timeStr.Length > 8) { if (time.ToString()[0] == '-') { time = new TimeSpan(24 + time.Hours, 60 + time.Minutes, 0); timeStr = time.ToString().Substring(0, timeStr.Length - 4); dayCounter--; } else { timeStr = timeStr.Substring(2, timeStr.Length - 3); dayCounter++; } } } date = date.AddDays(dayCounter); string dateShortStr = date.ToShortDateString(); for (int i = dateShortStr.Length - 1; i >= 0; i--) { dateStr += dateShortStr[dateShortStr.Length - 1 - i] == '/' ? '-' : dateShortStr[dateShortStr.Length - 1 - i]; } string datetimeISO = $"{dateStr} {timeStr.Substring(0, 5)}"; string remText = msg.Substring(24, msg.Length - 24); await message.Respond($"I will remind you, {message.Author.UserName}, of {remText} on the {datetimeISO} UTC"); sendMsg = async str => await message.Respond(str); await BBBInfo.AddReminder(message.Author, datetimeISO, remText); } catch { await message.Respond("If you want me to remind you of something, you gotta follow the template sweety ;p"); } }