Exemplo n.º 1
0
 public static bool _Check_Update_Value_Int(Options_Handler user_option, string message, Chat chat, string resource, string resource_invaled, bool defenet)
 {
     user_option = chat_options.Where(x => x.Id == user_option.Id).FirstOrDefault();
     try
     {
         if (resource_invaled.Contains("Update_Floor_Num"))
         {
             user_option.Floor = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Num_Bed"))
         {
             user_option.Num_Bedrooms = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Num_Bath"))
         {
             user_option.Num_Bathrooms = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Floors"))
         {
             user_option.Num_Floors = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Size"))
         {
             user_option.Property_Size = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Zip_Code"))
         {
             user_option.Zip_Code = message;
         }
         if (resource_invaled.Contains("Update_Garage"))
         {
             if (_Get_Command(message, settings.Lang) != "Search_Select_Gar_Yes" && _Get_Command(message, settings.Lang) != "Search_Select_Gar_No")
             {
                 throw new NullReferenceException();
             }
             user_option.Has_Garage = _Get_Command(message, settings.Lang) == "Search_Select_Gar_Yes" ? true : false;
         }
         if (resource_invaled.Contains("Update_Garden"))
         {
             if (_Get_Command(message, settings.Lang) != "Search_Select_Grd_Yes" && _Get_Command(message, settings.Lang) != "Search_Select_Grd_No")
             {
                 throw new NullReferenceException();
             }
             user_option.Has_Garden = _Get_Command(message, settings.Lang) == "Search_Select_Grd_Yes" ? true : false;
         }
         if (resource_invaled.Contains("Update_Other_Details"))
         {
             user_option.Other_Details = message;
         }
         if (resource_invaled.Contains("Update_Sale_Price"))
         {
             user_option.Sale_Price = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Rent_Price"))
         {
             user_option.Rent_Price = int.Parse(message);
         }
         if (resource_invaled.Contains("Update_Address"))
         {
             user_option.Address = message;
         }
         if (resource_invaled.Contains("Update_Location"))
         {
             //https://www.google.com/maps/@33.2742896,36.1859014,16.75z
             string loc_temp = message;
             loc_temp = loc_temp.Replace("https://www.google.com/maps/@", "");
             string lat = loc_temp.Split(',')[0];
             string lng = loc_temp.Split(',')[1];
             _Check_Insert_Value_Location(user_option, lat, lng);
         }
         if (resource_invaled.Contains("Update_Country"))
         {
             _Check_Insert_Value_Country(user_option, message);
         }
         if (resource_invaled.Contains("Update_City"))
         {
             _Check_Insert_Value_City(user_option, message);
         }
         if (defenet)
         {
             user_option.ExpectedEntry = "Update_Select_Option";
             replay = _Update_Confirm_List(settings, out commands);
             Send_Message(replay, chat, commands);
         }
         return(true);
     }
     catch (Exception)
     {
         replay = _Get_Command_Value(resource_invaled, settings.Lang);
         Send_Message(replay, chat, null); return(true);
     }
 }
Exemplo n.º 2
0
        public static bool _Check_Input_Update(Options_Handler handler, string message, string command_en, string command_ar, Chat chat)
        {
            bool hit         = false;
            var  user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();

            switch (user_option.ExpectedEntry)
            {
            case "Update_Select_Proprty":
                user_option.ExpectedEntry = "Update_Select_Option";
                string property_data_trim = message.Remove(0, 4).TrimEnd(')').TrimStart('(');
                int    i       = property_data_trim.IndexOf(" @ ");
                string address = property_data_trim.Substring(0, i);
                string date    = property_data_trim.Substring(i + 3);
                user_option = new Telegram_HandlerClient()._Get_Property_Value(user_option, address, date);
                chat_options.Remove(chat_options.Where(x => x.Id == user_option.Id).FirstOrDefault());
                chat_options.Add(user_option);
                replay = _Update_Option_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Update_Cat":    //cat
                user_option.ExpectedEntry = "Update_Typ";
                _Category_List(settings, out commands);
                replay = _Get_Command_Value("Search_Select_Cat", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Update_Typ":
                string cat = _Category_List_Check(command_en, command_ar);

                if (user_option != null)
                {
                    user_option.Cat = cat;
                }
                user_option.ExpectedEntry = "Update_Typ_Chk";
                replay = _Get_Command_Value("Search_Select_Typ", settings.Lang);
                _Type_List(settings, cat, out commands, true);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Update_Typ_Chk":
                user_option.ExpectedEntry = "Update_Confirm";
                string typ = _Type_List_Check(command_en, command_ar);

                if (user_option != null)
                {
                    user_option.Type = typ;
                }
                replay = _Update_Confirm_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Update_Address":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Address", "Update_Address_Invalid", true);
                break;

            case "Update_Sale_Price":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Sale_Price", "Update_Sale_Price_Invalid", true);
                break;

            case "Update_Rent_Price":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Rent_Price", "Update_Rent_Price_Invalid", true);
                break;

            case "Update_Other_Details":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Other_Details", "Update_Other_Details_Invalid", true);
                break;

            case "Update_Size":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Size", "Update_Size_Invalid", true);
                break;

            case "Update_Num_Bed":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Num_Bed", "Update_Num_Bed_Invalid", true);
                break;

            case "Update_Num_Bath":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Num_Bath", "Update_Num_Bath_Invalid", true);
                break;

            case "Update_Floors":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Floors", "Update_Floors_Invalid", true);
                break;

            case "Update_Zip_Code":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Zip_Code", "Update_Zip_Code_Invalid", true);
                break;

            case "Update_Country":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_Country", "Update_Country_Invalid", false);
                user_option.ExpectedEntry = "Update_City";
                replay = _City_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Update_City":
                hit = _Check_Update_Value_Int(user_option, message, chat, "Update_City", "Update_City_Invalid", true);
                break;
            }
            return(hit);
        }
Exemplo n.º 3
0
        public static string _Type_List(Options_Handler handler, string cat, out ReplyKeyboardMarkup keyboardButtons, bool insert)
        {
            ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();

            replyKeyboardMarkup.OneTimeKeyboard = true;
            switch (cat)
            {
            case "Residental":
                replyKeyboardMarkup.Keyboard = new KeyboardButton[][]
                {
                    new KeyboardButton[]
                    {
                        new KeyboardButton(_Get_Command_Value("Property_Type", "Apartment", handler.Lang))
                    },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Commonhold", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Timeshare", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "House", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Villa", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Mansion", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(insert?"":_Get_Command_Value("Property_Type", "All", handler.Lang)) }
                };
                break;

            case "Commertial":
                replyKeyboardMarkup.Keyboard = new KeyboardButton[][]
                {
                    new KeyboardButton[]
                    {
                        new KeyboardButton(_Get_Command_Value("Property_Type", "In_Building_Shop", handler.Lang))
                    },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "In_Mall_Shop", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Office", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Building", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Mall", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Hotel", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(insert?"":_Get_Command_Value("Property_Type", "All", handler.Lang)) }
                };
                break;

            case "Luxury":
                replyKeyboardMarkup.Keyboard = new KeyboardButton[][]
                {
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Resort", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Hotel_Room", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Resturant_Table", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(insert?"":_Get_Command_Value("Property_Type", "All", handler.Lang)) }
                };
                break;

            case "Land":
                replyKeyboardMarkup.Keyboard = new KeyboardButton[][]
                {
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Residental", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Commertial", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Luxury", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Agriculture", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(_Get_Command_Value("Property_Type", "Non_Licensed", handler.Lang)) },
                    new KeyboardButton[]
                    { new KeyboardButton(insert?"":_Get_Command_Value("Property_Type", "All", handler.Lang)) }
                };
                break;
            }
            keyboardButtons = replyKeyboardMarkup;
            return("🏘");
        }
Exemplo n.º 4
0
        public static string _Update_Option_List(Options_Handler handler, out ReplyKeyboardMarkup keyboardButtons)
        {
            ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();

            replyKeyboardMarkup.OneTimeKeyboard = true;
            replyKeyboardMarkup.Keyboard        = new KeyboardButton[][]
            {
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Type", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Address", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Country_City", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Sale_Price", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Rent_Price", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Photo", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Location", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Other_Details", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Size", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Zip_Code", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Num_Bed", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Num_Bath", handler.Lang))
                },
                new KeyboardButton[]
                {
                    new KeyboardButton(_Get_Command_Value("Update_Floors", handler.Lang))
                }
            };
            keyboardButtons = replyKeyboardMarkup;
            return("🏠");
        }
