Ejemplo n.º 1
0
 private static void GoToBeginning(CallbackQueryEventArgs callbackQueryEventArgs)
 {
     if (callbackQueryEventArgs.CallbackQuery.Data == "Начало")
     {
         InlineMenu inlineMenu = new InlineMenu();
         inlineMenu.RunCreatingProcess(callbackQueryEventArgs);
     }
 }
Ejemplo n.º 2
0
        private static async void Bot_OnCallbackQuery(object sender, CallbackQueryEventArgs e)
        {
            if (e.CallbackQuery.Data == "12")
            {
                var inlineKeyboard = new InlineKeyboardMarkup(new[]
                {
                    // first row
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Недвижимость", "s_11"),
                        InlineKeyboardButton.WithCallbackData("Авто", "s_12"),
                        InlineKeyboardButton.WithCallbackData("Услуги", "s_13")
                    },
                    // second row
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Обмен криптовалюты", "s_21"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Назад", "s_31"),
                    }
                });

                await botClient.EditMessageTextAsync(
                    chatId : e.CallbackQuery.Message.Chat.Id,
                    messageId : e.CallbackQuery.Message.MessageId,
                    text : "Сейчас можно продать, купить товары/услуги за BTC",
                    replyMarkup : inlineKeyboard
                    );
            }

            if (e.CallbackQuery.Data == "s_31")
            {
                var inlineKeyboard = new InlineKeyboardMarkup(new[]
                {
                    // first row
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Покупка", "11"),
                        InlineKeyboardButton.WithCallbackData("Продажа", "12"),
                    },
                    // second row
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Мои объявления", "21"),
                    }
                });

                await botClient.EditMessageTextAsync(
                    chatId : e.CallbackQuery.Message.Chat.Id,
                    messageId : e.CallbackQuery.Message.MessageId,
                    text : "Сейчас можно продать, купить товары/услуги за BTC",
                    replyMarkup : inlineKeyboard
                    );
            }
        }
Ejemplo n.º 3
0
        public async static void Bot_OnCallbackQueryReceived(object sender, CallbackQueryEventArgs e)
        {
            var answer = e.CallbackQuery.Data;

            switch (answer)
            {
            case "Рыжий боярин": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "КРАСАВЧЕГ!");

                await ToxicAction.QuestionTwo(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Жируня": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ТОП, ТАК ДЕРЖАТЬ");

                await ToxicAction.QuestionThree(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Брутальные каскадеры": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ЕЕЕС");

                await ToxicAction.QuestionFor(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Вилка": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "А ТЫ ШАРИШЬ");

                await ToxicAction.OrderSomeMeal(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Бамжук": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ПАПРОБУЙ ИЩЁ!");

                await ToxicAction.QuestionOne(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Каза": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ПАПРОБУЙ ИЩЁ!");

                await ToxicAction.QuestionTwo(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Сладкие педики": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ПАПРОБУЙ ИЩЁ!");

                await ToxicAction.QuestionThree(e.CallbackQuery.Message.Chat.Id);

                break;

            case "Кеды": await MainAction.SendMessage(e.CallbackQuery.Message.Chat.Id, "ПАПРОБУЙ ИЩЁ!");

                await ToxicAction.QuestionFor(e.CallbackQuery.Message.Chat.Id);

                break;
            }
        }
Ejemplo n.º 4
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var callbackQuery = callbackQueryEventArgs.CallbackQuery;

            await Bot.AnswerCallbackQueryAsync(
                callbackQuery.Id,
                $"Received {callbackQuery.Data}");

            await Bot.SendTextMessageAsync(
                callbackQuery.Message.Chat.Id,
                $"Received {callbackQuery.Data}");
        }
Ejemplo n.º 5
0
        private static async void ShowUsersActions(string sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            try
            {
                string buttonText = callbackQueryEventArgs.CallbackQuery.Data;
                Console.WriteLine($"{sender} нажал кнопку {buttonText}");

                await BotController.Bot.AnswerCallbackQueryAsync(callbackQueryEventArgs.CallbackQuery.Id, $"Вы нажали кнопку {buttonText}");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex}");
            }
        }
Ejemplo n.º 6
0
        private async void OnCallbackQuery(object sender, CallbackQueryEventArgs callbackQuery)
        {
            var callbackData = callbackQuery.CallbackQuery.Data.Replace(@"/", String.Empty);
            var response     = dispatcher.Handle(callbackData);

            if (response.Keyboard == null)
            {
                await Client.SendTextMessageAsync(
                    callbackQuery.CallbackQuery.Message.Chat.Id, text : response.Hint);
            }
            else
            {
                await Client.SendTextMessageAsync(
                    callbackQuery.CallbackQuery.Message.Chat.Id, text : response.Hint, replyMarkup : response.Keyboard);
            }
        }
