Esempio n. 1
0
def Coords(call):
    current_user = user_dict.get(call.from_user.id)
    if current_user is not None:
        try:
            bot.edit_message_reply_markup(call.from_user.id, message_id=call.message.message_id, reply_markup=None)
            if call.data == 'Wrong city':
                current_user.step = 1
                msg = bot.send_message(call.from_user.id, "Ну, попробуй ввести еще раз)))))))))\n"
                                                          "может, по-другому как-то))",
                                       reply_markup=types.ReplyKeyboardRemove())
                bot.register_next_step_handler(msg, AdvGeoCode)
                return

            elif bool(re.search(r".*\d+[.]\d{4,6}\s.*\d+[.]\d{4,6}", call.data)):
                current_user.lon = float(call.data.split(' ')[0])
                current_user.lat = float(call.data.split(' ')[1])
                bot.send_message(call.from_user.id, "Ура!\nВот и познакомились.\nТеперь выбери,чего же ты хочешь",
                                 reply_markup=keyboard_main())
                current_user.running = False
                bot.clear_step_handler_by_chat_id(chat_id=call.from_user.id)
                return

        except AttributeError:
            if current_user.step == 1:
                pass
            else:
                msg = bot.send_message(call.from_user.id, 'Пока не выберешь что-то из списка'
                                                          ' выше ничего не произойдет..')
                bot.register_next_step_handler(msg, Coords)
            return
    else:
        to_begin(call.from_user.id, call.from_user.first_name)
        return
Esempio n. 2
0
def ProcLoc(message):
    current_user = user_dict.get(message.chat.id)
    if current_user is not None:
        if not chek(message, 'I need ur city or location.........pleeease', ProcLoc, 'text', 'location'):
            return

        elif message.location is not None:
            current_user.lon = float(message.location.longitude)
            current_user.lat = float(message.location.latitude)
            bot.send_message(message.chat.id, "Ура!\nВот и познакомились.\nТеперь выбери,чего же ты хочешь",
                             reply_markup=keyboard_main())
            current_user.running = False
            bot.clear_step_handler_by_chat_id(chat_id=message.chat.id)
            return
        elif message.text == 'Введу название':
            txt = 'Хорошо.\nНапиши, пожалуйста, название своего города(села, деревни) или откуда ты там вообще...' \
                  '\nНапример,\nМосква'
            msg = bot.send_message(message.chat.id, txt, reply_markup=types.ReplyKeyboardRemove())
            bot.register_next_step_handler(msg, AdvGeoCode)
            return

        else:
            msg = bot.send_message(message.chat.id, 'Ну кнопочками ответь, ну по-братски')
            bot.register_next_step_handler(msg, ProcLoc)
            return
    else:
        to_begin(message.chat.id, message.from_user.first_name)
Esempio n. 3
0
def acquaintanceHeat(message):
    current_user = user_dict.get(message.chat.id)
    if current_user is not None:
        if not chek(message, 'wow buddy dat s pretty cool but I need ur SEX', acquaintanceHeat, 'text'):
            return
        sex = message.text
        if (sex == 'Женский') or (sex == 'Мужской'):
            current_user.sex = sex
        elif sex == 'Я небинарное чудо':
            # В семье не без урода.
            text_sex2 = 'ЧТОШ....Ну а юбки и платья вы носите?'
            keyboard_yn = types.ReplyKeyboardMarkup(resize_keyboard=True)
            keyboard_yn.add("Дa", "Hет")
            msg = bot.send_message(message.chat.id, text_sex2, reply_markup=keyboard_yn)
            bot.register_next_step_handler(msg, acquaintanceHeat)
            return

        elif sex == "Дa" or sex == "Hет":
            current_user.sex = 'Женский'
            if sex == "Нет":
                current_user.sex = 'Мужской'
        else:
            msg = bot.reply_to(message, 'Пол введи,чудо мое\n КНОПАЧКАМИ')
            bot.register_next_step_handler(msg, acquaintanceHeat)

        if (current_user.sex == 'Женский') or (current_user.sex == 'Мужской'):
            keyboard_heat = types.ReplyKeyboardMarkup(resize_keyboard=True)
            keyboard_heat.add('Я мерзляч').add('Я горяч').add('Чё? Я норм.')
            msg = bot.send_message(message.chat.id, "Хорошо.\nНу тут одно из ТРЁХ", reply_markup=keyboard_heat)
            bot.register_next_step_handler(msg, acquaintanceLoc)
            return
    else:
        to_begin(message.chat.id, message.from_user.first_name)
