def next_recommendation(m, user_id): global cat, counter, name, address, latitude, longitude loc = users.get_user_location_by_user_id(m.chat.id) result = nearby_places(loc.latitude, loc.longitude, cat) if result is None: bot.send_message(m.chat.id, "Lo siento, cerca de tu localización no encuentro ningún/ninguna " + Places.get_instance().get_place_name(cat)) bot.send_sticker(m.chat.id, PEPE_CRY, reply_markup=types.ReplyKeyboardRemove()) users.store_step(user_id, START) else: if counter >= len(result): bot.send_message(m.chat.id, "Lo siento, no encuentro más resultados en tu zona") bot.send_sticker(m.chat.id, PEPE_CRY, reply_markup=types.ReplyKeyboardRemove()) users.store_step(user_id, START) counter = 0 return loc = result[counter].get('geometry').get('location') name = result[counter].get('name') address = result[counter].get('vicinity') latitude = loc.get('lat') longitude = loc.get('lng') bot.send_location(m.chat.id, latitude, longitude) bot.send_message(m.chat.id, "He encontrado este " + Places.get_instance().get_place_name(cat) + " cerca de ti, ¿Qué te parece?\n*" + name + "*\nDirección: _" + address + "_", reply_markup=user_likes.recommendation_select, parse_mode="Markdown") counter += 1 users.store_step(user_id, RECOMMENDATIONS)
def recommendations_yes_or_no(m): global cat, name, address, latitude, longitude cid = m.chat.id user_id = users.get_user_by_id(cid) text = m.text bot.send_chat_action(cid, 'typing') time.sleep(0.5) if text == 'Me gusta 😍': end_message(m, user_id) categories = Places.get_instance().get_category(cat) for category in categories: PlacesController.get_instance().create_place(name, latitude, longitude, address, category, cat, user_id) elif text == 'Prueba con otro 🔄': bot.send_message(cid, "Vamos a ver...", reply_markup=types.ReplyKeyboardRemove()) bot.send_chat_action(cid, 'typing') time.sleep(0.5) next_recommendation(m, user_id) users.store_step(user_id, RECOMMENDATIONS) elif text == 'Cancelar ❌': command_text_bye(m) else: bot.send_message(cid, "Por favor, utiliza solo los botones")