From: Giuseppe Bilotta Date: Thu, 5 Apr 2007 21:35:05 +0000 (+0000) Subject: lastfm plugin: bugfixes, proper handling of artists/groups without description X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=df7f5c991a7f518177be58be2b0d901c1e8b4353;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git lastfm plugin: bugfixes, proper handling of artists/groups without description --- diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index dec9ef5d..f2ecd053 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -43,19 +43,25 @@ class LastFmPlugin < Plugin if page if page.match(/

(.*?)<\/a><\/h1>/) url = LASTFM + $1 - title = $2 + title = $2.ircify_html else raise "No URL/Title found for #{artist}" end - wiki = page.match(/
(.*?)<\/div>/m)[1].ircify_html + wiki = "This #{action} doesn't have a description yet. You can help by writing it: #{url}/+wiki?action=edit" + if page.match(/
(.*?)<\/div>/m) + wiki = $1.ircify_html + end + m.reply "%s : %s\n%s" % [title, url, wiki] else m.reply "no data found on #{artist}" end - rescue + rescue Exception => e m.reply "I had problems looking for #{artist}" - debug page + error e.inspect + debug e.backtrace.join("\n") + debug page[0...10*1024] return end when :song, :track @@ -63,7 +69,7 @@ class LastFmPlugin < Plugin when :album m.reply "not implemented yet, sorry" else - return usage unless what.length == 1 + return usage(m) unless what.length == 1 user = what.first begin data = open("http://ws.audioscrobbler.com/1.0/user/#{user}/#{action}.txt")