Skip to content

Commit

Permalink
print broken days
Browse files Browse the repository at this point in the history
  • Loading branch information
BattleRush committed Feb 28, 2024
1 parent f79f202 commit 05c2117
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ETHDINFKBot/Modules/AdminModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,8 @@ public async Task FindBrokenMensas(int days = 7)

List<Restaurant> brokenRestaurants = new List<Restaurant>();

Dictionary<string, string> brokenRestaurantList = new Dictionary<string, string>();

for (int i = 0; i < days; i++)
{
foreach (var restaurant in allRestaurants)
Expand All @@ -1191,33 +1193,36 @@ public async Task FindBrokenMensas(int days = 7)

if (allMenus.Count == 0)
{
if (!brokenRestaurants.Contains(restaurant))
brokenRestaurants.Add(restaurant);
var name = $"{restaurant.Name} ({restaurant.RestaurantId})";
if (!brokenRestaurantList.ContainsKey(name))
brokenRestaurantList.Add(name, day.DayOfWeek.ToString());
else
brokenRestaurantList[name] += $", {day.DayOfWeek.ToString()}";
}
}
}

await Context.Channel.SendMessageAsync($"Broken restaurants: {brokenRestaurants.Count}", false);

// list broken restaurants
List<string> brokenRestaurantList = new List<string>();
List<string> brokenRestaurantInfo = new List<string>();

foreach (var restaurant in brokenRestaurants)
foreach (var restaurant in brokenRestaurantList)
{
brokenRestaurantList.Add($"{restaurant.RestaurantId} - {restaurant.Name} -{restaurant.InternalName} - {restaurant.AdditionalInternalName} - {restaurant.TimeParameter}");
brokenRestaurantInfo.Add($"{restaurant.Key} - {restaurant.Value}");
}

// print text but break lines when it would exceed 1990 chars
string outputString = "";
foreach (var restaurant in brokenRestaurantList)
foreach (var info in brokenRestaurantInfo)
{
if (outputString.Length + restaurant.Length > 1990)
if (outputString.Length + info.Length > 1990)
{
await Context.Channel.SendMessageAsync(outputString, false);
outputString = "";
}

outputString += restaurant + Environment.NewLine;
outputString += info + Environment.NewLine;
}

if (!string.IsNullOrWhiteSpace(outputString))
Expand Down

0 comments on commit 05c2117

Please sign in to comment.