Exemplo n.º 5
0
        public static InlineKeyboardMarkup Create_Calender(Options_Handler handler, int year, int month)
        {
            InlineKeyboardButton[] week1 = new InlineKeyboardButton[7];
            InlineKeyboardButton[] week2 = new InlineKeyboardButton[7];
            InlineKeyboardButton[] week3 = new InlineKeyboardButton[7];
            InlineKeyboardButton[] week4 = new InlineKeyboardButton[7];
            InlineKeyboardButton[] extra = new InlineKeyboardButton[7];
            int i = 0;
            int j = 1;

            foreach (DateTime day in EachDay(new DateTime(year, month, 1), new DateTime(year, month + 1, 1)))
            {
                if (j == 1)
                {
                    if (i < 7)
                    {
                        week1[i] = new InlineKeyboardButton {
                            Text = day.Day + "", CallbackData = "calender-day-" + day.Day
                        }; i++;
                    }
                    if (i == 7)
                    {
                        i = 0;
                        j++;
                        continue;
                    }
                }
                if (j == 2)
                {
                    if (i < 7)
                    {
                        week2[i] = new InlineKeyboardButton {
                            Text = day.Day + "", CallbackData = "calender-day-" + day.Day
                        }; i++;
                    }
                    if (i == 7)
                    {
                        i = 0;
                        j++;
                        continue;
                    }
                }
                if (j == 3)
                {
                    if (i < 7)
                    {
                        week3[i] = new InlineKeyboardButton {
                            Text = day.Day + "", CallbackData = "calender-day-" + day.Day
                        }; i++;
                    }
                    if (i == 7)
                    {
                        i = 0;
                        j++;
                        continue;
                    }
                }
                if (j == 4)
                {
                    if (i < 7)
                    {
                        week4[i] = new InlineKeyboardButton {
                            Text = day.Day + "", CallbackData = "calender-day-" + day.Day
                        }; i++;
                    }
                    if (i == 7)
                    {
                        i = 0;
                        j++;
                        continue;
                    }
                }
                if (j > 4)
                {
                    if (i < 6)
                    {
                        if (day.Day != 1)
                        {
                            extra[i] = new InlineKeyboardButton {
                                Text = day.Day + "", CallbackData = "calender-day-" + day.Day
                            }
                        }
                        ; i++;
                    }
                    if (i == 6)
                    {
                        break;
                    }
                }
            }
            for (int l = 0; l < extra.Length; l++)
            {
                extra[l] = extra[l] == null ? new InlineKeyboardButton {
                    Text = " ", CallbackData = "ignore"
                } : extra[l];
            }
            var btnarray = new InlineKeyboardButton[][]
            {
                new InlineKeyboardButton[]
                {
                    new InlineKeyboardButton {
                        Text = new DateTime(year, month, 1).ToString("MMM", CultureInfo.InvariantCulture) + " " + year, CallbackData = "ignore"
                    }
                },
                new InlineKeyboardButton[]
                {
                    new InlineKeyboardButton {
                        Text = "S"
                    },
                    new InlineKeyboardButton {
                        Text = "U"
                    },
                    new InlineKeyboardButton {
                        Text = "M"
                    },
                    new InlineKeyboardButton {
                        Text = "T"
                    },
                    new InlineKeyboardButton {
                        Text = "W"
                    },
                    new InlineKeyboardButton {
                        Text = "R"
                    },
                    new InlineKeyboardButton {
                        Text = "F"
                    }
                },
                week1,
                week2,
                week3,
                week4,
                extra
                ,
                new InlineKeyboardButton[]
                {
                    new InlineKeyboardButton {
                        Text = "<", CallbackData = "previous-month"
                    },
                    new InlineKeyboardButton {
                        Text = " ", CallbackData = "ignore"
                    },
                    new InlineKeyboardButton {
                        Text = ">", CallbackData = "next-month"
                    },
                }
            };
            InlineKeyboardMarkup markup = new InlineKeyboardMarkup(btnarray);

            return(markup);
        }
