-
- head = results[0][0].ircify_html
- text = results[0][1].ircify_html
- m.reply "#{head} -- #{text}"
+ unless xml.elements['/queryresult'].attributes['success'] == "true"
+ m.reply "no data available"
+ return
+ end
+ answer_type, answer = [], []
+ xml.elements.each("//pod") { |element|
+ answer_type << element.attributes['title']
+ answer << element.elements['subpod/plaintext'].text
+ }
+ # find the first answer that isn't nil,
+ # starting on the second pod in the array
+ n = 1
+ answer[1..-1].each { |a|
+ break unless a.nil?
+ n += 1
+ }
+ if answer[n].nil?
+ m.reply "no results"
+ return
+ end
+ # strip spaces, pipes, and line breaks
+ sep = Bold + ' :: ' + Bold
+ chars = [ [/\n/, sep], [/\t/, " "], [/\s+/, " "], ["|", "-"] ]
+ chars.each { |c| answer[n].gsub!(c[0], c[1]) }
+ m.reply answer_type[n] + sep + answer[n]