Permalink
Browse files

Fixed a bug because last.fm sucks.

  • Loading branch information...
Raynes committed Apr 25, 2013
1 parent 3001545 commit e1b1658f0fa161185f9ec004b0f84ae73e429e96
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/lazybot/plugins/lastfm.clj
@@ -33,13 +33,16 @@
(defn get-association [server nick & [not-found]]
(get-in @associations [server nick] not-found))
+(defn first-if-sequential [x]
+ (if (sequential? x) (first x) x))
+
(defn get-latest-song [bot server nick]
(let [user (get-association server nick nick)]
- (when-let [latest (first (get-in (least/read "user.getRecentTracks"
- (get-api-key bot)
- {:user user
- :limit 1})
- [:recenttracks :track]))]
+ (when-let [latest (first-if-sequential (get-in (least/read "user.getRecentTracks"
+ (get-api-key bot)
+ {:user user
+ :limit 1})
+ [:recenttracks :track]))]
(format "%s %s: %s - %s [%s]"
nick
(if (= "true" (get-in latest [:attr :nowplaying]))

0 comments on commit e1b1658

Please sign in to comment.