Exemplo n.º 6
0
        public static void Bot_OnMessage(Update e, TelegramBotClient service_bot)
        {
            Chat chat = e.Message.Chat;

            bot = service_bot;
            //text handling
            if (e.Message.Type == MessageType.Text)
            {
                string message = e.Message.Text;
                settings = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                if (settings == null)
                {
                    settings = new Options_Handler {
                        Id = chat.Id, Lang = "en"
                    };
                    chat_options.Add(settings);
                }//else
                 //    settings.Read_Settings();

                replay = _Get_Command_Value("Welcome", settings.Lang);
                switch (message)
                {
                case @"/start":

                    replay = _Command_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                    break;

                case @"/cancel":
                    settings.ExpectedEntry = "";
                    replay = _Command_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                    break;

                case @"/add_user":
                    _Add_User(new Options_Handler {
                        Id = chat.Id, Email = "*****@*****.**", Password = "******", FirstName = chat.FirstName, LastName = chat.LastName
                    });
                    break;

                case "/cal":
                    settings         = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                    settings.Url_ext = 0.ToString();
                    var country_buttons = _Country_List_Filters(settings);
                    Send_Message(replay, chat, country_buttons, 0);
                    replay = _Country_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                    break;

                case @"/display_param":
                    //chat_options.Clear();
                    settings = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                    if (settings != null)
                    {
                        Send_Message(
                            "Id: " + settings.Id +
                            " , Cat= " + settings.Cat +
                            " , Type= " + settings.Type +
                            " , Gar= " + settings.Garage +
                            " , grd= " + settings.Garden
                            , chat, commands);
                    }
                    break;

                default:
                    string command_en, command_ar;
                    _Get_Input_Commands(message, out command_en, out command_ar);
                    if (!(
                            _Lang(command_en, command_ar, chat) ||
                            _Search(command_en, command_ar, chat) ||
                            _Other(command_en, command_ar, chat) ||
                            _Login(command_en, command_ar, chat) ||
                            _Insert(command_en, command_ar, chat) ||
                            _Update(command_en, command_ar, chat) ||
                            _Check_Entry(settings, message, command_en, command_ar, chat)
                            ))
                    {
                        replay = _Command_List(settings, out commands);
                        settings.ExpectedEntry = "";
                        Send_Message(replay, chat, commands);
                    }
                    break;
                }
            }
            //location handling
            if (e.Message.Type == MessageType.Location)
            {
                var user_option = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                if (user_option == null)
                {
                    user_option = new Options_Handler {
                        Id = chat.Id
                    };
                    chat_options.Add(user_option);
                }
                _Check_Insert_Value_Location(user_option, e.Message.Location.Latitude.ToString(), e.Message.Location.Longitude.ToString());
                if (user_option.ExpectedEntry == "Insert_Location")
                {
                    user_option.ExpectedEntry = "Insert_Photo";
                    replay = _Get_Command_Value("Insert_Photo", settings.Lang);
                    Send_Message(replay, chat, null);
                }
                if (user_option.ExpectedEntry == "Update_Location")
                {
                    user_option.ExpectedEntry = "Update_Select_Option";
                    replay = _Update_Confirm_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                }
            }
            //photo handling
            if (e.Message.Type == MessageType.Photo)
            {
                var photo = e.Message.Photo[e.Message.Photo.Length - 1];

                var user_option = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                if (user_option == null)
                {
                    user_option = new Options_Handler {
                        Id = chat.Id
                    };
                    chat_options.Add(user_option);
                }
                _Check_Insert_Value_Photo(user_option, photo);
                if (user_option.ExpectedEntry == "Insert_Photo")
                {
                    replay = _Insert_Confirm_List(user_option, out commands);
                    Send_Message(replay, chat, commands);
                }
                if (user_option.ExpectedEntry == "Update_Photo")
                {
                    user_option.ExpectedEntry = "Update_Select_Option";
                    replay = _Update_Confirm_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                }
            }
            //callback query
            if (e.Type == UpdateType.CallbackQuery)
            {
                if (settings == null)
                {
                    settings = new Options_Handler {
                        Id = e.Message.Chat.Id, Date = DateTime.Now
                    };
                    chat_options.Add(settings);
                }
                if (e.CallbackQuery.Data.Contains("calender-day"))
                {
                    if (e.CallbackQuery.Data != "calender-day-")
                    {
                        string day = e.CallbackQuery.Data.Replace("calender-day-", "");
                        settings = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                        if (settings == null)
                        {
                            settings = new Options_Handler {
                                Id = chat.Id, Date = DateTime.Now
                            };
                            chat_options.Add(settings);
                        }
                        // day = settings.Date.Year + "-" + settings.Date.Month + "-" + day;
                        settings.Expire_Date = new DateTime(settings.Date.Year, settings.Date.Month, int.Parse(day));
                        bot.DeleteMessageAsync(chat, e.CallbackQuery.Message.MessageId);
                        settings.ExpectedEntry = "Insert_Floor_Num";
                        replay = _Get_Command_Value("Insert_Floor", settings.Lang);
                        Send_Message(replay, chat, null);
                    }
                }
                settings = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                if (e.CallbackQuery.Data == "next-month")
                {
                    bot.DeleteMessageAsync(chat, e.CallbackQuery.Message.MessageId);
                    settings.Date = settings.Date.AddMonths(1);
                    var calender = Calender.Create_Calender(null, settings.Date.Year, settings.Date.Month);
                    Send_Message(replay, chat, calender, 0);
                }
                if (e.CallbackQuery.Data == "previous-month")
                {
                    bot.DeleteMessageAsync(chat, e.CallbackQuery.Message.MessageId);
                    settings.Date = settings.Date.Month < DateTime.Now.Month ? settings.Date : settings.Date.AddMonths(-1);
                    var calender = Calender.Create_Calender(null, settings.Date.Year, settings.Date.Month);
                    Send_Message(replay, chat, calender, 0);
                }
                if (e.CallbackQuery.Data == "previous-country")
                {
                    bot.DeleteMessageAsync(chat, e.CallbackQuery.Message.MessageId);
                    if (!string.IsNullOrEmpty(settings.Url_ext))
                    {
                        settings.Url_ext = (int.Parse(settings.Url_ext) - 100).ToString();
                    }
                    else
                    {
                        settings.Url_ext = 0.ToString();
                    }
                    var country_buttons = _Country_List_Filters(settings);
                    Send_Message(replay, chat, country_buttons, 0);
                    replay = _Country_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                }
                if (e.CallbackQuery.Data == "next-country")
                {
                    bot.DeleteMessageAsync(chat, e.CallbackQuery.Message.MessageId);
                    if (!string.IsNullOrEmpty(settings.Url_ext))
                    {
                        settings.Url_ext = (int.Parse(settings.Url_ext) < 0 ? 0 : int.Parse(settings.Url_ext) + 100).ToString();
                    }
                    else
                    {
                        settings.Url_ext = 0.ToString();
                    }
                    var country_buttons = _Country_List_Filters(settings);
                    Send_Message(replay, chat, country_buttons, 0);
                    replay = _Country_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                }
            }
        }
