private String FormatMarkUp(XmlNode eventNode, RLEvent rLEvent) { String Ready = ""; Dictionary <String, String> replaceMacro = new Dictionary <String, String>(); foreach (XmlNode eventParameter in eventNode) { if (eventParameter.Name == "Label") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Label); } if (eventParameter.Name == "Text") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Description); } if (eventParameter.Name == "Location") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Location); } if (eventParameter.Name == "DateTime") { replaceMacro.Add(eventParameter.InnerText, rLEvent.dateTime.ToString("yyyy-MMMM-dd HH:mm")); } if (eventParameter.Name == "OptionalParameter1") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional1); } if (eventParameter.Name == "OptionalParameter2") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional2); } if (eventParameter.Name == "OptionalParameter3") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional3); } if (eventParameter.Name == "OptionalParameter4") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional4); } if (eventParameter.Name == "OptionalParameter5") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional5); } if (eventParameter.Name == "OptionalParameter6") { replaceMacro.Add(eventParameter.InnerText, rLEvent.Optional6); } if (eventParameter.Name == "MarkUp") { Ready = eventParameter.InnerText; } } foreach (KeyValuePair <String, String> entry in replaceMacro) { Ready = Ready.Replace(entry.Key, entry.Value); } return(Ready); }
public void SearchNerbyRandomThisWeek(long chatId, int messageId = 0) { DateTime start = DateTime.Now; DateTime finish = DateTime.Today; finish = finish.AddDays(7); RLEvent rLEvent = SearchRandomInBetween(start, finish); _bot.SendTextMessageAsync(chatId, _settingsWrapper.ParseEvent(rLEvent), Telegram.Bot.Types.Enums.ParseMode.Markdown); Thread.Sleep(50); var message = _settingsWrapper.RepeatSearchRandom(); var keyboard = BuildKeyboardFromMessage(message); _bot.SendTextMessageAsync(chatId, message.Text, Telegram.Bot.Types.Enums.ParseMode.Markdown, false, false, 0, keyboard); Console.WriteLine("Sent event to client, id: {0}.", rLEvent.EventId); }
public String ParsePreviewEvent(RLEvent rLEvent) { if (rLEvent.Label == null) { return(NoEventsFound().Text); } var message = new MessageWithButtons(); _settingsDocument = new XmlDocument(); _settingsDocument.Load(_xmlFileName); String MarkedUpText = ""; XmlElement xRoot = _settingsDocument.DocumentElement; foreach (XmlNode xnode in xRoot) { if (xnode.Attributes.Count > 0) { XmlNode attr = xnode.Attributes.GetNamedItem("name"); XmlNode attrType = xnode.Attributes.GetNamedItem("type"); if (attr != null && attrType != null) { if (attr.Value == "EventBlockPreview") { List <Button> MessageButtons = new List <Button>(); foreach (XmlNode events in xnode.ChildNodes[0].ChildNodes) { XmlNode attrTypeEvent = events.Attributes.GetNamedItem("markup_type"); if (attr != null) { if (events.Name == "Event" && attrTypeEvent.Value == rLEvent.MarkupType) { MarkedUpText = FormatMarkUp(events, rLEvent); } } } message.Buttons = MessageButtons; } } } } return(MarkedUpText); }