if arts.length > 1
tits = []
arts.each { |el|
- artitle = (el/"div.generaltitle").first.to_html.ircify_html
+ # see if the div tag with generaltitle class is present
+ artitle = (el/"div.generaltitle").first
+ if artitle
+ tits << artitle.to_html.ircify_html
+ next
+ end
+ # otherwise, check for skin+datitle a tags
+ datitle = (el/"a.datitle").first
+ next unless datitle
+ skin = (el/"a.skin").first
+ artitle = [
+ skin ? skin.innerHTML.ircify_html : nil,
+ datitle.innerHTML.ircify_html
+ ].compact.join(" ")
tits << artitle
}
content = tits.join(" | ")
@bot.register_filter(:slashdot, :htmlinfo) { |s| slashdot_filter(s) }
end
end
-
+
def search_slashdot(m, params)
max = params[:limit].to_i
search = params[:search].to_s
debug xml.inspect
begin
doc = Document.new xml
- rescue REXML::ParseException => e
- warning e.inspect
- m.reply "couldn't parse output XML: #{e.class}"
+ rescue REXML::ParseException => err
+ warning err.inspect
+ m.reply "couldn't parse output XML: #{err.class}"
return
end
unless doc
m.reply "search for #{search} failed"
end
end
-
+
def slashdot(m, params)
debug params.inspect
max = params[:limit].to_i
max = 8 if max > 8
matches = Array.new
doc.elements.each("*/story") {|e|
- matches << [ e.elements["title"].text,
- e.elements["author"].text,
+ matches << [ e.elements["title"].text,
+ e.elements["author"].text,
e.elements["time"].text.gsub(/\d{4}-(\d{2})-(\d{2})/, "\\2/\\1").gsub(/:\d\d$/, "") ]
done += 1
break if done >= max
- }
+ }
if oneline
m.reply matches.collect{|mat| mat[0]}.join(" | ")
else