Exemplo n.º 7
0
        public static bool _Check_Input_Signup(Options_Handler handler, string message, string command_en, string command_ar, Chat chat)
        {
            bool hit = false;

            switch (handler.ExpectedEntry)
            {
            case "Signup_Email":
                handler.ExpectedEntry = "Signup_Phone";
                replay = _Get_Command_Value("Login_SignUp_Phone", settings.Lang);
                var user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    user_option.Email = message;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Email = message, Id = chat.Id
                    });
                }
                Send_Message(replay, chat, null); hit = true;
                break;

            case "Signup_Phone":
                handler.ExpectedEntry = "Signup_Password";
                replay      = _Get_Command_Value("Login_SignUp_Password", settings.Lang);
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    user_option.Phone = message;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Phone = message, Id = chat.Id
                    });
                }
                Send_Message(replay, chat, null); hit = true;
                break;

            case "Signup_Password":
                handler.ExpectedEntry = "Signup_Password_Confirm";
                replay      = _Get_Command_Value("Login_SignUp_Password_Confirm", settings.Lang);
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    user_option.Password = message;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Password = message, Id = chat.Id
                    });
                }
                Send_Message(replay, chat, null); hit = true;
                break;

            case "Signup_Password_Confirm":
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    // if (string.IsNullOrEmpty(user_option.Oldpassword))
                    user_option.Oldpassword = message;
                    if (user_option.Oldpassword == user_option.Password)
                    {
                        Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
                        string result = telegram_Handler._Add_User(handler, Token_GET);
                        if (string.IsNullOrEmpty(result))
                        {
                            replay = _Get_Command_Value("Login_SignUp_Success", handler.Lang);
                            Send_Message(replay, chat, commands); hit = true;
                            user_option.ExpectedEntry = "Insert_Cat";
                            replay = _Get_Command_Value("Insert_Property_Cat", settings.Lang);
                            Send_Message(replay, chat, null); hit = true;
                        }
                        else
                        {
                            user_option.ExpectedEntry = "Signup_Email";
                            replay = result;
                            Send_Message(replay, chat, null);
                            replay = _Get_Command_Value("Login_SignUp_Email", settings.Lang);
                            Send_Message(replay, chat, null); hit = true;
                        }
                    }
                    else
                    {
                        replay = _Get_Command_Value("Login_SignUp_Password_Mismatch", settings.Lang);
                        Send_Message(replay, chat, null); hit = true;
                    }
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Oldpassword = message, Id = chat.Id
                    });
                }
                //Send_Message(replay, chat, null); hit = true;
                break;
            }
            return(hit);
        }
