From 5d00c76c4d78fafc9e719103e2e046c9bb51fab9 Mon Sep 17 00:00:00 2001 From: Raine Virta Date: Sun, 15 Feb 2009 02:35:39 +0200 Subject: [PATCH] last.fm plugin: list common artists in taste comparison --- data/rbot/plugins/lastfm.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index 39074404..30012597 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -177,9 +177,8 @@ class LastFmPlugin < Plugin return end end - now = artist = track = albumtxt = date = nil score = doc.root.elements["comparison/result/score"].text.to_f - rating = nil + artists = doc.root.get_elements("comparison/result/artists/artist").map { |e| e.elements["name"].text} case when score >= 0.9 rating = _("Super") @@ -194,7 +193,19 @@ class LastFmPlugin < Plugin else rating = _("Very Low") end - m.reply _("%{a}'s and %{b}'s musical compatibility rating is: %{r}") % {:a => user1, :b => user2, :r => rating} + + reply = _("%{a}'s and %{b}'s musical compatibility rating is %{bold}%{r}%{bold}") % { + :a => user1, + :b => user2, + :r => rating.downcase, + :bold => Bold + } + + reply << _(" and music they have in common includes: %{artists}") % { + :artists => artists.join(", ") + } unless artists.empty? + + m.reply reply end def now_playing(m, params) -- 2.39.5