/// <summary> /// /// </summary> /// <param name="e"></param> /// <returns></returns> private static async Task TryMessage(MessageEventArgs e) { var chat = await ClientService.GetByChatId(e.Message.Chat.Id); var company = CompanyService.GetByChatId(e.Message.Chat.Id); var order = await OrdersService.GetByPositionChatId(e.Message.Chat.Id, 1); var tokenOrService = -1; if (e.Message.Text != null) { tokenOrService = e.Message.Text.IndexOf("_"); } //Stream read = File.OpenRead("dry.mp4"); if (e.Message.Location != null && chat != null && order != null) { if (order.Longitude == null && order.Longitude == null) { SendPayment(e); } else { InliniButtonForServices(e); } } else if (tokenOrService != -1) { AddTokenOrService(e); } else if (company != null && e.Message.Video != null || company != null && e.Message.Photo != null) { SendPhotoOrVideo(e); } else if (e.Message.Text == "/start" && chat == null) { var firstmessage = "Biz sizga kim deb murojaat qilsak bo’ladi?\n Как мы можем обратиться к вам?"; //Bot.SendVideoAsync(e.Message.Chat.Id, video: read, caption: "Dry car washing"); ClientService.AddOrUpdate(new Client() { ChatId = e.Message.Chat.Id }); Bot.SendTextMessageAsync(e.Message.Chat.Id, firstmessage); } else if (e.Message.Text == "/todayPeople" && company != null) { var count = await ClientService.GetCount(); Bot.SendTextMessageAsync(e.Message.Chat.Id, count != 0 ? "Bugungi qo'shilgan odamlar - " + count : "Bugun odam qo'shilmagan"); } else if (e.Message.Text != "/start" && chat == null) { Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos /start ni bosing"); } else if (e.Message.Text == "/info") { Bot.SendTextMessageAsync(e.Message.Chat.Id, "Call center \nTelefon: \n +998 95 001 07 99 \n \n Телефон: \n +998 95 001 07 99"); } else if (e.Message.Text == "/start" && chat.Name == null) { Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos telefon ism ni kiriting!"); } else if (e.Message.Text == "/start" && chat.Phone == null) { Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos telefon nomer ni kiriting!"); } else if (e.Message.Contact != null && chat.Phone == null) { var random = new Random().Next(10000, 99999); ClientService.AddOrUpdate(new Client() { Id = chat.Id, Name = chat.Name, Phone = e.Message.Contact.PhoneNumber, ChatId = e.Message.Chat.Id, IsActive = false, GenerateCode = random }); SendSMSForClient(e); Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos Kodni kiriting! \n \n Пожалуйста, введите код", replyMarkup: new ReplyKeyboardRemove()); } else if (e.Message.Text == "/changenumber") { ClientService.AddOrUpdate(new Client() { Id = chat.Id, Name = chat.Name, ChatId = e.Message.Chat.Id }); var secondmessage = "Ro'yxatdan o'tish uchun telefon raqamingizni kiriting \nRaqamni 901234567 shaklida yuboring. \n \n Введите свой номер телефона для регистрации \nОтправьте номер в форме 901234567."; var RequestReplyKeyboard = new ReplyKeyboardMarkup(new[]// bu yerda location qabul qilish ishlatilvotdi { new KeyboardButton("📱 Contact") { RequestContact = true } }); RequestReplyKeyboard.ResizeKeyboard = true; RequestReplyKeyboard.OneTimeKeyboard = true; Bot.SendTextMessageAsync(e.Message.Chat.Id, secondmessage, ParseMode.Default, false, false, 0, RequestReplyKeyboard); } else if (chat.Name == null) { ClientService.AddOrUpdate(new Client() { Id = chat.Id, Name = e.Message.Text, ChatId = e.Message.Chat.Id }); var secondmessage = "Ro'yxatdan o'tish uchun telefon raqamingizni kiriting \nRaqamni 901234567 shaklida yuboring. \n \n Введите свой номер телефона для регистрации \nОтправьте номер в форме 901234567."; var RequestReplyKeyboard = new ReplyKeyboardMarkup(new[]// bu yerda location qabul qilish ishlatilvotdi { new KeyboardButton("📱 Contact") { RequestContact = true } }); RequestReplyKeyboard.ResizeKeyboard = true; RequestReplyKeyboard.OneTimeKeyboard = true; Bot.SendTextMessageAsync(e.Message.Chat.Id, secondmessage, ParseMode.Default, false, false, 0, RequestReplyKeyboard); } else if (chat.Phone == null) { try { if (e.Message.Text.Length == 9) { var random = new Random().Next(10000, 99999); var phone = Convert.ToInt32(e.Message.Text); ClientService.AddOrUpdate(new Client() { Id = chat.Id, Name = chat.Name, Phone = e.Message.Text, ChatId = e.Message.Chat.Id, IsActive = false, GenerateCode = random }); Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos kodni kiriting! \nПожалуйста, введите код!"); SendSMSForClient(e); } else { var secondmessage = "Telefon raqam noto'g'ri kiritildi \n Raqamni 901234567 shaklida yuboring!"; Bot.SendTextMessageAsync(e.Message.From.Id, secondmessage); } } catch { var secondmessage = "Telefon raqam noto'g'ri kiritildi \n Raqamni 901234567 shaklida yuboring!"; Bot.SendTextMessageAsync(e.Message.From.Id, secondmessage); } } else if (chat.IsActive == false && chat.GenerateCode.ToString() == e.Message.Text) { ClientService.AddOrUpdate(new Client() { Id = chat.Id, Name = chat.Name, Phone = chat.Phone, GenerateCode = chat.GenerateCode, ChatId = e.Message.Chat.Id, IsActive = true, DateCreate = DateTime.Now.Date }); InliniButtonForServices(e); } else if (chat.IsActive == true) { InliniButtonForServices(e); } else if (chat.IsActive == false && chat.GenerateCode.ToString() != e.Message.Text) { Bot.SendTextMessageAsync(e.Message.Chat.Id, "Iltimos kodni to'g'ri kiriting!"); } else if (e.Message != null && chat != null) { Bot.SendTextMessageAsync(e.Message.Chat.Id, chat.Name == null ? "Iltimos ismni kiritin" : "Iltimos nomerni kiritin"); } }