Ejemplo n.º 7
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var callbackQuery = callbackQueryEventArgs.CallbackQuery;

            switch (callbackQuery.Data)
            {
            case "hoteles":
                List <string> filtroHoteles = new List <string>
                {
                    "Todos", "Estrellas", "Provincia"
                };

                await Bot.SendTextMessageAsync(
                    chatId : callbackQuery.Message.Chat.Id,
                    text : "¿Cómo desea listar los hoteles?",
                    replyMarkup : GetReplyKeyboard(filtroHoteles));

                break;

            case "reservas":
                await Bot.SendTextMessageAsync(
                    chatId : callbackQuery.Message.Chat.Id,
                    text : "Para listar sus reservas, por favor ingrese su número de cédula",
                    replyMarkup : new ForceReplyMarkup());

                break;

            default:
                foreach (Hotel h in GetHotelesFromAPI())
                {
                    if (callbackQuery.Data.Equals(h.CedulaJuridica))
                    {
                        float lat = float.Parse(h.UbicacionX.Replace('.', ','));
                        float lon = float.Parse(h.UbicacionY.Replace('.', ','));

                        await Bot.SendVenueAsync(
                            chatId : callbackQuery.Message.Chat.Id,
                            latitude : lat,
                            longitude : lon,
                            title : h.Nombre,
                            address : h.Direccion
                            );
                    }
                }
                break;
            }
        }
Ejemplo n.º 8
0
        private static async void OnInlineButtonHandlet(object sender, CallbackQueryEventArgs e)
        {
            var msg = e.CallbackQuery.Message;

            msg.ReplyMarkup = null;

            bool properly = e.CallbackQuery.Data.Contains("True");

            string[] answersMsg = GetAnswersCorrectAndUncorrect(e.CallbackQuery.Data, properly);

            string correctAnswer = answersMsg[0];
            string answer        = properly ? answersMsg[0] : answersMsg[1];

            string textMsg;

            if (properly)
            {
                textMsg = $@"✅ Правильно
Ваш ответ: {correctAnswer}";
            }
            else
            {
                textMsg = $@"❌ Неправильно
Ваш ответ: {answer}
Правильный ответ: {correctAnswer}";
            }

            await client.EditMessageTextAsync(e.CallbackQuery.Message.Chat.Id, e.CallbackQuery.Message.MessageId, $@"{msg.Text}
{textMsg}");

            anEquationAndAnswers.FormAnEquationAndAnswers(); //Создаётся новое уравнение и ответы

            string[] answers            = anEquationAndAnswers.GetAnswers();
            int      indexCorrectAnswer = anEquationAndAnswers.GetIndexCorrectAnswer();

            InlineKeyboardButton[] ikb = new InlineKeyboardButton[3];

            for (int i = 0; i < answers.Length; i++)
            {
                ikb[i] = InlineKeyboardButton.WithCallbackData(answers[i].ToString(), (i == indexCorrectAnswer) ? $"True|{answers[indexCorrectAnswer]}" : $"False|{answers[indexCorrectAnswer]}|{answers[i]}");
            }

            InlineKeyboardMarkup ikm = new InlineKeyboardMarkup(ikb);

            await client.SendTextMessageAsync(msg.Chat.Id, anEquationAndAnswers.GetEquation(), replyMarkup : ikm);
        }
Ejemplo n.º 9
0
        private async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var callbackQuery = callbackQueryEventArgs.CallbackQuery;

            if (date == DateTime.MinValue)
            {
                return;
            }
            if (!availableCurrency.Contains(callbackQuery.Data))
            {
                return;
            }

            string rate = GetRate(callbackQuery.Data, json);

            Console.WriteLine($"{callbackQuery.Message.From} asked for exchange rate on {date.ToShortDateString()} for {callbackQuery.Data} is {rate}");

            await client.SendTextMessageAsync(chatId : callbackQuery.Message.Chat.Id, text : $"Exchange rate on {date.ToShortDateString()} for {callbackQuery.Data} is {rate}")
            .ConfigureAwait(false);
        }
Ejemplo n.º 10
0
        private async void Bot_Callback(object sender, CallbackQueryEventArgs e)
        {
            var text = "";

            var id = e.CallbackQuery.Message.Chat.Id;

            var chat = trainingChats[id];

            switch (e.CallbackQuery.Data)
            {
            case "rustoeng":
                training.Add(id, TrainingType.RusToEng);

                text = chat.GetTrainingWord(TrainingType.RusToEng);

                break;

            case "engtorus":
                training.Add(id, TrainingType.EngToRus);

                text = chat.GetTrainingWord(TrainingType.EngToRus);
                break;

            default:
                break;
            }

            chat.IsTraningInProcess = true;
            activeWord.Add(id, text);

            if (trainingChats.ContainsKey(id))
            {
                trainingChats.Remove(id);
            }

            await botClient.SendTextMessageAsync(id, text);

            await botClient.AnswerCallbackQueryAsync(e.CallbackQuery.Id);
        }
Ejemplo n.º 11
0
        private static async void BotOnCallbackQueryRecived(object?sender, CallbackQueryEventArgs e)
        {
            string buttonText = e.CallbackQuery.Data;
            string name       = $"{e.CallbackQuery.From.FirstName} {e.CallbackQuery.From.LastName}";

            Console.WriteLine($"{name} нажал: {buttonText}");

            var messageId = e.CallbackQuery.From.Id;

            if (userDictionary.ContainsKey(e.CallbackQuery.From.Id))
            {
                await _botClient.SendTextMessageAsync(messageId, "*Вы уже заполняете анкету*");

                return;
            }

            if (buttonText == "Заполнить у бота")
            {
                userDictionary.Add(messageId, 0);
                userDictionaryAnswers.Add(messageId, new string[7]);
                await _botClient.SendTextMessageAsync(messageId, _questions[userDictionary[messageId]]);
            }
        }
