Back to Parent

def match (body, keywords)
    keywords.each do |keyword|
    keyword = keyword.downcase.strip
    if body.include?(keyword)
        return true
    end
end
return false
end


def what_problem?

    problem_list = "Electricity ๐Ÿ’ก \n" + "Plumbing ๐Ÿšฐ \n" + "Leak ๐Ÿ’ง \n" + "Heating ๐Ÿ”ฅ \n" + "Pests ๐Ÿœ \n" + "Cleaning Service ๐Ÿงน" 
    sympathy_responses = ["Oh no!", "Sorry to hear that."]
    sympathy_responses.sample + " What sort of problem is it? \n" + problem_list
end



ELECTRICITY = ["๐Ÿ’ก", "Electricity ๐Ÿ’ก", "electricity", "electric", "power", "cable", "wire", "Electricity", "electricity ๐Ÿ’ก", "โšก๏ธ"]
PLUMBING = ["๐Ÿšฐ", "Plumbing ๐Ÿšฐ", "plumbing", "clog", "clogged", "drain", "plumber", "plumbing ๐Ÿšฐ"]
LEAK = ["๐Ÿ’ง", "Leak ๐Ÿ’ง", "leaking", "leak ๐Ÿ’ง", "leakage", "leak"]
HEATING = ["๐Ÿ”ฅ", "heating", "Heating ๐Ÿ”ฅ", "heating ๐Ÿ”ฅ", "heater", "furnace"]
PESTS = ["๐Ÿœ", "Pests ๐Ÿœ", "pests", "Pests", "exterminate"]
MESSY = ["Just messy ๐Ÿงน", "๐Ÿงน", "messy", "just messy", "messy house", "dirty", "cleaner", "clutter"]

def pick_problem incoming_text
   restate_problem = "Ahh, let me see if I can find someone who can help with your #{incoming_text} problem. \n" + 
   "Message me your zipcode so I can find you some options nearby!"
   
    if match(incoming_text, ELECTRICITY)
        puts "problem is electricity - #{incoming_text}" 
        return restate_problem
    elsif match(incoming_text, PLUMBING)
        puts "problem is plumbing - #{incoming_text}" 
        return restate_problem
    elsif match(incoming_text, LEAK)
        puts "problem is leak - #{incoming_text}" 
        return restate_problem
    elsif match(incoming_text, HEATING)
        puts "problem is heating- #{incoming_text}" 
        return restate_problem
    elsif match(incoming_text, PESTS)
        puts "problem is pests - #{incoming_text}" 
        return restate_problem
    elsif match(incoming_text, MESSY)
        puts "problem is messy - #{incoming_text}" 
        return restate_problem
    else
        return error_response
    end
end
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0