]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/lastfm.rb
reaction: spoken reactions should use plainreply, not reply
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / lastfm.rb
index 9559f76441121ff2e5e17e18117fbbc6b0d482f2..22bd113051f20c8878c1682ffb28d04f1e24bb0c 100644 (file)
@@ -192,7 +192,16 @@ class LastFmPlugin < Plugin
       uri = "#{APIURL}method=geo.getevents&location=#{CGI.escape location.to_s}"
       emptymsg = _("no events found in %{location}") % {:location => location.to_s}
     elsif venue
-      venues = search_venue_by(:name => venue.to_s, :limit => 1)
+      begin
+        venues = search_venue_by(:name => venue.to_s, :limit => 1)
+      rescue Exception => e
+        error e
+        m.reply _("an error occurred looking for venue %{venue}: %{e}") % {
+          :venue => venue.to_s,
+          :e => e.message
+        }
+      end
+
       if venues.empty?
         m.reply _("no venue found matching %{venue}") % {:venue => venue.to_s}
         return
@@ -746,11 +755,20 @@ class LastFmPlugin < Plugin
   end
 end
 
+event_map_options = {
+ :action => :find_events,
+ :requirements => {
+  :num => /\d+/,
+  :sort_order => /(?:asc|desc)(?:ending)?/
+ },
+ :thread => true
+}
+
 plugin = LastFmPlugin.new
-plugin.map 'lastfm [:num] event[s] in *location [sort[ed] by :sort_by] [in] [:sort_order] [order]', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
-plugin.map 'lastfm [:num] event[s] by *who [sort[ed] by :sort_by] [in] [:sort_order] [order]', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
-plugin.map 'lastfm [:num] event[s] at *venue [sort[ed] by :sort_by] [in] [:sort_order] [order]', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
-plugin.map 'lastfm [:num] event[s] [for] *who [sort[ed] by :sort_by] [in] [:sort_order] [order]', :action => :find_events, :requirements => { :num => /\d+/ }, :thread => true
+plugin.map 'lastfm [:num] event[s] in *location [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
+plugin.map 'lastfm [:num] event[s] by *who [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
+plugin.map 'lastfm [:num] event[s] at *venue [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
+plugin.map 'lastfm [:num] event[s] [for] *who [sort[ed] by :sort_by] [[in] :sort_order [order]]', event_map_options.dup
 plugin.map 'lastfm artist *artist', :action => :find_artist, :thread => true
 plugin.map 'lastfm album *album [by *artist]', :action => :find_album
 plugin.map 'lastfm track *track', :action => :find_track, :thread => true