public InlineKeyboardMarkup InviteInlineKeyboard(Guild guild) { keyboardInvite = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new Telegram.Bot.Types.InlineKeyboardButton[][] { new [] { new Telegram.Bot.Types.InlineKeyboardButton(" Accept ", "Accept " + guild.id), new Telegram.Bot.Types.InlineKeyboardButton(" No ", "No G") } }); return(keyboardInvite); }
/// <summary> /// Вызывает команду /// </summary> /// <param name="message">принимает сообщение</param> /// <param name="client">Ссылка на экземпляр бота</param> public async void Execute(Message message, TelegramBotClient client) { var chatId = message.Chat.Id; var messageId = message.MessageId; //var keyboard = new InlineKeyboardMarkup //( // new InlineKeyboardButton[][] // { // // First row // new InlineKeyboardButton[] // { // // First column // InlineKeyboardButton.WithCallbackData("one","callback1"), // // Second column // InlineKeyboardButton.WithCallbackData("two","callback2"), // }, // } //); var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // first row { InlineKeyboardButton.WithUrl("1.1", "www.pornhub.com"), InlineKeyboardButton.WithCallbackData("1.2", "callback1"), }, new [] // second row { InlineKeyboardButton.WithCallbackData("2.1", "callback2"), InlineKeyboardButton.WithCallbackData("2.2"), } }); await client.SendTextMessageAsync(chatId, "Жамкни!", replyMarkup : keyboard); client.OnCallbackQuery += async(object sender, Telegram.Bot.Args.CallbackQueryEventArgs ev) => { var CBQMessage = ev.CallbackQuery.Message; if (ev.CallbackQuery.Data == "callback1") { await client.AnswerCallbackQueryAsync(ev.CallbackQuery.Id, "Ты выбрал " + ev.CallbackQuery.Data, true); } else if (ev.CallbackQuery.Data == "callback2") { await client.SendTextMessageAsync(CBQMessage.Chat.Id, "тест", replyToMessageId : CBQMessage.MessageId); await client.AnswerCallbackQueryAsync(ev.CallbackQuery.Id); // отсылаем пустое, чтобы убрать "часики" на кнопке } }; }
public override void Execute(Message message, TelegramBotClient client) { var chatId = message.Chat.Id; var messageId = message.MessageId; //var request = (HttpWebRequest)WebRequest.Create("https://login.uber.com/oauth/v2/authorize?client_id=rj7tZtjxSQwh7sxBDEZyU9Q5_10WBvPD&response_type=code&redirect_uri=https://fffb3ee5.ngrok.io/api/message/uber&state="+ chatId); //var response = (HttpWebResponse)request.GetResponse(); //var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var authClient = new UberAuthenticationClient("rj7tZtjxSQwh7sxBDEZyU9Q5_10WBvPD", "lVtEEJJcJKSz_ie-8OSofKa6P9n_-gICXPx8ZyWh"); // Generate authorize URL - If you don't specify scope, state or redirect URI then app defaults will be used var authorizeUrl = authClient.GetAuthorizeUrl(null, chatId.ToString(), null); var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // first row { InlineKeyboardButton.WithUrl("Войти через Uber", authorizeUrl) } }); client.SendTextMessageAsync(chatId, "Віберете действие!", replyMarkup: keyboard); }
//бота можно бы и в отдельный класс вынести. Кстати, что ещё из e ты используешь? И из sender? private static void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e) { string history = ""; history += e.Message.Text;//а почему не присвоить сразу? строка гарантированно пустая в этот момент if (e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Text) { /* * Понимаю, пробелы бесплатные * Можно ставить много :D */ var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] //необязательно полное имя класса указывать { new [] // Строка кнопок. { InlineKeyboardButton.WithCallbackData("Калькулятор", "calculator"), InlineKeyboardButton.WithCallbackData("История", "history"), } }); Bot.SendTextMessageAsync(e.Message.Chat.Id, "Выберите действие", replyMarkup: keyboard);//async-await } // При нажатии на кнопку.//вообще зло Bot.OnCallbackQuery += async(object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev) => { var message = ev.CallbackQuery.Message; if (ev.CallbackQuery.Data == "calculator") // При нажатии на левую кнопку меню (калькулятор). //самое странное расположение коммента, которое я видел { var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // Первая строка кнопок с операциями. { InlineKeyboardButton.WithCallbackData("+", "+"), InlineKeyboardButton.WithCallbackData("-", "-"), }, new [] // Вторая строка кнопок с операциями. { InlineKeyboardButton.WithCallbackData("*", "*"), InlineKeyboardButton.WithCallbackData("/", "/") } }); await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Выберите операцию", replyMarkup : keyboard); // При нажатии на кнопку в подменю.//зло в квадрате, ведь ты уже в обработчике Bot.OnCallbackQuery += async(object op, Telegram.Bot.Args.CallbackQueryEventArgs sec) => { var message2 = sec.CallbackQuery.Message;//message2 - это сиквел? // При нажатии на кнопку сложения. //Antipattern.Сopypaste.Start() if (sec.CallbackQuery.Data == "+") { try { string s = e.Message.Text.Replace(',', '.'); //а не проще var strNumbers = ... ? string[] strNumbers; double sum = 0; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Суммируем подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { sum += Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } history += " + "; // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(sum)); } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); // а если здесь что-то пойдёт не так - всё, прощай бот? } } else // При нажатии на кнопку вычитания. if (sec.CallbackQuery.Data == "-") { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double difer = 0; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Вычитаем поочерёдно подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { difer -= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(difer)); history += " - "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } else // При нажатии на кнопку умножения. if (sec.CallbackQuery.Data == "*") { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double prod = 1; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Перемножаем подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { prod *= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(prod)); history += " * "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } else //ну лично я против такого стиля написания else if, и не я один if (sec.CallbackQuery.Data == "/") // при нажатии на кнопку деления { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double div; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); //почему не ' ' ? div = Double.Parse(strNumbers[0], CultureInfo.InvariantCulture); //про культуры в курсе - это хорошо // Разделяем поочерёдно подстроки, преобразованные в double. //а есть и неплохой такой цикл foreach for (int i = 1; i < strNumbers.Length; i++) { div /= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(div)); history += " / "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } //Antipattern.Сopypaste.End() }; } else if (ev.CallbackQuery.Data == "history") { await Bot.SendTextMessageAsync(e.Message.Chat.Id, history); //и он отправит что? строка создана-то локально } }; }
public ViewGuild() { keyboardCreateChoose = new ReplyKeyboardMarkup { Keyboard = new[] { new[] { new Telegram.Bot.Types.KeyboardButton("Create G"), new Telegram.Bot.Types.KeyboardButton("Change G"), }, new[] { new Telegram.Bot.Types.KeyboardButton(" Back "), } }, ResizeKeyboard = true }; keyboardGuild = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] { new Telegram.Bot.Types.KeyboardButton(" Chat G"), new Telegram.Bot.Types.KeyboardButton(" Work G") }, new[] { new Telegram.Bot.Types.KeyboardButton(" Guild G"), new Telegram.Bot.Types.KeyboardButton(" Back ") }, }, ResizeKeyboard = true }; keyboardGuildMasterSetting = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] { new Telegram.Bot.Types.KeyboardButton(" Invite G"), new Telegram.Bot.Types.KeyboardButton(" Exclude G"), new Telegram.Bot.Types.KeyboardButton(" Change chat G") }, new[] { new Telegram.Bot.Types.KeyboardButton(" Change Hire status G"), new Telegram.Bot.Types.KeyboardButton(" All members G"), new Telegram.Bot.Types.KeyboardButton(" Guild G ") }, }, ResizeKeyboard = true }; keyboardWorkGuild = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] { new Telegram.Bot.Types.KeyboardButton("1. Easy job( 2 \U000026A1) G"), new Telegram.Bot.Types.KeyboardButton("2. Normal job( 3 \U000026A1) G") }, new[] { new Telegram.Bot.Types.KeyboardButton("3. Hard job( 4 \U000026A1) G"), new Telegram.Bot.Types.KeyboardButton(" Guild G ") }, }, ResizeKeyboard = true }; keyboardInvite = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new Telegram.Bot.Types.InlineKeyboardButton[][] { new [] { new Telegram.Bot.Types.InlineKeyboardButton(" Accept ", "Accept G"), new Telegram.Bot.Types.InlineKeyboardButton(" No ", "No G") } }); guildHello = "You are enter a guild house"; workGuild = "You see on the notice board some jobs: "; createGuild = "Write a name of the guild after command /GCreate_. For example: /GCreate_GuildName. You need 1000 gold and 15 lvl"; createGuildOk = "You just create a new guild. Guildmaster!"; createGuildFalseName = " Some things go wrong. Maybe this name is used"; createGuildFalseGold = " Some things go wrong. You are too poor to be a guildmaster"; createGuildFalseLvl = " Some things go wrong. You are too young to be a guildmaster"; settingGuildMaster = "What do you want to change guild master?"; changeHire = "You change hire statys"; chatUrl = "Plese write comand /GSetChatUrl_ and your invite link (without https://t.me/)"; chatUrlSucces = "All right. You changed succesfuly"; chatUrlFail = "Some thing gone wrong"; invite = "Write a name of the person after command /GInvite_. For example: /GInvite_PersonTest"; exclude = "Write a name of the person after command /GExlude_. For example: /GExlude_PersonTest"; excludeSucces = "Exclude succes"; excludeSuccesMessageToPlayer = "You was exclude from guild!"; kikFailIMaster = "You cant kik your self!"; inviteFaileByName = "We dont have such player!"; inviteFaileByGuild = "This player is already a member of the guild!"; inviteSucces = "We send invite message"; inviteAccepted = "Player accept you invite!"; leaveGuildSucces = "You leave this guild. So now try to find better"; doSomeThingWrong = "I think you do some thing wrong!"; }
// Three states: init, uploaded and set for contact group private static async void BotOnMessageReceived(object sender, MessageEventArgs messageEventArgs) { var rkm = new ReplyKeyboardMarkup(); rkm.Keyboard = new KeyboardButton[][] { new KeyboardButton[] { new KeyboardButton("Upload"), }, new KeyboardButton[] { new KeyboardButton("To Sign"), }, new KeyboardButton[] { new KeyboardButton("Signed"), } }; rkm.OneTimeKeyboard = true; // Prepare all relevant data from client long tgid = messageEventArgs.Message.Chat.Id; string docname = null; Contact contact = null; if (messageEventArgs.Message.Type.Equals(MessageType.DocumentMessage)) { docname = messageEventArgs.Message.Document.FileName; } else if (messageEventArgs.Message.Type.Equals(MessageType.ContactMessage)) { contact = messageEventArgs.Message.Contact; } //TODO switch case if (messageEventArgs.Message.Type.Equals(MessageType.TextMessage) && messageEventArgs.Message.Text.Equals("/start")) { Console.WriteLine("Init for " + tgid); await Bot.SendTextMessageAsync(messageEventArgs.Message.Chat.Id, "Please Select An Option", false, false, 0, rkm); } else if (messageEventArgs.Message.Type.Equals(MessageType.TextMessage) && messageEventArgs.Message.Text.Equals("Upload")) { Console.WriteLine(tgid + "Want to upload"); statedict[tgid] = "init"; docnamedict = new Dictionary <long, Document>(); contactsdict = new Dictionary <long, Dictionary <string, List <Contact> > >(); //Set empty / clear contact list for client with tgid contactsdict[tgid] = new Dictionary <string, List <Contact> >(); await Bot.SendTextMessageAsync(messageEventArgs.Message.Chat.Id, "Now upload file you want to sign", false, false, 0, null); } else if (messageEventArgs.Message.Type.Equals(MessageType.DocumentMessage) && statedict.ContainsKey(tgid) && statedict[tgid] == "init") { Console.WriteLine("Document received from " + tgid); //Update Data statedict[tgid] = "uploaded"; docnamedict[tgid] = messageEventArgs.Message.Document; // Dictionary <string, List <Contact> > dict = new Dictionary <string, List <Contact> >(); dict[docname] = new List <Contact>(); contactsdict[tgid] = dict; //Send Reply await Bot.SendTextMessageAsync(messageEventArgs.Message.Chat.Id, "Document for sign: " + docname + ". Please select document signers by phone number from your contact list", false, false, 0, null); } else if (messageEventArgs.Message.Type.Equals(MessageType.ContactMessage) && statedict.ContainsKey(tgid) && (statedict[tgid] == "uploaded" || statedict[tgid] == "set")) { // Keyboard with one button for sender sign var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup( new Telegram.Bot.Types.InlineKeyboardButton[][] { // First row new [] { // First column new Telegram.Bot.Types.InlineKeyboardButton("sign and send", "sendtosigncallback"), }, } ); // Update client state and add new contact statedict[tgid] = "set"; contactsdict[tgid][docnamedict[tgid].FileName].Add(contact); string res = "Document signers: \n"; for (var i = 0; i < contactsdict[tgid][docnamedict[tgid].FileName].Count; i++) { Contact c = contactsdict[tgid][docnamedict[tgid].FileName][i]; res = res + c.FirstName + " " + c.LastName + "\n"; } await Bot.SendTextMessageAsync(messageEventArgs.Message.Chat.Id, res, false, false, 0, keyboard); } else { await Bot.SendTextMessageAsync(messageEventArgs.Message.Chat.Id, "Do not understand, sorry", false, false, 0, null); } }
private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs) { // Keyboard with one button for sender sign var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup( new Telegram.Bot.Types.InlineKeyboardButton[][] { // First row new [] { // First column new Telegram.Bot.Types.InlineKeyboardButton("sign document", "signcallback"), }, } ); long tgid = callbackQueryEventArgs.CallbackQuery.From.Id; Document d = null; if (docnamedict.ContainsKey(tgid)) { d = docnamedict[tgid]; } if (callbackQueryEventArgs.CallbackQuery.Data == "sendtosigncallback") { //await Bot.AnswerCallbackQueryAsync(callbackQueryEventArgs.CallbackQuery.Id, "You hav choosen " + callbackQueryEventArgs.CallbackQuery.Data, true); if (d != null) { // Send to the magic blockchain endpoint (CAN BE SIGNED AND ALREADY SIGNED) //String contractAddress, String docHash, //String url, String senderAdress, String recipientAdress var md5 = MD5.Create(); md5.ComputeHash(d.FileStream); apiBlockChain.unlockAccount(mainContractAdress, "123"); var l = apiBlockChain.createDeal(mainContractAdress, md5.ComputeHash(d.FileStream).ToString(), d.FilePath, "0x3e165d74b72bc6848329ff8ddf678ac19ec1a139", "0x521a2561b4eb3fda1c6af94bbf130aae23ed2765"); Console.WriteLine(l); await Bot.SendTextMessageAsync(tgid, "Document is sucessfully signed and send to", false, false, 0, null); for (var i = 0; i < contactsdict[tgid][d.FileName].Count; i++) { Contact c = contactsdict[tgid][docnamedict[tgid].FileName][i]; try { await Bot.SendTextMessageAsync(c.UserId, "Hey, you have new document for sign from " + callbackQueryEventArgs.CallbackQuery.From.FirstName + " " + callbackQueryEventArgs.CallbackQuery.From.LastName, false, false, 0, null); await Bot.SendDocumentAsync(c.UserId, d.FileId, "", false, 0, keyboard); await Bot.SendTextMessageAsync(tgid, c.FirstName + c.LastName, false, false, 0, null); Console.WriteLine("Send document to" + c.FirstName + " " + c.LastName); } catch (Exception e) { await Bot.SendTextMessageAsync(tgid, "We couldn't send document to " + c.FirstName + c.LastName, false, false, 0, null); Console.WriteLine("Couldn't send document to" + c.FirstName + " " + c.LastName); return; } } await Bot.AnswerCallbackQueryAsync(callbackQueryEventArgs.CallbackQuery.Id); //Clean data and say success this to user statedict[tgid] = "init"; docnamedict = new Dictionary <long, Document>(); contactsdict = new Dictionary <long, Dictionary <string, List <Contact> > >(); } else { await Bot.SendTextMessageAsync(tgid, "Document is already signed", false, false, 0, null); } } else if (callbackQueryEventArgs.CallbackQuery.Data == "signcallback") { // Send request the magic blockchain endpoint await Bot.SendTextMessageAsync(tgid, "Document is sucessfully signed", false, false, 0, null); await Bot.AnswerCallbackQueryAsync(callbackQueryEventArgs.CallbackQuery.Id); } }
private static void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e) { string history = ""; history += e.Message.Text; if (e.Message.Type == Telegram.Bot.Types.Enums.MessageType.Text) { var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // Строка кнопок. { InlineKeyboardButton.WithCallbackData("Калькулятор", "calculator"), InlineKeyboardButton.WithCallbackData("История", "history"), } }); Bot.SendTextMessageAsync(e.Message.Chat.Id, "Выберите действие", replyMarkup: keyboard); } // При нажатии на кнопку. Bot.OnCallbackQuery += async(object sc, Telegram.Bot.Args.CallbackQueryEventArgs ev) => { var message = ev.CallbackQuery.Message; if (ev.CallbackQuery.Data == "calculator") // При нажатии на левую кнопку меню (калькулятор). { var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // Первая строка кнопок с операциями. { InlineKeyboardButton.WithCallbackData("+", "+"), InlineKeyboardButton.WithCallbackData("-", "-"), }, new [] // Вторая строка кнопок с операциями. { InlineKeyboardButton.WithCallbackData("*", "*"), InlineKeyboardButton.WithCallbackData("/", "/") } }); await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Выберите операцию", replyMarkup : keyboard); // При нажатии на кнопку в подменю. Bot.OnCallbackQuery += async(object op, Telegram.Bot.Args.CallbackQueryEventArgs sec) => { var message2 = sec.CallbackQuery.Message; // При нажатии на кнопку сложения. if (sec.CallbackQuery.Data == "+") { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double sum = 0; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Суммируем подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { sum += Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } history += " + "; // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(sum)); } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } else // При нажатии на кнопку вычитания. if (sec.CallbackQuery.Data == "-") { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double difer = 0; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Вычитаем поочерёдно подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { difer -= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(difer)); history += " - "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } else // При нажатии на кнопку умножения. if (sec.CallbackQuery.Data == "*") { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double prod = 1; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); // Перемножаем подстроки, преобразованные в double. for (int i = 0; i < strNumbers.Length; i++) { prod *= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(prod)); history += " * "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } else if (sec.CallbackQuery.Data == "/") // при нажатии на кнопку деления { try { string s = e.Message.Text.Replace(',', '.'); string[] strNumbers; double div; // Разделяем на подстроки. strNumbers = s.Split(new char[] { ' ' }); div = Double.Parse(strNumbers[0], CultureInfo.InvariantCulture); // Разделяем поочерёдно подстроки, преобразованные в double. for (int i = 1; i < strNumbers.Length; i++) { div /= Double.Parse(strNumbers[i], CultureInfo.InvariantCulture); } // Отправляем результат собеседнику. await Bot.SendTextMessageAsync(e.Message.Chat.Id, Convert.ToString(div)); history += " / "; } catch { await Bot.SendTextMessageAsync(e.Message.Chat.Id, "Неверный ввод"); } } }; } else if (ev.CallbackQuery.Data == "history") { await Bot.SendTextMessageAsync(e.Message.Chat.Id, history); } }; }
private static async void BotOnMessageReceived(object sender, MessageEventArgs messageEventArgs) { String Answer = ""; Telegram.Bot.Types.Message msg = messageEventArgs.Message; if (msg == null || msg.Type != MessageType.Text) { return; } switch (msg.Text) { case "Факультет КТиИБ": Answer = "Ждём вас в нашем университете:)"; break; case "Геолокация": Answer = "Адрес:\nг.Ростов-на-Дону, Большая Садовая 69\nhttps://inlnk.ru/qVOKz"; break; case "Специальности": Answer = "В данном разделе мы можете посмотреть напрвления в нашем университете."; break; case "/start": Answer = "Добрый день!"; break; case "Скрыть панель": Answer = "Перейдите в /start"; await BOT.SendTextMessageAsync(msg.Chat.Id, "Для повторного вызова панели", replyMarkup : new ReplyKeyboardRemove()); break; case "Аспирантура": using (SQLiteConnection Connect = new SQLiteConnection(@"Data Source=C:\Users\kaut1\Desktop\TestDB.db; Version=3;")) { string commandText = "SELECT * FROM [Aspirantura] WHERE [name] NOT NULL"; SQLiteCommand Command = new SQLiteCommand(commandText, Connect); Connect.Open(); // открыть соединение SQLiteDataReader sqlReader = Command.ExecuteReader(); while (sqlReader.Read()) // считываем и вносим в лист все параметры { object all_task = " "; object position = " "; object name = sqlReader["name"]; ; all_task = sqlReader["exams"]; position = sqlReader["about"]; String All_Bakalavr = name + "\n\nОписание:\n" + position.ToString() + "\n\nЭкзамены(ЕГЭ):\n" + all_task.ToString(); await BOT.SendTextMessageAsync(msg.Chat.Id, All_Bakalavr); Answer = "Подробнее:\nhttps://rsue.ru/abitur/aspirantura/programmi/"; } Connect.Close(); } break; case "Бакалавриат": using (SQLiteConnection Connect = new SQLiteConnection(@"Data Source=C:\Users\kaut1\Desktop\TestDB.db; Version=3;")) { string commandText = "SELECT * FROM [dbTableName] WHERE [name] NOT NULL"; SQLiteCommand Command = new SQLiteCommand(commandText, Connect); Connect.Open(); // открыть соединение SQLiteDataReader sqlReader = Command.ExecuteReader(); while (sqlReader.Read()) // считываем и вносим в лист все параметры { object all_task = " "; object position = " "; object name = sqlReader["name"]; object bal = sqlReader["bal"]; object priceOch = sqlReader["priceOch"]; object priceZaOch = sqlReader["priceZaOch"]; all_task = sqlReader["task"]; position = sqlReader["position"]; String All_Bakalavr = name + "\n\nОписание:\n" + position.ToString() + "\n\nЭкзамены(ЕГЭ):\n" + all_task.ToString() + "\n\nПроходной балл: " + bal.ToString() + "\n\nСтоимость обучения(очная/заочная): " + priceOch.ToString() + "/" + priceZaOch.ToString(); await BOT.SendTextMessageAsync(msg.Chat.Id, All_Bakalavr); Answer = "Подробнее:\nhttp://ktib-rsue.ru/napravleniya-podgotovki.html"; } Connect.Close(); } break; case "Магистратура": using (SQLiteConnection Connect = new SQLiteConnection(@"Data Source=C:\Users\kaut1\Desktop\TestDB.db; Version=3;")) { string commandText = "SELECT * FROM [Specialitet] WHERE [name] NOT NULL"; SQLiteCommand Command = new SQLiteCommand(commandText, Connect); Connect.Open(); // открыть соединение SQLiteDataReader sqlReader = Command.ExecuteReader(); while (sqlReader.Read()) // считываем и вносим в лист все параметры { object all_task = " "; object position = " "; object name = sqlReader["name"]; all_task = sqlReader["exams"]; object priceOch = sqlReader["priceOch"]; object priceZaOch = sqlReader["priceZaOch"]; position = sqlReader["about"]; String All_Bakalavr = name + "\n\nОписание:\n" + position.ToString() + "\n\nЭкзамены(ЕГЭ):\n" + all_task.ToString() + "\n\nСтоимость обучения(очная/заочная): " + priceOch.ToString() + "руб/" + priceZaOch.ToString() + "руб"; await BOT.SendTextMessageAsync(msg.Chat.Id, All_Bakalavr); Answer = "Подробнее:\nhttp://magistratura.rsue.ru/umd.php"; } Connect.Close(); } break; case "Документы": string mesage = "Список Совета факультета\nhttps://inlnk.ru/WEVZQ "; await BOT.SendTextMessageAsync(msg.Chat.Id, mesage); mesage = "План работы Совета факультета\nhttps://inlnk.ru/qO44o"; await BOT.SendTextMessageAsync(msg.Chat.Id, mesage); Answer = "Положение об факультете\nhttps://inlnk.ru/WyGG7"; break; case "Контакты": Answer = "Приемная комиссия\nТелефон:\n+7 (863) 237-02-60\nПочта:\[email protected]\nПрниемная ректора\nТелефон:\n+7 (863) 263-30-80\nПочта:\[email protected]"; break; default: Answer = "Перейдите в /start"; break; } await BOT.SendTextMessageAsync(msg.Chat.Id, Answer); if (msg.Text == "Специальности") { var keyboard = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new KeyboardButton("Бакалавриат"), new KeyboardButton("Магистратура"), }, new[] // row 1 { new KeyboardButton("Аспирантура"), }, new[] // row 2 { new KeyboardButton("Скрыть панель"), }, }, ResizeKeyboard = true }; await BOT.SendTextMessageAsync(msg.Chat.Id, "Что вас интересует?", replyMarkup : keyboard); } if (msg.Text == "/start") { var keyboard = new Telegram.Bot.Types.ReplyMarkups.ReplyKeyboardMarkup { Keyboard = new[] { new[] // row 1 { new KeyboardButton("Специальности"), new KeyboardButton("Документы"), }, new[] // row 1 { new KeyboardButton("Контакты"), new KeyboardButton("Факультет КТиИБ"), }, new[] // row 1 { new KeyboardButton("Геолокация"), }, new[] // row 2 { new KeyboardButton("Скрыть панель"), }, }, ResizeKeyboard = true }; await BOT.SendTextMessageAsync(msg.Chat.Id, "Выберете то, что вас интересует! ", replyMarkup : keyboard); } if (msg.Text == "Факультет КТиИБ") { var keyboard = new Telegram.Bot.Types.ReplyMarkups.InlineKeyboardMarkup(new[] { new [] // first row { InlineKeyboardButton.WithUrl("Вконтакте", "https://vk.com/ktiib"), InlineKeyboardButton.WithUrl("Инстаграм", "https://www.instagram.com/f.ktiib/"), }, new [] // first row { InlineKeyboardButton.WithUrl("Наш сайт", "https://vk.com/away.php?to=http%3A%2F%2Fktib-rsue.ru"), }, }); await BOT.SendTextMessageAsync(msg.Chat.Id, "Наши социальные сети!", replyMarkup : keyboard); } }