Ejemplo n.º 1
0
        public static string _Country_List(Options_Handler handler, out ReplyKeyboardMarkup keyboardButtons)
        {
            int start = int.Parse(handler.Url_ext);
            Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
            var country_list = telegram_Handler._Get_Country_List();
            int k            = start > 0?start:0;

            KeyboardButton[][] keyboard = new KeyboardButton[100][];
            for (int i = 0; i < 100; i++)
            {
                if (k < country_list.Length)
                {
                    keyboard[i] = new KeyboardButton[] { new KeyboardButton(country_list[k].Country_Name + "/" + country_list[k].Country_Native_Name) }; k++;
                }
                else
                {
                    break;
                }
            }
            keyboard = keyboard.Where(x => x != null && !string.IsNullOrEmpty(x[0].Text)).ToArray();;
            ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();

            replyKeyboardMarkup.OneTimeKeyboard = true;
            replyKeyboardMarkup.Keyboard        = keyboard;
            keyboardButtons = replyKeyboardMarkup;
            return("🌎");
        }
Ejemplo n.º 2
0
        public static bool _Check_Logged_In(Options_Handler handler)
        {
            Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();

            //if (System.Diagnostics.Debugger.IsAttached)
            //    return true;
            return(telegram_Handler._User_Exist(handler, Token_GET));
        }
Ejemplo n.º 3
0
        public static bool _Insert(string command_en, string command_ar, Chat chat)
        {
            var  user_option = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
            bool hit         = false;

            if (command_ar == "Insert" || command_en == "Insert")
            {
                if (_Check_Logged_In(settings))
                {
                    user_option.ExpectedEntry = "Insert_Cat";
                    _Category_List(settings, out commands);
                    replay = _Get_Command_Value("Insert_Property_Cat", settings.Lang);
                    Send_Message(replay, chat, commands); hit = true;
                }
                else
                {
                    replay = _Login_List(settings, out commands);
                    Send_Message(replay, chat, commands); hit = true;
                }
            }
            else if (command_ar == "Manage_Update_Password" || command_en == "Manage_Update_Password")
            {
                user_option.ExpectedEntry = "Password_Old";
                replay = _Get_Command_Value("Manage_Old_Password", settings.Lang);
                Send_Message(replay, chat, null); hit = true;
            }
            else if (command_ar == "Manage_Update_Email" || command_en == "Manage_Update_Email")
            {
                user_option.ExpectedEntry = "Email";
                replay = _Get_Command_Value("Manage_New_Email", settings.Lang);
                Send_Message(replay, chat, null); hit = true;
            }
            else if (command_ar == "Insert_Done_Yes" || command_en == "Insert_Done_Yes")
            {
                if (settings != null)
                {
                    user_option.ExpectedEntry = "";
                    Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
                    var result = telegram_Handler._Add_Property(settings, Token_GET);
                    if (string.IsNullOrEmpty(result))
                    {
                        replay = _Get_Command_Value("Insert_Done_Confirm", settings.Lang);
                        Send_Message(replay, chat, null);
                        replay = _Command_List(settings, out commands);
                        Send_Message(replay, chat, commands);
                    }
                    else
                    {
                        replay = result;
                        Send_Message(replay, chat, null);
                    }
                }
                hit = true;
            }
            return(hit);
        }
