public Task SendAnswer(BotClient client, NewMessage message) { if (!CanHandleMessage(client, message)) { return(null); } if (random.Next(2) == 0) { var html = new WebClient { Encoding = Encoding.UTF8 } .DownloadString(@"https://tproger.ru/wp-content/plugins/citation-widget/get-quote.php"); return(client.PostTextMessageToChannel(html, message.channel)); } else { var html = new WebClient { Encoding = Encoding.UTF8 }.DownloadString(@"http://bash.im/forweb/?u"); string[] delims = { "div id=\"b_q_t\" style=\"padding: 1em 0;\">", "<' + '/div><' + 'small>" }; string[] strs = html.Split(delims, StringSplitOptions.None); string text = strs[1].Replace("<' + 'br>", Environment.NewLine); text = text.Replace("<' + 'br />", Environment.NewLine); text = text.Replace(""", "\""); text = text.Replace("<", "<"); text = text.Replace(">", ">"); return(client.PostTextMessageToChannel(text, message.channel)); } }
public async Task SendAnswer(BotClient client, NewMessage message) { if (!CanHandleMessage(client, message)) { return; } await client.PostTextMessageToChannel(reactions.GetRandom(), message.channel); }
public override Task SendAnswer(BotClient client, NewMessage message) { if (!CanHandleMessage(client, message)) { return(null); } var text = message.text; var addressWithKey = @"https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20161009T130533Z.7d1dea82ce2b214a.c09525953775fcd5e747c0b4b416940ae077dc9d"; var textParameter = "&text=" + System.Uri.EscapeUriString(text); var translationDirection = "&lang=ru-uk"; var uri = new Uri(addressWithKey + textParameter + translationDirection); var webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; var result = webClient.DownloadString(uri); var tran = JsonConvert.DeserializeObject <TranslatedObject>(result); var answerText = tran.text[0]; return(client.PostTextMessageToChannel(answerText, message.channel)); }
public override Task SendAnswer(BotClient client, NewMessage message) { if (!CanHandleMessage(client, message)) { return(null); } var messageText = message.text.ToLower(); var answerText = string.Empty; if (messageText.Contains("у меня все работает") || messageText.Contains("все работает") || messageText.Contains("не проявляется") || messageText.Contains("так и должно быть")) { var number = random.Next(3); if (number == 0) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/11.png"; } else if (number == 1) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/12.png"; } else { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/13.png"; } } else if (messageText.Contains("чай") || messageText.Contains("печеньки")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/18.png"; } else if (messageText.Contains("чиню") || messageText.Contains("чиним")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/6.png"; } else if (messageText.Contains("зачекинил") || messageText.Contains("закоммитил")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/5.png"; } else if (messageText.Contains("это баг")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/7.png"; } else if (messageText.Contains("скрам")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/8.png"; } else if (messageText.Contains("стендап") || messageText.Contains("митинг")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/9.png"; } else if (messageText.Contains("на ревью") || messageText.Contains("на рецензии") || messageText.Contains("на рецензировании")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/192/10.png"; } else if (messageText.Contains("это платформа") || messageText.Contains("платформа") || messageText.Contains("платформенная ошибка")) { if (random.Next(2) == 0) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/14.png"; } else { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/15.png"; } } else if (messageText.Contains("побыстрому") || messageText.Contains("по-быстрому")) { answerText = "https://s.tcdn.co/67e/60c/67e60c3e-98b9-3cf5-8338-1c71364df6d2/17.png"; } if (string.IsNullOrEmpty(answerText)) { return(null); } return(client.PostTextMessageToChannel(answerText, message.channel)); }