Beispiel #1
0
        public InitialCatalogueStep(long chatId, IBotClient client) : base(chatId, client)
        {
            CallbackActions.Add("Back", BackAction);

            KeyboardMarkup = new KeyboardMarkup(KeyboardTools.GetCategoriesButtonRow(CommandName));
            NextStep       = new ShowCatalogueProductsStep(ChatId, BotClient);
        }
Beispiel #2
0
        public override async Task MainAction(BotUpdate update, IBotClient clien)
        {
            NextStep = new SpecifyOrderProductsStep(ChatId, BotClient, Data);

            var keyboard = new KeyboardMarkup(KeyboardTools.GetCategoriesButtonRow(CommandName));

            await SendMessageAsync(Message, keyboardMarkup : keyboard);
        }
Beispiel #3
0
        public override async Task DefaultAction(BotUpdate update, IBotClient client)
        {
            Data.Product = Catalog.GetProductName(update.CallbackData.Split()[1]);
            var backButton = new KeyboardMarkup(KeyboardTools.GetOrderAndBackButtons(Data.Product, CommandName));

            NextStep = new ReturnOrOrderStep(Data, update.CallbackData, ChatId, client);

            await EditMessageAsync($"{Message} {Data.Product}", update.CallbackMessageId, backButton);
        }
Beispiel #4
0
        public override async Task MainAction(BotUpdate update, IBotClient clien)
        {
            Data.Category = Catalog.GetCategoryName(update.CallbackData.Split()[1]);
            NextStep      = new SpecifyPhoneStep(ChatId, BotClient, Data);

            var keyboard = new KeyboardMarkup(KeyboardTools.GetProductsButtonRow(Data.Category, CommandName));

            await EditMessageAsync(Message, update.CallbackMessageId, keyboard);
        }
        public override async Task MainAction(BotUpdate update, IBotClient clien)
        {
            Data.Adress = update.MessageText;
            NextStep    = new FinishOrderStep(ChatId, BotClient, Data);

            var keyboard = new KeyboardMarkup(KeyboardTools.GetConfirmAndCancelButtons(CommandName));

            await SendMessageAsync(Message);
            await SendMessageAsync(IsItCorrectMessage, keyboardMarkup : keyboard);
        }
        public override async Task MainAction(BotUpdate update, IBotClient client)
        {
            var keyboard = new KeyboardMarkup(new KeyboardButtonInfo[][]
            {
                KeyboardTools.GetProductsButtonRow(SelectedCategoryName, CommandName),
                new KeyboardButtonInfo[] { KeyboardTools.GetBackButton(CommandName) }
            });

            NextStep = new DescribeProductStep(ChatId, client, SelectedCategoryName);

            await EditMessageAsync(string.Format(Message, SelectedCategoryName), update.CallbackMessageId, keyboard);
        }
Beispiel #7
0
        private InlineKeyboardMarkup GetInlineKeyboardMarkup(KeyboardMarkup keyboardMarkup)
        {
            if (keyboardMarkup != null)
            {
                var inlineKeyboard = keyboardMarkup.KeyboardButtons.Select(
                    buttonArray => buttonArray.Select(buttonInfo => new InlineKeyboardButton()
                {
                    CallbackData = buttonInfo.CallbackData,
                    Text         = buttonInfo.Text
                }).ToArray()
                    ).ToArray();

                InlineKeyboardMarkup markup = new InlineKeyboardMarkup(inlineKeyboard);

                return(markup);
            }
            else
            {
                return(null);
            }
        }
 public Task EditTextMessageAsync(long chatId, int messageId, string text, KeyboardMarkup keyboard = null)
 {
     throw new NotImplementedException();
 }
 public Task SendTextMessageAsync(long chatId, string text, int replyToMessageId = 0, KeyboardMarkup keyboard = null)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public async Task EditTextMessageAsync(long chatId, int messageId, string messageText, KeyboardMarkup keyboard = null)
 {
     InlineKeyboardMarkup keyboardMarkup = GetInlineKeyboardMarkup(keyboard);
     await Client.EditMessageTextAsync(chatId, messageId, messageText, replyMarkup : keyboardMarkup);
 }
Beispiel #11
0
 public async Task SendTextMessageAsync(long chatId, string text, int replyToMessageId = 0, KeyboardMarkup keyboard = null)
 {
     InlineKeyboardMarkup keyboardMarkup = GetInlineKeyboardMarkup(keyboard);
     await Client.SendTextMessageAsync(chatId, text, replyToMessageId : replyToMessageId, replyMarkup : keyboardMarkup);
 }
Beispiel #12
0
        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);
        }
Beispiel #13
0
 public async Task EditMessageAsync(string messageText, int callbackMessageId, KeyboardMarkup keyboardMarkup = null)
 {
     await BotClient.EditTextMessageAsync(ChatId, callbackMessageId, messageText, keyboardMarkup);
 }
Beispiel #14
0
 public async Task SendMessageAsync(string messageText, int replyToMessageId = 0, KeyboardMarkup keyboardMarkup = null)
 {
     await BotClient.SendTextMessageAsync(ChatId, messageText, replyToMessageId, keyboardMarkup);
 }