Ejemplo n.º 4
0
        public static void _Check_Input_Password(Options_Handler handler, string message, string command_en, string command_ar, Chat chat, bool old)
        {
            if (old)
            {
                var user_option = chat_options.Where(x => x.Id == chat.Id).FirstOrDefault();
                user_option.ExpectedEntry = "Password_New";
                replay = _Get_Command_Value("Manage_New_Password", settings.Lang);

                if (user_option != null)
                {
                    user_option.Oldpassword = message;
                }
                else
                {
                    chat_options.Add(new Options_Handler {
                        Oldpassword = message, Id = chat.Id
                    });
                }
                Send_Message(replay, chat, null);
                return;
            }
            if (string.IsNullOrEmpty(command_en) && string.IsNullOrEmpty(command_ar))
            {
                var user_option = chat_options.Where(x => x.Id == handler.Id).FirstOrDefault();
                if (user_option != null)
                {
                    user_option.Password = message;
                }

                Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
                string result = telegram_Handler._Update_User(handler);
                if (string.IsNullOrEmpty(result))
                {
                    _Account_List(settings, out commands);
                    user_option.ExpectedEntry = "";
                    replay = _Get_Command_Value("Manage_Password_Success", handler.Lang);
                    Send_Message(replay, chat, commands);
                }
                else
                {
                    replay = result;
                    Send_Message(replay, chat, null);
                    replay = _Get_Command_Value("Manage_New_Password", settings.Lang);
                    Send_Message(replay, chat, null);
                }
            }
        }
Ejemplo n.º 5
0
        public static void _Check_Insert_Value_City(Options_Handler user_option, string city)
        {
            Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
            var city_list = telegram_Handler._Get_City_List((int)user_option.Country_ID);
            var ct        = city.Substring(0, city.IndexOf('/'));

            foreach (var item in city_list)
            {
                if (item.City_Name == ct)
                {
                    user_option.City_ID = item.City_ID;
                }
            }
            if (user_option.City_ID == 0)
            {
                user_option.City_ID = 1;
            }
        }
Ejemplo n.º 6
0
        public static string _Update_Proprty_List(Options_Handler handler, out ReplyKeyboardMarkup keyboardButtons)
        {
            Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
            var proprty_list = telegram_Handler._Get_Property_List(handler);

            //apply filters
            KeyboardButton[][] keyboard = new KeyboardButton[10][];
            if (proprty_list.Length > 0)
            {
                for (int i = 0; i < 10; i++)
                {
                    keyboard[i] = new KeyboardButton[] { new KeyboardButton("#" + (i + 1) + ".(" + proprty_list[i].Address + " @ " + proprty_list[i].Date_Added + ")") };
                }
            }
            ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();

            replyKeyboardMarkup.OneTimeKeyboard = true;
            replyKeyboardMarkup.Keyboard        = keyboard;
            keyboardButtons = replyKeyboardMarkup;
            return("📑");
        }
Ejemplo n.º 7
0
        public static string _City_List(Options_Handler handler, out ReplyKeyboardMarkup keyboardButtons)
        {
            Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
            var city_list = telegram_Handler._Get_City_List((int)handler.Country_ID);

            KeyboardButton[][] keyboard = new KeyboardButton[city_list.Length][];
            for (int i = 0; i < 100; i++)
            {
                if (i < city_list.Length)
                {
                    keyboard[i] = new KeyboardButton[] { new KeyboardButton(city_list[i].City_Name + "/" + city_list[i].City_Native_Name) }
                }
                ;
            }
            ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();

            replyKeyboardMarkup.OneTimeKeyboard = true;
            keyboard = keyboard.Where(x => x != null && !string.IsNullOrEmpty(x[0].Text)).ToArray();
            replyKeyboardMarkup.Keyboard = keyboard;
            keyboardButtons = replyKeyboardMarkup;
            return("🗺");
        }
