From b46397e1cf9698942c2a85cec42e9185cfb1bf29 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 7 Mar 2009 11:10:05 +0100 Subject: lastfm: handle no events when searching by venue --- data/rbot/plugins/lastfm.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index 11154069..9559f764 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -50,6 +50,15 @@ class ::LastFmEvent end define_structure :LastFmVenue, :id, :city, :street, :postal, :country, :name, :url, :lat, :long +class ::Struct::LastFmVenue + def to_s + str = self.name.dup + if self.country + str << " (" << [self.city, self.country].compact.join(", ") << ")" + end + str + end +end class LastFmPlugin < Plugin include REXML @@ -190,6 +199,7 @@ class LastFmPlugin < Plugin end venue = venues.first uri = "#{APIURL}method=venue.getevents&venue=#{venue.id}" + emptymsg = _("no events found at %{venue}") % {:venue => venue.to_s} elsif artist uri = "#{APIURL}method=artist.getevents&artist=#{CGI.escape artist.to_s}" emptymsg = _("no events found by %{artist}") % {:artist => artist.to_s} -- cgit v1.2.3