private IMBotMessage DoSearchCommand(IMBotConversation conversation, IList <string> arguments) { if (arguments.Count == 0) { return(new IMBotMessage("Search text or result number is missing.", IMBotMessage.ErrorColor)); } int resultNumber; if (int.TryParse(arguments[0], out resultNumber)) { return(DoSearchResults(conversation, resultNumber)); } using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent()) { string searchText = arguments[0]; if (searchText.StartsWith(@"\")) { searchText = searchText.Substring(1); } string[] titles = tvSchedulerAgent.GetTitlesByPartialTitle(GetChannelType(conversation), searchText, false); StringBuilder replyText = new StringBuilder(); replyText.AppendFormat("Found {0} in the following titles:", searchText); int index = 0; foreach (string title in titles) { replyText.AppendLine(); replyText.AppendFormat("{0,3}» {1}", ++index, title); } conversation.Session.Remove(SessionKey.Programs); conversation.Session[SessionKey.FoundTitles] = titles; return(new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'search <number>' to see the programs." }); } }
private IMBotMessage DoSearchCommand(IMBotConversation conversation, IList<string> arguments) { if (arguments.Count == 0) { return new IMBotMessage("Search text or result number is missing.", IMBotMessage.ErrorColor); } int resultNumber; if (int.TryParse(arguments[0], out resultNumber)) { return DoSearchResults(conversation, resultNumber); } using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent()) { string searchText = arguments[0]; if (searchText.StartsWith(@"\")) { searchText = searchText.Substring(1); } string[] titles = tvSchedulerAgent.GetTitlesByPartialTitle(GetChannelType(conversation), searchText, false); StringBuilder replyText = new StringBuilder(); replyText.AppendFormat("Found {0} in the following titles:", searchText); int index = 0; foreach (string title in titles) { replyText.AppendLine(); replyText.AppendFormat("{0,3}» {1}", ++index, title); } conversation.Session.Remove(SessionKey.Programs); conversation.Session[SessionKey.FoundTitles] = titles; return new IMBotMessage(replyText.ToString(), true) { Footer = "Use 'search <number>' to see the programs." }; } }