Exemplo n.º 1
0
            static async Task StartMessage(Message message)
            {
                await Bot.SendChatActionAsync(message.Chat.Id, ChatAction.Typing);

                var inlineKeyboard = new InlineKeyboardMarkup(new[]
                {
                    new[] { InlineKeyboardButton.WithCallbackData("Доступные стажировки", "/internships") },
                    new[] { InlineKeyboardButton.WithCallbackData("FAQ", "/faq") },
                    new[] { InlineKeyboardButton.WithCallbackData("Правила приёма", "/rules") },
                });

                await Bot.SendTextMessageAsync(
                    chatId : message.Chat.Id,
                    text :  GoogleSheetsInterference.GetHelloMessage()
                    );

                await Bot.SendTextMessageAsync(
                    chatId : message.Chat.Id,
                    text : "Мои команды:",
                    replyMarkup : inlineKeyboard
                    );
            }
Exemplo n.º 2
0
        private static async Task BotOnMessageReceived(Message message)
        {
            Console.WriteLine($"Receive message type: {message.Type}");
            if (message.Type != MessageType.Text)
            {
                return;
            }

            if (IsRequest)
            {
                if (Count == -1)
                {
                    IsRequest = false;
                    Count     = 7;
                    GoogleSheetsInterference.AppendList(ListName, Data);

                    var keyboard = new InlineKeyboardMarkup(new[]
                    {
                        new[] { InlineKeyboardButton.WithCallbackData("Назад", "/internships") }
                    });

                    await Bot.SendTextMessageAsync(
                        chatId : message.Chat.Id,
                        text :  $"Заявка на вакансию {ListName} успешно отправлена!",
                        replyMarkup : keyboard
                        );


                    Data     = new List <object>();
                    ListName = null;
                }

                else
                {
                    if (Count == 7)
                    {
                        Data = new List <object> {
                            message.Chat.Username, message.Date.ToString(CultureInfo.InvariantCulture)
                        };
                        Count = 5;
                    }

                    Data.Add(message.Text);

                    await Bot.SendTextMessageAsync(
                        chatId : message.Chat.Id,
                        text :  $"{Props[Count]}"
                        );

                    Count--;
                }
            }

            else
            {
                var action = message.Text.Split(' ').First() switch
                {
                    "/start" => StartMessage(message),
                    _ => StartMessage(message)
                };

                await action;
            }