public async override Task ExecuteAsync(CommandContext context) { if (context.IsCallback && context.Message != null) { await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty()); } CommandState newState = CommandState.MainMenu; string message = Localizer["BackMainMenu"]; var keyboard = CommandKeyboards.GetMainMenu(Localizer); if (context.State == CommandState.EditBookMenu) { context.SelectedBook = null; newState = CommandState.BookMenu; message = Localizer["BackBookMenu"]; keyboard = CommandKeyboards.GetBookMenu(Localizer); } else { context.SelectedBook = null; context.SelectedBookshelf = null; } context.ChangeState(newState); await BotClient.SendTextMessageAsync(context.Message.Chat, message, replyMarkup : keyboard); context.RedirectToCommand("/help"); }
public async override Task ExecuteAsync(CommandContext context) { EnterMessage = Localizer["AddBookshelfEnter"]; NoExitstMessage = Localizer["AddBookshelfSuccess"]; ExistMessage = Localizer["AddBookshelfError"]; IReplyMarkup keyboard = new ReplyKeyboardRemove(); if (InputData(context, out Bookshelf bookshelf)) { if (bookshelf == null) { bookshelf = new Bookshelf { Name = context.Parameters ?? context.Data, User = context.User }; context.AddBookshelf(bookshelf); context.CommandName = null; keyboard = CommandKeyboards.GetMainMenu(Localizer); } else { context.CommandName = Name; } } await BotClient.SendTextMessageAsync(context.Message.Chat, Message, replyMarkup : keyboard); }
public async override Task ExecuteAsync(CommandContext context) { EnterMessage = Localizer["RemoveBookshelfEnter"]; NoExitstMessage = Localizer["RemoveBookshelfError"]; ExistMessage = Localizer["RemoveBookshelfSuccess"]; Message = ExistMessage; IReplyMarkup keyboard = new ReplyKeyboardRemove(); var bookshelf = context.SelectedBookshelf; if (bookshelf != null || InputData(context, out bookshelf)) { if (bookshelf != null) { context.RemoveBookshelf(bookshelf); context.CommandName = null; keyboard = CommandKeyboards.GetMainMenu(Localizer); } else { context.CommandName = Name; } } await BotClient.SendTextMessageAsync(context.Message.Chat, Message, replyMarkup : keyboard); }
public async override Task ExecuteAsync(CommandContext context) { string message = Localizer["EditBookshelfEnter"]; IReplyMarkup keyboard = CommandKeyboards.GetMainMenu(Localizer); if (context.SelectedBookshelf == null || CheckParameters(context)) { context.SelectedBookshelf = FindItem(context); if (context.SelectedBookshelf == null) { message = Localizer["EditBookshelfNoExist"]; } } else if (context.Data != null && context.SelectedBookshelf != null) { if (!context.Bookshelves.Any(b => b.Name == context.Data)) { context.SelectedBookshelf.Name = context.Data; context.SelectedBookshelf = null; message = Localizer["EditBookshelfSuccess"]; } else { message = Localizer["EditBookshelfErrorName"]; } } if (message == Localizer["EditBookshelfEnter"]) { keyboard = new ReplyKeyboardRemove(); } await BotClient.SendTextMessageAsync(context.Message.Chat, message, replyMarkup : keyboard); }
public async override Task ExecuteAsync(CommandContext context) { if (context.User == null) { var message = string.Format(messageNewUser, Localizer["Start"], Localizer["InitDescription"], Localizer["MenuDescription"]); var telegramUser = context.Message.From; var user = new User { Id = telegramUser.Id, Username = telegramUser.Username, Language = telegramUser.LanguageCode }; context.User = user; await BotClient.SendTextMessageAsync(context.Message.Chat, message, ParseMode.Html); } else { context.ChangeState(CommandState.MainMenu); await BotClient.SendTextMessageAsync(context.Message.Chat, string.Format(restartMessage, Localizer["Restart"]), ParseMode.Html, replyMarkup : CommandKeyboards.GetMainMenu(Localizer)); } }