private static async Task DetectMessageAsync(TelegramBotAbstract telegramBotAbstract, MessageEventArgs e) { ; var botId = telegramBotAbstract.GetId(); if (AskUser.UserAnswers.ContainsUser(e.Message.From.Id, botId)) { if (AskUser.UserAnswers.GetState(e.Message.From.Id, botId) == AnswerTelegram.State.WAITING_FOR_ANSWER) { AskUser.UserAnswers.RecordAnswer(e.Message.From.Id, botId, e.Message.Text); return; } } var question = new Language(new Dictionary <string, string> { { "it", "Vuoi postare questo messaggio?" }, { "en", "Do you want to post this message?" } }); var l1 = new Language(new Dictionary <string, string> { { "it", "Si" } }); var l2 = new Language(new Dictionary <string, string> { { "it", "No" } }); var options = new List <List <Language> > { new List <Language> { l1, l2 } }; var r = await AskUser.AskBetweenRangeAsync(e.Message.From.Id, question, telegramBotAbstract, e.Message.From.LanguageCode, options, e.Message.From.Username, true, e.Message.MessageId); if (l1.Matches(r)) { //yes await AskIdentityForMessageToSend2(telegramBotAbstract, e); return; } var l3 = new Language(new Dictionary <string, string> { { "it", "Va bene. Se ti serve aiuto usa /help" }, { "en", "Ok. If you need any help, use /help" } }); await telegramBotAbstract.SendTextMessageAsync(e.Message.From.Id, l3, ChatType.Private, e.Message.From.LanguageCode, ParseMode.Html, null, e.Message.From.Username); }
private static async Task AskIdentityForMessageToSend2(TelegramBotAbstract telegramBotAbstract, MessageEventArgs e) { var question = new Language(new Dictionary <string, string> { { "it", "Vuoi essere completamente anonimo o usare uno dei nostri pseudonimi per te riservati? (non sarai riconoscibile in nessun modo, " + "tuttavia sarà chiaro a chi legge che l'autore è sempre lo stesso, se scegli lo stesso pseudonimo)" } }); var l1 = new Language(new Dictionary <string, string> { { "it", "Anonimo" } }); var l2 = new Language(new Dictionary <string, string> { { "it", "Pseudonimo" } }); var options = new List <List <Language> > { new List <Language> { l1, l2 } }; var r = await AskUser.AskBetweenRangeAsync(e.Message.From.Id, question, telegramBotAbstract, e.Message.From.LanguageCode, options, e.Message.From.Username, true, e.Message.MessageId); if (l1.Matches(r)) { await AskForMessageToReplyTo(telegramBotAbstract, e, 0); return; } await AskIdentityForMessageToSend(telegramBotAbstract, e); }
internal static async Task RoomsMainAsync(TelegramBotAbstract sender, MessageEventArgs e) { if (e.Message.Chat.Type != ChatType.Private) { return; } var question = new Language(new Dictionary <string, string> { { "it", "Scegli:" }, { "en", "Choose:" } }); var options2 = new List <Language> { new Language(new Dictionary <string, string> { { "it", "Cerca aule" }, { "en", "Search classroom" } }), new Language(new Dictionary <string, string> { { "it", "Aule libere" }, { "en", "Free classroom" } }), new Language(new Dictionary <string, string> { { "it", "Occupazioni del giorno" }, { "en", "Occupancies of the day" } }), new Language(new Dictionary <string, string> { { "it", "Aiuto" }, { "en", "Help" } }) }; var o3 = KeyboardMarkup.ArrayToMatrixString(options2); var r = await AskUser.AskBetweenRangeAsync(e.Message.From.Id, question, lang : e.Message.From.LanguageCode, options : o3, username : e.Message.From.Username, sendMessageConfirmationChoice : true, sender : sender); var chosen = Language.FindChosen(options2, r, e.Message.From.LanguageCode); if (chosen == null) { return; } switch (chosen.Value) { case 0: { await SearchClassroomAsync(sender, e); return; } case 1: { await FreeClassroomAsync(sender, e); return; } case 2: { await OccupanciesOfTheDayAsync(sender, e); return; } case 3: { await HelpAsync(sender, e); return; } } var text = new Language(new Dictionary <string, string> { { "it", "Hai compiuto una scelta che non era possibile compiere." }, { "en", "You choose something that was not possible to choose" } }); //wrong choice: (should be impossible) await SendMessage.SendMessageInPrivate(sender, e.Message.From.Id, e.Message.From.LanguageCode, e.Message.From.Username, text, ParseMode.Default, null); }