Ejemplo n.º 12
0
        private static async void CallbackQueryReceived(object sender, CallbackQueryEventArgs e)
        {
            string[] data     = e.CallbackQuery.Data.Split(' ');
            string   list     = data[0];
            int      page     = Convert.ToInt32(data[1]);
            var      pagesNum = Convert.ToInt32(data[2]);
            string   msg;

            switch (list)
            {
            case "product":
                msg = await GetListMessage <ProductInformation>("product", page);

                break;

            case "supplier":
                msg = await GetListMessage <SupplierInformation>("supplier", page);

                break;

            case "article":
                msg = await GetListMessage <ArticleInformation>("article", page);

                break;

            default:
                msg = "No such option";
                break;
            }
            await botClient.EditMessageTextAsync(
                messageId : e.CallbackQuery.Message.MessageId,
                chatId : e.CallbackQuery.Message.Chat.Id,
                text : msg,
                parseMode : ParseMode.Html,
                replyMarkup : ikm
                );
        }
Ejemplo n.º 13
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            string word = callbackQueryEventArgs.CallbackQuery.Data;

            var url = "http://10.10.11.35:3000/earthtionary/word/" + word.Replace(" ", "%20");

            var json = new WebClient().DownloadString(url);

            List <Acronym> deserializedProduct = JsonConvert.DeserializeObject <List <Acronym> >(json);

            int    i          = 1;
            string definition = "Definition of " + word + ":\r\n\r\n";

            deserializedProduct.ForEach(x =>
            {
                if (!String.IsNullOrEmpty(x.text))
                {
                    definition += "Definition " + i + ": " + x.text + "\r\n";
                    i++;
                }
            });

            await Bot.SendTextMessageAsync(callbackQueryEventArgs.CallbackQuery.Message.Chat.Id, definition);
        }
Ejemplo n.º 14
0
        private static string GetAvailableSenderName(CallbackQueryEventArgs callbackQueryEventArgs)
        {
            string senderName;

            if (callbackQueryEventArgs.CallbackQuery.From.LastName == null && callbackQueryEventArgs.CallbackQuery.From.Username == null)
            {
                senderName = $"{callbackQueryEventArgs.CallbackQuery.From.FirstName}";
                return(senderName);
            }
            if (callbackQueryEventArgs.CallbackQuery.From.LastName == null)
            {
                senderName = $"{callbackQueryEventArgs.CallbackQuery.From.FirstName} {callbackQueryEventArgs.CallbackQuery.From.Username}";
                return(senderName);
            }
            if (callbackQueryEventArgs.CallbackQuery.From.Username == null)
            {
                senderName = $"{callbackQueryEventArgs.CallbackQuery.From.FirstName} {callbackQueryEventArgs.CallbackQuery.From.LastName}";
                return(senderName);
            }

            senderName = $"{callbackQueryEventArgs.CallbackQuery.From.FirstName} {callbackQueryEventArgs.CallbackQuery.From.LastName}" +
                         $" {callbackQueryEventArgs.CallbackQuery.From.Username}";
            return(senderName);
        }
Ejemplo n.º 15
0
        private static async void OnCallbackQueryReceived(object sender, CallbackQueryEventArgs e)
        {
            long chatId            = e.CallbackQuery.Message.Chat.Id;
            int  separatorPosition = e.CallbackQuery.Data.IndexOf(";#!");

            string keyToRemove   = e.CallbackQuery.Data.Substring(0, separatorPosition);
            string valueToRemove = e.CallbackQuery.Data.Substring(separatorPosition + 3);

            var valuesList = LearnedPhrases[keyToRemove];

            if (valuesList.Contains(valueToRemove))
            {
                valuesList.Remove(valueToRemove);
                await Bot.SendTextMessageAsync(chatId, string.Format("Eliminada la opción {0} - {1}", keyToRemove, valueToRemove));

                System.IO.File.WriteAllText(LearnedPhrasesPath, JsonConvert.SerializeObject(LearnedPhrases));
            }
            else
            {
                await Bot.SendTextMessageAsync(chatId, "No he podido eliminar esta opción, tal vez ya la haya eliminado otro!");
            }

            await Bot.DeleteMessageAsync(chatId, e.CallbackQuery.Message.MessageId);
        }
