]*>.*?\((-?\d+)\).*?(.*)<\/p>\s+(?:<\/td>.*)?\z/m)
- num = $1
- vote = $2
- text = $3
- quotes << BashQuote.new(num, text, vote)
- end
- }
+ if not html
+ m.reply "unable to retrieve quotes"
+ return
+ end
+
+ quotes = get_html_quotes(html)
case quotes.length
when 0
@@ -98,8 +161,7 @@ class BashPlugin < Plugin
# may want to echo more than one for latest/random
quote = quotes.first
end
- # TODO: the gsub of br tags to | should be an ircify_html option
- m.reply "#%d (%d): %s" % [quote.num, quote.vote, quote.text.gsub(/(?:
\s*)+/, ' | ').ircify_html]
+ m.reply quote.to_s, :split_at => /\s+\|\s+/
end
def xml_bash(m, id=nil)
@@ -110,7 +172,7 @@ class BashPlugin < Plugin
xml = @bot.httputil.get("http://bash.org/xml/?random&num=1", :cache => false)
else
xml = @bot.httputil.get("http://bash.org/xml/?" + id + "&num=1")
- end
+ end
unless xml
m.reply "bash.org rss parse failed"
@@ -122,7 +184,7 @@ class BashPlugin < Plugin
return
end
doc.elements.each("*/item") {|e|
- if(id != 0)
+ if(id != 0)
reply = e.elements["title"].text.gsub(/QDB: /,"") + " " + e.elements["link"].text.gsub(/QDB: /,"") + "\n"
reply = reply + e.elements["description"].text.gsub(/\
/, "\n")
else