def search_at_dest(request, responder): l_t.delIntent() spot_name = request.entities[0]["value"][0]["cname"] id = request.params.dynamic_resource['id'] lat, long = _fetch_spot_from_kb(spot_name) res = firebase.getFoodPref(id) if not res: responder.params.target_dialogue_state = "set_food_pref" responder.reply( "Sure, please first tell us the preferences for the (veg/non-veg/italian/etc)" ) else: res_msg = getRestaurant(id, lat, long) if res_msg == '': responder.reply( "Oops! I cannot find any restaurants near you, must be a remote place 🙂~why don't you try searching with a place name....." ) else: responder.frame["for_confirmation"] = 1 responder.frame[ "for_confirmation_message"] = "There are some restaurants at your destination😋~" + "Kindly check out the following list:\n~" + res_msg responder.frame["for_denial"] = 1 responder.frame[ "for_denial_message"] = "Ok, please first tell us the preferences for the (veg/non-veg/italian/etc)" responder.reply("Your previous preferences for food was: " + res + "\nWould you like to continue?")
def search_nearby_food(request, responder): print('f') l_t.delIntent() id = request.params.dynamic_resource['id'] res = firebase.getFoodPref(id) if not res: responder.params.target_dialogue_state = "set_food_pref" responder.reply( "Sure, please first tell us the preferences for the (veg/non-veg/italian/etc)" ) else: try: lat, long = firebase.getCurrLocation(id) if lat and long: res_msg = getRestaurant(id, lat, long) if res_msg == '': responder.reply( "Oops! I cannot find any restaurants near you, must be a remote place 🙂~why don't you try searching with a place name....." ) else: responder.frame["for_confirmation"] = 1 responder.frame[ "for_confirmation_message"] = "Yay ..I found some restaurants nearby you🌮~Go and enjoy some yummy local food there😋~Below is list of restaurants, check it out:\n" + res_msg responder.frame["for_denial"] = 1 responder.frame[ "for_denial_message"] = "Ok, please first tell us the preferences for the (veg/non-veg/italian/etc)" responder.reply( "Your previous preferences for food was: " + res + "\nWould you like to continue?") except (TypeError, AttributeError): responder.params.target_dialogue_state = "search_food_at_curr" responder.reply( 'I know you are hungry😅.~But can you please share your location first so that I can help you in finding restaurants nearby you...🙂' )
def present_city(request, responder): print('f') id = request.params.dynamic_resource['id'] city_name = request.entities[0]["value"][0]["cname"] lat, long = fetch_city_coord_from_kb(city_name) intent = l_t.getIntent() hotel_msg = res_msg = '' if intent == 'loc_for_hotel': hotel_msg = hotelList(id, lat, long) if hotel_msg is None: responder.reply("We don't have any hotels for you😕.") else: responder.reply( "I have found some hotels at your current location." + "~" + "Checkout the following list of hotels:\n~" + hotel_msg + "\n") elif intent == 'loc_for_food': res_msg = getRestaurant(id, lat, long) if res_msg: responder.reply( "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n" + res_msg) else: responder.reply("We don't have any restaurants for you😕.") else: pass l_t.delIntent()
def search_food_at_curr(request, responder): l_t.delIntent() # code for getting nearest_city for the loc id = request.params.dynamic_resource['id'] lat, long = firebase.getCurrLocation(id) # end res_msg = getRestaurant(id, lat, long) responder.reply( "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n" + res_msg)
def present_city(request, responder): print('f') id = request.params.dynamic_resource['id'] city_name = request.entities[0]["value"][0]["cname"] lat, long = fetch_city_coord_from_kb(city_name) intent = l_t.getIntent() hotel_msg = res_msg = '' if intent == 'loc_for_hotel': hotel_msg = hotelList(id, lat, long) if hotel_msg is None: responder.reply("We don't have any hotels for you😕.") else: responder.reply( "I have found some hotels at your current location." + "~" + "Checkout the following list of hotels:\n~" + hotel_msg + "\n") elif intent == 'loc_for_food': res_msg = getRestaurant(id, lat, long) if res_msg: responder.reply( "Yummy food is waiting for you😋!~I found some restaurants at your current location:\nHere is the list of restaurants you can check it out:\n\n" + res_msg) else: responder.reply("We don't have any restaurants for you😕.") elif intent == 'loc_for_source': responder.reply( "Your current location has been set. Feel free to search hotels and restaurants near you" ) else: lat, long = fetch_city_coord_from_kb(city_name) location = {'Latitude': lat, 'Longitude': long} result = firebase.setCurrLocation(location, id) responder.reply( "Your current location has been set. Feel free to search hotels and restaurants near you" ) l_t.delIntent()