public string CreateKeyMessage() { string text = ""; text += FoodElement.FoodTagsToEmoji(FoodTags.ALCOHOL) + " " + Lang.food_tag_alcohol + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.BEEF) + " " + Lang.food_tag_beef + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.BIO) + " " + Lang.food_tag_bio + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.CHICKEN) + " " + Lang.food_tag_chicken + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.FISH) + " " + Lang.food_tag_fish + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.GARLIC) + " " + Lang.food_tag_garlic + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.HOGGET) + " " + Lang.food_tag_hogget + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.PORK) + " " + Lang.food_tag_pork + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.SOUP) + " " + Lang.food_tag_soup + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.VITAL) + " " + Lang.canteen + " " + Lang.food_tag_vital + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.VEGAN) + " " + Lang.food_tag_vegan + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.VEGETARIAN) + " " + Lang.food_tag_vegetarian + MessageInterpreter.LineBreak; text += FoodElement.FoodTagsToEmoji(FoodTags.VENSION) + " " + Lang.food_tag_vension + MessageInterpreter.LineBreak; return(text); }
public string [] CreateMensaReply(string paramFirst, string paramSecond, MensaBotEntities mensaBotEntities, string channelId, string conversationId, bool forceDate) { bool isShortRequest = false; //check if paramFirst is date, if true -> change order if (!string.IsNullOrEmpty(paramFirst) && string.IsNullOrEmpty(paramSecond)) { var isDate = (MessageInterpreter.Get.FindDate(paramFirst) != DateIndex.none); if (isDate) { paramSecond = paramFirst; paramFirst = null; } } if (string.IsNullOrEmpty(paramFirst)) { paramFirst = DatabaseUtilities.GetValueBytKey(mensaBotEntities, DatabaseUtilities.DefaultMensaTag, channelId, conversationId); if (string.IsNullOrEmpty(paramFirst)) { return new string[] { Lang.please_add + " " + MessageInterpreter.MarkBold(Lang.canteen_name) + "!" } } ; else { isShortRequest = true; } } CanteenName canteenName = MessageInterpreter.Get.FindCanteen(paramFirst); if (canteenName == CanteenName.none) { return(new string[] { Lang.canteen_not_found + ": " + MessageInterpreter.MarkBold(paramFirst) }); } try { if (_canteens == null) { CreateCanteenInfo(); } _canteens[(int)canteenName].LoadElements(3); } catch (Exception e) { return(new string[] { Lang.fail_to_load_information + ": " + MessageInterpreter.MarkBold(paramFirst) }); } DateIndex dateIndex = DateIndex.TODAY; if (!string.IsNullOrEmpty(paramSecond)) { dateIndex = MessageInterpreter.Get.FindDate(paramSecond); if (dateIndex == DateIndex.none) { return(new string[] { Lang.date_not_found + " " + MessageInterpreter.MarkBold(paramSecond) }); } } //Find correct date element. DateTime now = DateTime.Now.ToUniversalTime().AddDays((int)dateIndex).AddHours(1); DayElement[] dayElements = null; try { if (isShortRequest && !forceDate) { int maxDays = 3; for (int i = 0; i < maxDays; i++) { if (i == 0 && now.Hour > 16)//TODO read close time via website { continue; } dayElements = _canteens[(int)canteenName].DayElements.FindAll(t => t.Date.Day == now.AddDays(i).Day).ToArray(); if (dayElements != null && dayElements.Length != 0) { break; } } } else { dayElements = _canteens[(int)canteenName].DayElements.FindAll(t => t.Date.Day == now.Day).ToArray(); } } catch (Exception e) { dayElements = null; } if (dayElements == null || dayElements.Length == 0) { return(new string[] { MessageInterpreter.MarkBold(Lang.could_not_find_date + " " + now.ToString("dd.MM.yyyy") + Lang.broken_heart) }); } IEnumerable <FoodTags> filter = null; try { filter = CommandBucket.Get.GetValue(mensaBotEntities, DatabaseUtilities.IgnoreTags, channelId, conversationId) .Split(MessageInterpreter.ParamDivider) .Select(t => Enum.Parse(typeof(FoodTags), t.ToUpper())) .Cast <FoodTags>(); } catch (Exception e) { filter = null; } string[] menuItems = new string[dayElements.Length]; //List all elements for dayElement for (int i = 0; i < dayElements.Length; i++) { menuItems[i] = Lang.menu_for + ":" + MessageInterpreter.LineBreak + MessageInterpreter.MarkBold(_canteens[(int)canteenName].GetDescription(i)) + " " + Lang.menu_for_at + " " + MessageInterpreter.MarkItalic(dayElements[i].Date.ToString("dd.MM.yyyy")) + MessageInterpreter.DrawLine; foreach (var foodElement in dayElements[i].FoodElements) { bool hideElement = false; var tagResult = ""; if (foodElement.Tags != null) { foreach (var tag in foodElement.Tags) { if (tag != null) { if (filter != null && filter.Contains(tag)) { hideElement = true; break; } tagResult += FoodElement.FoodTagsToEmoji(tag) + ","; } else { tagResult += "❎"; } } } if (tagResult.Length > 1) { tagResult = tagResult.Remove(tagResult.Length - 1, 1).ToLower() + ";"; } string warning = null; if (string.IsNullOrEmpty(foodElement.EnglishName.Trim()) && CultureInfo.CurrentCulture.ToString() != (new CultureInfo("de")).ToString()) { warning = MessageInterpreter.MarkItalic(Lang.no_english_available); } FoodDisplayStyle foodDisplayStyle = FoodDisplayStyle.none; string styleString = GetValue(mensaBotEntities, DatabaseUtilities.StyleTag, channelId, conversationId); if (!string.IsNullOrEmpty(styleString)) { if (!FoodDisplayStyle.TryParse(styleString.ToUpper(), out foodDisplayStyle)) { foodDisplayStyle = FoodDisplayStyle.none; } } var tagsDisplay = ""; switch (foodDisplayStyle) { case FoodDisplayStyle.none: case FoodDisplayStyle.MAXIMUM: tagsDisplay = MessageInterpreter.LineBreak + tagResult + (!string.IsNullOrEmpty(foodElement.Cost) ? foodElement.Cost + "€" : "") + MessageInterpreter.DrawLine; break; case FoodDisplayStyle.MINIMUM_NOLINES: tagsDisplay = MessageInterpreter.LineBreak; break; case FoodDisplayStyle.MINIMUM: tagsDisplay = MessageInterpreter.DrawLine; break; case FoodDisplayStyle.INLINE: tagsDisplay = " " + ((tagResult.Length > 1) ? tagResult.Remove(tagResult.Length - 1, 1) : tagResult) + MessageInterpreter.DrawLine; break; } if (!hideElement) { if (CultureInfo.CurrentCulture.ToString() == (new CultureInfo("de")).ToString() || warning != null) { menuItems[i] += MessageInterpreter.MarkBold(foodElement.GermanName) + warning + " " + tagsDisplay; } else { menuItems[i] += MessageInterpreter.MarkBold(MessageInterpreter.FirstCharToUpper(foodElement.EnglishName)) + " " + tagsDisplay; } } } } return(menuItems); }