From df7f5c991a7f518177be58be2b0d901c1e8b4353 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 5 Apr 2007 21:35:05 +0000 Subject: lastfm plugin: bugfixes, proper handling of artists/groups without description --- data/rbot/plugins/lastfm.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'data/rbot/plugins') 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") -- cgit v1.2.3