Ejemplo n.º 16
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs e)
        {
            var    message = e.CallbackQuery.Message;
            string data    = e.CallbackQuery.Data;

            switch (data)
            {
            case "Абитуриент":
                var keyboard_first = new InlineKeyboardMarkup(new[]
                {
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Как поступить в SU?", "first")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Список документов для поступления", "second")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("В какое время можно подать документы? Можно ли сделать это в субботу или воскресенье?", "third")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Могу ли я подать документы лично, если мне меньше 18 лет? Или обязательно присутствие родителей?", "four")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Контакты приемной комиссии?", "five")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("График работы приемной комиссии?", "six")
                    }
                });

                await Bot.SendTextMessageAsync(message.Chat.Id, e.CallbackQuery.Message.Text, replyMarkup : keyboard_first);

                Bot.OnCallbackQuery += async(object sc, CallbackQueryEventArgs ev) =>
                {
                    var message = ev.CallbackQuery.Message;
                    switch (ev.CallbackQuery.Data)
                    {
                    case "first":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Зарегистрироваться в онлайн режиме по адресу kb.satbayev.university");

                        break;

                    case "second":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "1. Заявление на поступление 2.Аттестат о среднем общем или диплом о начальном профессиональном или среднем профессиональном образовании(оригинал) 3.Фото формата 3х4 – 6шт 4.Медицинская справка по форме 086 - У 5.Прививочная карта по форме 063 6.Снимок флюорографии 7.Документ, подтверждающий преимущественное право 8.Сертификат ЕНТ или комплексного тестирования 9.Свидетельство о присуждении гранта(при его наличии) 10.Копия удостоверении личности 11.Приписное свидетельство ");

                        break;

                    case "third":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Подать документы можно в рабочие часы Приёмной комиссии. Они будут объявлены ближе к старту приёмной кампании.");

                        break;

                    case "four":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Вы можете подать документы и самостоятельно, только не забудьте взять с собой паспорт. Но помните: если вы поступаете на место на коммерческой основе, то заключить договор, будучи несовершеннолетним, вы самостоятельно не сможете — необходимо присутствие родителя. Кроме того, если вам меньше 18, вам обязательно нужно будет принести форму согласия на обработку ваших персональных данных, подписанную родителем или опекуном (без неё документы не примут!).");

                        break;

                    case "five":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Республика Казахстан, г. Алматы, ул. Сатпаева 22а, Главный учебный корпус (ГУК). Вход со стороны ул. Байтурсынова. +7 (727) 292 7301  +7 (727) 292 7779  +7 (727) 320 4112 [email protected]");

                        break;

                    case "six":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "График работы: пн - пт, с 8:30 до 17:30 сб, с 9:00 до 17:00 ");

                        break;
                    }
                };
                break;


            case "Бакалавриат":
                var keyboard_second = new InlineKeyboardMarkup(new[]
                {
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Есть ли общежитие? Какие критерии и требования для получения комнаты в общежитии SU?", "first"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Имеется ли в университете военная кафедра? Есть ли необходимость доплаты за военную кафедру?", "second"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Что такое кредитная технология обучения?", "third"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Какие студентческие сообщества есть в университете?", "forth"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Как вступить в один из таких сообществ?", "fifth"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("При каких обстоятельствах студент лишается гранта", "sixth"),
                    }
                });

                await Bot.SendTextMessageAsync(message.Chat.Id, e.CallbackQuery.Message.Text, replyMarkup : keyboard_second);

                Bot.OnCallbackQuery += async(object sc, CallbackQueryEventArgs ev) =>
                {
                    var message = ev.CallbackQuery.Message;
                    switch (ev.CallbackQuery.Data)
                    {
                    case "firth":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Да, в SU есть общежитие. Для того, чтобы получить место в общежитии необходимо написать заявление, все заявления в конце августа рассматривает комиссия. В первую очередь места предоставляются иногородним первокурсникам для благополучной адаптации и привыканию к новому месту жительства в первый год обучения. Вторым не маловажным условием для получения места в общежитии является материальное положение студента (при наличии подтверждающих документов).");

                        break;

                    case "second":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "В университете имеется военная кафедра, зачисление юношей на военную подготовку производится после 1 курса на конкурсной основе. Для обучения на военной кафедре выделяется государственный заказ.");

                        break;

                    case "third":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Кредитная технология обучения – способ организации учебного процесса, при котором обучающиеся в определенных границах имеют возможность индивидуально планировать последовательность образовательной траектории.");

                        break;

                    case "forth":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "«Жас Отан», «Лига Волонтеров», Дебатные клубы, Enactus, Society of Automotive Engineers, American Association of Petroleum Geologists, Society of Petroleum Engineers");

                        break;

                    case "fifth":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Ежегодно в сентябре проводится «Ярмарка студенческих сообществ», во время которой каждый желающий может открыть и презентовать свое сообщество или вступить в то сообщество, которое ему понравилось.");

                        break;

                    case "sixth":
                        await Bot.SendTextMessageAsync(message.Chat.Id, "Обучающиеся, обладатели образовательных грантов, оставленные на повторный курс обучения, лишаются образовательного гранта и продолжают свое дальнейшее обучение на платной основе. Если годовой gpa будет меньше 1,6 то студент теряет государственный образовательный грант. Если студент в итоге за дисциплину получает удовлетворительную оценку, то студент теряет стипендию.");

                        break;
                    }
                };
                break;


            case "Преподаватель":
                var keyboard_third = new InlineKeyboardMarkup(new[]
                {
                    new []
                    {
                        InlineKeyboardButton.WithUrl("Академический календарь", "https://drive.google.com/uc?export=download&id=10Z7T0DhO08kwQLA76YI1aYqkP8ZVxBSK"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithUrl("Скачать форму отчета", "https://drive.google.com/uc?export=download&id=1nEEsECD2od_zsFZlgLMWKUnB3f3VOK0T"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("", "third"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("", "forth"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("", "fifth"),
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("", "sixth"),
                    }
                });
                await Bot.SendTextMessageAsync(message.Chat.Id, e.CallbackQuery.Message.Text, replyMarkup : keyboard_third);

                break;

            case "МК":
                var keyboard_fourth = new InlineKeyboardMarkup(new[]
                {
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Главный учебный корпус", "first")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Горно-металлургический институт имени О. Байконурова", "second")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Медицинский пункт", "third")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Нефтянной корпус", "four")
                    },
                    new []
                    {
                        InlineKeyboardButton.WithCallbackData("Военная кафедра", "five")
                    }
                });

                await Bot.SendTextMessageAsync(message.Chat.Id, e.CallbackQuery.Message.Text, replyMarkup : keyboard_fourth);

                Bot.OnCallbackQuery += async(object sc, CallbackQueryEventArgs ev) =>
                {
                    var message = e.CallbackQuery.Message;
                    switch (ev.CallbackQuery.Data)
                    {
                    case "first":
                        float Latitude1  = 43.236422f;
                        float Longitude1 = 76.929755f;
                        await Bot.SendLocationAsync(message.Chat.Id, Latitude1, Longitude1);

                        break;

                    case "second":
                        float Latitude2  = 43.236520f;
                        float Longitude2 = 76.931572f;
                        await Bot.SendLocationAsync(message.Chat.Id, Latitude2, Longitude2);

                        break;

                    case "third":
                        float Latitude3  = 43.237319f;
                        float Longitude3 = 76.934405f;
                        await Bot.SendLocationAsync(message.Chat.Id, Latitude3, Longitude3);

                        break;

                    case "four":
                        float Latitude4  = 43.237093f;
                        float Longitude4 = 76.931374f;
                        await Bot.SendLocationAsync(message.Chat.Id, Latitude4, Longitude4);

                        break;

                    case "five":
                        float Latitude5  = 43.231572f;
                        float Longitude5 = 76.934406f;
                        await Bot.SendLocationAsync(message.Chat.Id, Latitude5, Longitude5);

                        break;
                    }
                };
                break;
            }

            /*if (buttonText == "Картинка")
             * {
             *  await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "https://cdn.lifehacker.ru/wp-content/uploads/2019/06/telegram_1560950950.jpg");
             * }
             * else if (buttonText == "Документ")
             * {
             * // await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "https://drive.google.com/uc?export=download&id=0B3Rr6xomyKzhc09hSW4xOGt2SmlHYl95ZWpRYnVOZkhwa0NJ");
             * }
             *
             * await Bot.AnswerCallbackQueryAsync(e.CallbackQuery.Id, $"Вы нажали кнопку {buttonText}");*/
        }
