3 # plugin submitted by Jeremy Voorhis (jvoorhis)
5 class LastFmPlugin < Plugin
6 def help(plugin, topic="")
7 "lastfm <function> <user> => lastfm data for <user> on last.fm where <function> in [recenttracks, topartists, topalbums, toptracks, tags, friends, neighbors]"
10 def do_lastfm (m, params)
12 if params[:action] == "neighbors" || params[:action] == "neighbours" then
13 params[:action]="neighbours"
15 data = open("http://ws.audioscrobbler.com/1.0/user/#{params[:user]}/#{params[:action]}.txt")
16 m.reply "#{params[:action]} for #{params[:user]}:"
17 data.to_a[0..2].each do |line|
18 m.reply line.split(',')[-1]
21 m.reply "could not find #{params[:action]} for #{params[:user]} (is #{params[:user]} a user?)"
26 plugin = LastFmPlugin.new
27 plugin.map 'lastfm :action :user', :action => 'do_lastfm'