Esempio n. 4
0
def common_weather_fun(mci, name):
    current_user = user_dict.get(mci)
    if current_user is not None and current_user.running is False:
        return True
    else:
        bot.send_message(mci, 'Голубчик, у меня нет твоих данных:(\nПройди, пожалуйста, регистрацию')
        to_begin(mci, name)
        return False
Esempio n. 5
0
def to_begin(mci, name):
    add_user(mci)
    bot.clear_step_handler_by_chat_id(chat_id=mci)
    current_user = user_dict.get(mci)
    current_user.name = name
    text_oa = f'{name},кажется, данные о тебе не сохранились.\nПознакомимся еще разОчек?)' \
              f' Укажите, пожалуйста, Ваш пол'
    msg = bot.send_message(mci, text_oa, reply_markup=keyboard_sex())
    bot.register_next_step_handler(msg, acquaintanceHeat)
Esempio n. 6
0
def start_message(message):
    add_user(message.chat.id)
    current_user = user_dict.get(message.chat.id)
    current_user.name = message.from_user.first_name
    if current_user.name is None:
        current_user.name = 'мое чудо'
    if not current_user.running:
        current_user.running = True
        text_hi = f"Здравствуй, {current_user.name}!\nЯ бот, давай знакомиться!\nУкажите, пожалуйста, Ваш пол"
        msg = bot.send_message(message.chat.id, text_hi, reply_markup=keyboard_sex())
        bot.register_next_step_handler(msg, acquaintanceHeat)
Esempio n. 7
0
def AdvGeoCode(message):
    current_user = user_dict.get(message.chat.id)
    if current_user is not None:
        if not chek(message, 'oh c\'mon just answer as if you were normal guy', AdvGeoCode, 'text'):
            return
        current_user.city = message.text
        try:
            list_txt = "Выберите Свой город из списка пож:"
            list_cities = keyboa_maker(items=getCoords(current_user.city))
            current_user.step = 0
            msg = bot.send_message(message.chat.id, list_txt, reply_markup=list_cities)
            bot.register_next_step_handler(msg, Coords)
        except ValueError:
            no_city_txt = 'Похоже, я не могу найти ТАКОЕ \nПопробуй по-другому пож'
            msg = bot.send_message(message.chat.id, no_city_txt, reply_markup=types.ReplyKeyboardRemove())
            bot.register_next_step_handler(msg, AdvGeoCode)
    else:
        to_begin(message.chat.id, message.from_user.first_name)
Esempio n. 8
0
def acquaintanceLoc(message):
    current_user = user_dict.get(message.chat.id)
    if current_user is not None:
        if not chek(message, 'oh c\'mon just answer as if you were normal guy', acquaintanceLoc, 'text'):
            return

        if message.text == 'Я мерзляч' or 'Я горяч' == message.text or 'Чё? Я норм.' == message.text:
            if message.text == 'Я горяч':
                current_user.heat = 1
            if message.text == 'Я мерзляч':
                current_user.heat = -1
            text_loc = "ПРЕВОСХОДНО! А погода тебе где нужна?"
            keyboard_loc = types.ReplyKeyboardMarkup(resize_keyboard=True)
            key_loc = types.KeyboardButton(text='Отправить геолокацию', request_location=True)
            keyboard_loc.add(key_loc).add('Введу название')
            msg = bot.send_message(message.chat.id, text_loc, reply_markup=keyboard_loc)
            bot.register_next_step_handler(msg, ProcLoc)
            return
        else:
            msg = bot.send_message(message.chat.id, 'Ну кнопочками ответь, ну по-братски')
            bot.register_next_step_handler(msg, acquaintanceLoc)
            return
    else:
        to_begin(message.chat.id, message.from_user.first_name)
Esempio n. 9
0
def weatherNow(message):
    if common_weather_fun(message.chat.id, message.from_user.first_name):
        current_user = user_dict.get(message.chat.id)
        cur_text = WeekForecast(current_user.lat, current_user.lon)
        bot.send_message(message.chat.id, cur_text)
Esempio n. 10
0
def ClothTom(message):
    if common_weather_fun(message.chat.id, message.from_user.first_name):
        current_user = user_dict.get(message.chat.id)
        tom_cloth = getClothTomorrow(current_user.lat, current_user.lon, current_user.sex, current_user.heat)
        bot.send_message(message.chat.id, tom_cloth)
Esempio n. 11
0
def weatherTom(message):
    if common_weather_fun(message.chat.id, message.from_user.first_name):
        current_user = user_dict.get(message.chat.id)
        tom_text = getTomorrowWeather(current_user.lat, current_user.lon)
        bot.send_message(message.chat.id, tom_text)