Ejemplo n.º 8
0
 public static void _Check_Input_Email(Options_Handler handler, string message, string command_en, string command_ar, Chat chat)
 {
     handler.Email = message;
     if (string.IsNullOrEmpty(command_en) && string.IsNullOrEmpty(command_ar))
     {
         Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
         string result = telegram_Handler._Update_User(handler);
         if (string.IsNullOrEmpty(result))
         {
             _Account_List(settings, out commands);
             handler.ExpectedEntry = "";
             replay = _Get_Command_Value("Manage_Email_Success", handler.Lang);
             Send_Message(replay, chat, commands);
         }
         else
         {
             replay = result;
             Send_Message(replay, chat, null);
             replay = _Get_Command("Manage_New_Email", settings.Lang);
             Send_Message(replay, chat, null);
         }
     }
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public static bool _Update(string command_en, string command_ar, Chat chat)
        {
            bool hit = false;

            if (command_ar == "Update" || command_en == "Update")
            {
                if (_Check_Logged_In(settings))
                {
                    settings.ExpectedEntry = "Update_Select_Proprty";
                    replay = _Update_Proprty_List(settings, out commands);
                    //filters
                    Send_Message(replay, chat, commands); hit = true;
                }
                else
                {
                    replay = _Login_List(settings, out commands);
                    Send_Message(replay, chat, commands); hit = true;
                }
            }
            else if (command_ar == "Update_Type" || command_en == "Update_Type")
            {
                settings.ExpectedEntry = "Update_Cat";
                replay = _Category_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Address" || command_en == "Update_Address")
            {
                settings.ExpectedEntry = "Update_Address";
                replay = _Get_Command_Value("Update_Address_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Sale_Price" || command_en == "Update_Sale_Price")
            {
                settings.ExpectedEntry = "Update_Sale_Price";
                replay = _Get_Command_Value("Update_Sale_Price_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Rent_Price" || command_en == "Update_Rent_Price")
            {
                settings.ExpectedEntry = "Update_Rent_Price";
                replay = _Get_Command_Value("Update_Rent_Price_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Other_Details" || command_en == "Update_Other_Details")
            {
                settings.ExpectedEntry = "Update_Other_Details";
                replay = _Get_Command_Value("Update_Other_Details_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Size" || command_en == "Update_Size")
            {
                settings.ExpectedEntry = "Update_Size";
                replay = _Get_Command_Value("Update_Size_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Num_Bed" || command_en == "Update_Num_Bed")
            {
                settings.ExpectedEntry = "Update_Num_Bed";
                replay = _Get_Command_Value("Update_Num_Bed_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Num_Bath" || command_en == "Update_Num_Bath")
            {
                settings.ExpectedEntry = "Update_Num_Bath";
                replay = _Get_Command_Value("Update_Num_Bath_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Floors" || command_en == "Update_Floors")
            {
                settings.ExpectedEntry = "Update_Floors";
                replay = _Get_Command_Value("Update_Floors_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Zip_Code" || command_en == "Update_Zip_Code")
            {
                settings.ExpectedEntry = "Update_Zip_Code";
                replay = _Get_Command_Value("Update_Zip_Code_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Zip_Code" || command_en == "Update_Zip_Code")
            {
                settings.ExpectedEntry = "Update_Zip_Code";
                replay = _Get_Command_Value("Update_Zip_Code_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Location" || command_en == "Update_Location")
            {
                settings.ExpectedEntry = "Update_Location";
                replay = _Get_Command_Value("Update_Location_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Photo" || command_en == "Update_Photo")
            {
                settings.ExpectedEntry = "Update_Photo";
                replay = _Get_Command_Value("Update_Photo_Select", settings.Lang);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Country_City" || command_en == "Update_Country_City")
            {
                settings.ExpectedEntry = "Update_Country";
                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); hit = true;
            }
            else if (command_ar == "Update_Done_Yes" || command_en == "Update_Done_Yes")
            {
                replay = _Update_Option_List(settings, out commands);
                Send_Message(replay, chat, commands); hit = true;
            }
            else if (command_ar == "Update_Done_No" || command_en == "Update_Done_No")
            {
                settings.ExpectedEntry = "";
                hit = true;
                Telegram_HandlerClient telegram_Handler = new Telegram_HandlerClient();
                var result = telegram_Handler._Add_Property(settings, Token_GET);
                if (string.IsNullOrEmpty(result))
                {
                    replay = _Get_Command_Value("Update_Done_Confirm", settings.Lang);
                    Send_Message(replay, chat, null);
                    replay = _Command_List(settings, out commands);
                    Send_Message(replay, chat, commands);
                }
                else
                {
                    replay = result;
                    Send_Message(replay, chat, null);
                    replay = _Update_Option_List(settings, out commands);
                    Send_Message(replay, chat, commands); hit = true;
                }
            }
            return(hit);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
 }