Exemplo n.º 8
0
 public static void _Add_User(Options_Handler handler)
 {
     Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
     string result = telegram_Handler._Add_User(handler, Token_GET);
 }
Exemplo n.º 9
0
        public static bool _Check_Input_Insert(Options_Handler handler, string message, string command_en, string command_ar, Chat chat)
        {
            bool hit         = false;
            var  user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();

            switch (user_option.ExpectedEntry)
            {
            case "Insert_Cat":
                user_option.ExpectedEntry = "Insert_Typ";
                string cat = _Category_List_Check(command_en, command_ar);
                replay      = _Get_Command_Value("Search_Select_Typ", settings.Lang);
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    //command_en
                    user_option.Cat = cat;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Cat = cat, Id = chat.Id
                    });
                }
                _Type_List(settings, cat, out commands, true);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Insert_Typ":
                user_option.ExpectedEntry = "Insert_Exp";
                replay = _Get_Command_Value("Search_Select_Exp", settings.Lang);
                string typ = _Type_List_Check(command_en, command_ar);
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    user_option.Type = typ;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Type = typ, Id = chat.Id
                    });
                }
                if (user_option.Date.Year < DateTime.Now.Year - 1)
                {
                    user_option.Date = DateTime.Now;
                }
                var calender = Calender.Create_Calender(handler, DateTime.Now.Year, DateTime.Now.Month + 3);
                Send_Message(replay, chat, calender, 0); hit = true;
                break;

            case "Insert_Exp":
                user_option.ExpectedEntry = "Insert_Floor_Num";
                replay      = _Get_Command_Value("Insert_Floor", settings.Lang);
                user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option.Date == DateTime.Now)
                {
                    user_option.Date = DateTime.Now.AddMonths(3);
                }
                Send_Message(replay, chat, null); hit = true;
                break;

            case "Insert_Floor_Num":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Num_Bed", "Insert_Floor_Invalid");
                break;

            case "Insert_Num_Bed":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Num_Bath", "Insert_Num_Bed_Invalid");
                break;

            case "Insert_Num_Bath":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Floors", "Insert_Num_Bath_Invalid");
                break;

            case "Insert_Floors":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Size", "Insert_Floors_Invalid");
                break;

            case "Insert_Size":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Zip_Code", "Insert_Size_Invalid");
                break;

            case "Insert_Zip_Code":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Country", "Insert_Zip_Code_Invalid");
                if (!string.IsNullOrEmpty(settings.Url_ext))
                {
                    settings.Url_ext = (int.Parse(settings.Url_ext) - 100).ToString();
                }
                else
                {
                    settings.Url_ext = 0.ToString();
                }
                var country_buttons = _Country_List_Filters(settings);
                Send_Message(replay, chat, country_buttons, 0);
                replay = _Country_List(settings, out commands);
                Send_Message(replay, chat, commands);
                break;

            case "Insert_Country":
                hit    = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_City", "Insert_Country_Invalid");
                replay = _City_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Insert_City":
                hit    = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Garage", "Insert_City_Invalid");
                replay = _Garage_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Insert_Garage":
                hit    = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Garden", "Insert_Garage_Invalid");
                replay = _Garden_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
                break;

            case "Insert_Garden":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Other_Details", "Insert_Garden_Invalid");
                break;

            case "Insert_Other_Details":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Sale_Price", "Insert_Other_Details_Invalid");
                break;

            case "Insert_Sale_Price":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Rent_Price", "Insert_Rent_Price_Invalid");
                break;

            case "Insert_Rent_Price":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Address", "Insert_Rent_Price_Invalid");
                break;

            case "Insert_Address":
                hit = _Check_Insert_Value_Int(user_option, handler, message, chat, "Insert_Location", "Insert_Addess_Invalid");
                break;
            }
            return(hit);
        }