Ejemplo n.º 17
0
        public static void HandleCallbackQuery(string sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var stepId = DataBaseContext.GetStepId(callbackQueryEventArgs.CallbackQuery.From.Id);

            ShowUsersActions(sender, callbackQueryEventArgs);

            switch (stepId)
            {
            case (int)InlinePanelStep.Brands:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Список брендов")
                {
                    InlineListBrands inlineListBrands = new InlineListBrands();
                    inlineListBrands.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Инфо")
                {
                    InlineInfoBrands inlineInfoBrands = new InlineInfoBrands();
                    inlineInfoBrands.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Catalog1:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Далее")
                {
                    InlineCatalog2 inlineCatalog2 = new InlineCatalog2();
                    inlineCatalog2.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Catalog2:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineCatalog1 inlineCatalog1 = new InlineCatalog1();
                    inlineCatalog1.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Далее")
                {
                    InlineCatalog3 inlineCatalog3 = new InlineCatalog3();
                    inlineCatalog3.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Catalog3:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineCatalog2 inlineCatalog2 = new InlineCatalog2();
                    inlineCatalog2.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Далее")
                {
                    InlineCatalog4 inlineCatalog4 = new InlineCatalog4();
                    inlineCatalog4.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Catalog4:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineCatalog3 inlineCatalog3 = new InlineCatalog3();
                    inlineCatalog3.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.CatPrice:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Каталоги продукции")
                {
                    InlineCatalog1 inlineCatalog1 = new InlineCatalog1();
                    inlineCatalog1.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Прайс листы")
                {
                    InlinePriceList1 inlinePriceList1 = new InlinePriceList1();
                    inlinePriceList1.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Company:
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Contacts:
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Discount:
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.InfoBrands:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineBrands inlineBrands = new InlineBrands();
                    inlineBrands.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.ListBrands:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Каталоги и прайсы")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineBrands inlineBrands = new InlineBrands();
                    inlineBrands.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Major:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Виды продукции")
                {
                    InlineTypesProduct inlineTypesProduct = new InlineTypesProduct();
                    inlineTypesProduct.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Коротко о компании")
                {
                    InlineShort inlineShort = new InlineShort();
                    inlineShort.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Причины работать с нами")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Расписание рейсов")
                {
                    InlineTimetable inlineTimetable = new InlineTimetable();
                    inlineTimetable.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Menu:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Главная")
                {
                    InlineMajor inlineMajor = new InlineMajor();
                    inlineMajor.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Бренды")
                {
                    InlineBrands inlineBrands = new InlineBrands();
                    inlineBrands.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Каталоги и прайсы")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Акции")
                {
                    InlineDiscount inlineDiscount = new InlineDiscount();
                    inlineDiscount.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "О компании")
                {
                    InlineCompany inlineCompany = new InlineCompany();
                    inlineCompany.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Новости")
                {
                    InlineNews inlineNews = new InlineNews();
                    inlineNews.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Контакты")
                {
                    InlineContacts inlineContacts = new InlineContacts();
                    inlineContacts.RunCreatingProcess(callbackQueryEventArgs);
                }
                break;

            case (int)InlinePanelStep.News:
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.PriceList1:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Далее")
                {
                    InlinePriceList2 inlinePriceList2 = new InlinePriceList2();
                    inlinePriceList2.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.PriceList2:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlinePriceList1 inlinePriceList1 = new InlinePriceList1();
                    inlinePriceList1.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Далее")
                {
                    InlinePriceList3 inlinePriceList3 = new InlinePriceList3();
                    inlinePriceList3.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.PriceList3:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlinePriceList2 inlinePriceList2 = new InlinePriceList2();
                    inlinePriceList2.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason1:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason2:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason3:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason4:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason5:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason6:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason7:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reason8:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineReasons inlineReasons = new InlineReasons();
                    inlineReasons.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Reasons:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Низкие цены")
                {
                    InlineReason1 inlineReason1 = new InlineReason1();
                    inlineReason1.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Бесплатная доставка")
                {
                    InlineReason2 inlineReason2 = new InlineReason2();
                    inlineReason2.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Склад в Краснодаре")
                {
                    InlineReason3 inlineReason3 = new InlineReason3();
                    inlineReason3.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Широчайший ассортимент")
                {
                    InlineReason4 inlineReason4 = new InlineReason4();
                    inlineReason4.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Мы не срываем сроки")
                {
                    InlineReason5 inlineReason5 = new InlineReason5();
                    inlineReason5.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Профессиональные сотрудники")
                {
                    InlineReason6 inlineReason6 = new InlineReason6();
                    inlineReason6.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Гарантия качества")
                {
                    InlineReason7 inlineReason7 = new InlineReason7();
                    inlineReason7.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Маркетинговая поддержка")
                {
                    InlineReason8 inlineReason8 = new InlineReason8();
                    inlineReason8.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineMajor inlineMajor = new InlineMajor();
                    inlineMajor.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Short:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Подробнее о компании")
                {
                    InlineCompany inlineCompany = new InlineCompany();
                    inlineCompany.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Каталоги и прайсы")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineMajor inlineMajor = new InlineMajor();
                    inlineMajor.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.Timetable:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineMajor inlineMajor = new InlineMajor();
                    inlineMajor.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            case (int)InlinePanelStep.TypesProduct:
                if (callbackQueryEventArgs.CallbackQuery.Data == "Перейти к каталогу")
                {
                    InlineCatPrice inlineCatPrice = new InlineCatPrice();
                    inlineCatPrice.RunCreatingProcess(callbackQueryEventArgs);
                }
                if (callbackQueryEventArgs.CallbackQuery.Data == "Назад")
                {
                    InlineMajor inlineMajor = new InlineMajor();
                    inlineMajor.RunCreatingProcess(callbackQueryEventArgs);
                }
                GoToBeginning(callbackQueryEventArgs);
                break;

            default:
                InlineMenu inlineMenu = new InlineMenu();
                inlineMenu.RunCreatingProcess(callbackQueryEventArgs);
                break;
            }
        }
Ejemplo n.º 18
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var callbackQuery = callbackQueryEventArgs.CallbackQuery;

            switch (callbackQuery.Data)
            {
            case "Create folder":
                _flagCreate = true;
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Enter new folder name: ");

                break;

            case "Delete folder":
                _flagDelete = true;
                var buttonItem     = Funcs.GetListFolders(-1, Conn).ToArray();
                var keyboardMarkup = new InlineKeyboardMarkup(Funcs.GetInlineKeyboard(buttonItem));
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    $"Choose to delete {callbackQuery.Data} folder",
                    replyMarkup : keyboardMarkup);

                break;

            case "Rename folder":
                _flagRename    = true;
                buttonItem     = Funcs.GetListFolders(-1, Conn).ToArray();
                keyboardMarkup = new InlineKeyboardMarkup(Funcs.GetInlineKeyboard(buttonItem));
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    $"Choose to rename {callbackQuery.Data} folder",
                    replyMarkup : keyboardMarkup);

                break;

            case "Show folders":
                _flagShow      = true;
                buttonItem     = Funcs.GetListFolders(-1, Conn).ToArray();
                keyboardMarkup = new InlineKeyboardMarkup(Funcs.GetInlineKeyboard(buttonItem));
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Choose",
                    replyMarkup : keyboardMarkup);

                break;

            case "Add data":
                _flagAddData = true;
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Add some data");

                break;

            case "Get data":
                _flagGetData = true;

                var idFolder          = Convert.ToInt32(Database.MysqlSelect($"SELECT id FROM Folders WHERE Name = \"{_selectedButton}\"", Conn));
                var namesFiles        = Funcs.GetListFolders(idFolder, Conn);
                var keyboardMarkupNew = new InlineKeyboardMarkup(Funcs.GetInlineKeyboard(namesFiles.ToArray()));
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Choose file",
                    replyMarkup : keyboardMarkupNew);

                break;

            case "<- Back":
                _flagDelete = false;
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Choose",
                    replyMarkup : InlineKeyboard);

                break;

            case "Share storage":
                var shareKey = Guid.NewGuid().ToString();

                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    $"Your share key: {shareKey}",
                    replyMarkup : InlineKeyboard);

                break;

            case "Get shared storage":
                await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                await Bot.SendTextMessageAsync(
                    callbackQuery.Message.Chat.Id,
                    "Enter share key: ");

                break;

            default:
                if (_flagDelete)
                {
                    _flagDelete = false;

                    if (callbackQuery.Data != "<- Back")
                    {
                        Database.MysqlDeleteOrInsert($"DELETE FROM Folders WHERE Name = \"{callbackQuery.Data}\" ", Conn);
                        await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                        await Bot.SendTextMessageAsync(
                            callbackQuery.Message.Chat.Id,
                            "Choose",
                            replyMarkup : InlineKeyboard);
                    }
                }

                if (_flagRename)
                {
                    if (callbackQuery.Data != "<- Back")
                    {
                        _selectedButton = callbackQuery.Data;
                        await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                        await Bot.SendTextMessageAsync(
                            callbackQuery.Message.Chat.Id,
                            "Choose new name:");
                    }
                }

                if (_flagShow)
                {
                    _flagShow = false;
                    if (callbackQuery.Data != "<- Back")
                    {
                        _selectedButton = callbackQuery.Data;
                        buttonItem      = new[] { "<- Back", "Add data", "Get data" };
                        keyboardMarkup  = new InlineKeyboardMarkup(Funcs.GetInlineKeyboard(buttonItem));
                        await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                        await Bot.SendTextMessageAsync(
                            callbackQuery.Message.Chat.Id,
                            "Choose",
                            replyMarkup : keyboardMarkup);
                    }
                }

                if (_flagGetData)
                {
                    _flagGetData = false;
                    var idMessage = Convert.ToInt32(Database.MysqlSelect($"SELECT idMessage FROM Files WHERE Name = \"{callbackQuery.Data}\"", Conn));
                    await Bot.DeleteMessageAsync(callbackQuery.Message.Chat.Id, callbackQuery.Message.MessageId);

                    await Bot.SendTextMessageAsync(
                        callbackQuery.Message.Chat.Id,
                        "Your file",
                        replyToMessageId : idMessage,
                        replyMarkup : InlineKeyboard
                        );
                }
                break;
            }
        }
Ejemplo n.º 19
0
 private static void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 20
0
        private async void TelegramBot_OnCallbackQuery(object _sender, CallbackQueryEventArgs _e)
        {
            if (_e.CallbackQuery?.Data == null)
            {
                return;
            }

            if (PostLikeHelper.TryParseLikeInfo(_e.CallbackQuery.Data, out var likeInfo))
            {
                try
                {
                    if (likeInfo.IsLiked)
                    {
                        await m_telegramBot.AnswerCallbackQueryAsync(_e.CallbackQuery.Id, text : "Отметка ❤ уже поставлена");

                        return;
                    }

                    var user = m_userManager.GetUser(_e.CallbackQuery.Message.Chat.Id.ToString());

                    if (user == null)
                    {
                        await m_telegramBot.AnswerCallbackQueryAsync(_e.CallbackQuery.Id, text : "Пользователь не найден");

                        return;
                    }

                    try
                    {
                        await m_telegramBot.AnswerCallbackQueryAsync(_e.CallbackQuery.Id, text : "Вам ❤ это");

                        likeInfo.IsLiked = true;

                        var likeButton = KeyBoardBuilder.BuildInlineKeyboard(new[]
                        {
                            new KeyValuePair <string, string>("✅❤", PostLikeHelper.SerializeInfo(likeInfo))
                        }) as InlineKeyboardMarkup;

                        await m_telegramBot.EditMessageReplyMarkupAsync(_e.CallbackQuery.Message.Chat.Id,
                                                                        _e.CallbackQuery.Message.MessageId, replyMarkup : likeButton);

                        m_vkApi.LikePost(-likeInfo.OwnerId, (uint)likeInfo.ItemId, user.Token);
                    }
                    catch (InvalidParameterException)
                    {
                        //too late response
                    }
                    catch (Exception ex)
                    {
                        likeInfo.IsLiked = false;

                        await m_telegramBot.AnswerCallbackQueryAsync(_e.CallbackQuery.Id, text : "Не удалось поставить ❤");

                        var likeButton = KeyBoardBuilder.BuildInlineKeyboard(new[]
                        {
                            new KeyValuePair <string, string>("❤", PostLikeHelper.SerializeInfo(likeInfo))
                        }) as InlineKeyboardMarkup;

                        await m_telegramBot.EditMessageReplyMarkupAsync(_e.CallbackQuery.Message.Chat.Id,
                                                                        _e.CallbackQuery.Message.MessageId, replyMarkup : likeButton);

                        Console.WriteLine(ex);
                    }
                }
                catch (InvalidParameterException)
                {
                    //too late response
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }
Ejemplo n.º 21
0
 private static void BotOnCallbackQuery(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
 {
     CallbackQueryHandler.HandleCallbackQuery(GetAvailableSenderName(callbackQueryEventArgs), callbackQueryEventArgs);
 }
Ejemplo n.º 22
0
 private static async void OnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
 {
     var callbackQuery = callbackQueryEventArgs.CallbackQuery;
     await botClient.AnswerCallbackQueryAsync(callbackQuery.Id, $"Получен ответ {callbackQuery.Data}");
 }
Ejemplo n.º 23
0
        private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            var callbackQuery = callbackQueryEventArgs.CallbackQuery;

            switch (callbackQuery.Data)
            {
            case "mulEx":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[2]
                    );

                break;

            case "divEx":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[3]
                    );

                break;

            case "plusMinusEx":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[4]
                    );

                break;

            case "transEx_US":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[5]
                    );

                break;

            case "transEx_S":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[6]
                    );

                break;

            case "unsignedCharL1":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[7]
                    );

                break;

            case "signedCharL1":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[8]
                    );

                break;

            case "unsignedIntL1":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[9]
                    );

                break;

            case "signedIntL1":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[10]
                    );

                break;

            case "unsignedIntL2":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[11]
                    );

                break;

            case "signedIntL2":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[12]
                    );

                break;

            case "registers":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[14]
                    );

                break;

            case "directives":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[15]
                    );

                break;

            case "goFurtherConversation":
                await botClient.SendPhotoAsync(
                    callbackQuery.Message.Chat.Id,
                    mainImgs[16]
                    );

                break;

            default:
                break;
            }
        }
Ejemplo n.º 24
0
 private static async void BotOnCallbackQueryReceived(object sender, CallbackQueryEventArgs callbackQueryEventArgs)
 {
     await Bot.AnswerCallbackQueryAsync(callbackQueryEventArgs.CallbackQuery.Id,
                                        $"Received {callbackQueryEventArgs.CallbackQuery.Data}");
 }
Ejemplo n.º 25
0
        private async static void Bot_OnCallbackQueryReceived(object sender, CallbackQueryEventArgs e)
        {
            //для консоли
            string buttonText = e.CallbackQuery.Data;
            string name       = $"{e.CallbackQuery.From.FirstName} {e.CallbackQuery.From.LastName} (id:{e.CallbackQuery.From.Id})";

            Console.WriteLine(name + " pressed the button " + buttonText);


            ClassStatusList st = JsonConvert.DeserializeObject <ClassStatusList>(File.ReadAllText(stpath));

            UserStatus usrstatus = new UserStatus();
            int        index     = 0;
            bool       contains  = false;

            usrstatus.Id = Convert.ToString(e.CallbackQuery.From.Id);
            var message = e.CallbackQuery.Data;

            for (int i = 0; i < st.statuses.Count; i++)
            {
                if (st.statuses[i].Id == usrstatus.Id)
                {
                    contains  = true;
                    usrstatus = st.statuses[i];
                    index     = i;
                    break;
                }
            }

            if (contains == false)
            {
                usrstatus.status1 = 0;
                usrstatus.status2 = 0;
                usrstatus.Id      = Convert.ToString(e.CallbackQuery.From.Id);
                st.statuses.Add(usrstatus);
                index = st.statuses.IndexOf(usrstatus);
                await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Введите команду.");

                File.WriteAllText(stpath, JsonConvert.SerializeObject(st));
            }

            switch (st.statuses[index].status2)
            {
            case 0:
            {
                await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Введите, пожалуйста, команду.");

                break;
            }

            case 1:
            {         //addfavorite
                usrstatus.status1  = 0;
                usrstatus.status2  = 1;
                usrstatus.Id       = Convert.ToString(e.CallbackQuery.From.Id);
                st.statuses[index] = usrstatus;
                File.WriteAllText(stpath, JsonConvert.SerializeObject(st));

                string[] mass   = e.CallbackQuery.Data.Split('⁜');
                User     userrr = new User();
                userrr.Id     = mass[0];
                userrr.Name   = mass[1];
                userrr.Artist = mass[2];
                var json = JsonConvert.SerializeObject(userrr);
                var data = new StringContent(json, Encoding.UTF8, "application/json");


                HttpClient client   = new HttpClient();
                var        response = await client.PostAsync($"https://localhost:44348/api/Music/AddFavorite", data);

                string result = response.Content.ReadAsStringAsync().Result;

                if (result == "BAD")
                {
                    await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Данный трек уже находится в списке избранных.");
                }
                else
                {
                    await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Трек был успешно добавлен в список избранных.");
                }

                break;
            }

            case 2:
            {
                usrstatus.status1  = 0;
                usrstatus.Id       = Convert.ToString(e.CallbackQuery.From.Id);
                st.statuses[index] = usrstatus;
                File.WriteAllText(stpath, JsonConvert.SerializeObject(st));

                //deletefavorite
                string[] mass   = e.CallbackQuery.Data.Split('⁜');
                User     userrr = new User();
                userrr.Id   = mass[0];
                userrr.Name = mass[1];
                var json = JsonConvert.SerializeObject(userrr);
                var data = new StringContent(json, Encoding.UTF8, "application/json");


                HttpClient client   = new HttpClient();
                var        response = await client.PutAsync($"https://localhost:44348/api/Music/DeleteFavorite", data);

                string result = response.Content.ReadAsStringAsync().Result;

                if (result == "BAD")
                {
                    await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Данного трека нет в списке избранных.");
                }
                else
                {
                    await Bot.SendTextMessageAsync(e.CallbackQuery.From.Id, "Трек был успешно удалён из списка избранных.");
                }
                break;
            }

            default:
                break;
            }
        }