diff options
author | Raine Virta <rane@kapsi.fi> | 2009-02-15 02:35:39 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-16 20:50:11 +0100 |
commit | 5d00c76c4d78fafc9e719103e2e046c9bb51fab9 (patch) | |
tree | 062ace0af757b2cd4cce5993a02841c217263838 /data | |
parent | e3c929ff7f3e2491e7718e1da817d9de83b7bf1b (diff) |
last.fm plugin: list common artists in taste comparison
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/lastfm.rb | 17 |
1 files 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) |