class LastFM
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/rateless_bot/plugins/lastfm.rb, line 11 def initialize(*args) super @lastfm = Lastfm.new(config[:api_key], config[:api_secret]) end
Public Instance Methods
execute(m)
click to toggle source
# File lib/rateless_bot/plugins/lastfm.rb, line 18 def execute(m) user = m.message.split('!lastfm ')[1] scrobbles = @lastfm.user.get_recent_tracks(:user => user) track = scrobbles[0] m.reply make_track_str(track) end
help()
click to toggle source
# File lib/rateless_bot/plugins/lastfm.rb, line 5 def help '!lastfm USERNAME - get a given user\'s most recently scrobbled track' end
make_track_str(track)
click to toggle source
# File lib/rateless_bot/plugins/lastfm.rb, line 27 def make_track_str(track) artist_and_title = track['artist']['content'] + ' - ' + track['name'] artist_and_title + (track['nowplaying'] ? ' [Now Playing]' : '') end