X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Flastfm.rb;h=63935da15e0179feb02f90b3562314ac2379e710;hb=ad78fb47422664c9ce24a3b62194e42974274af7;hp=042d2d69227c92f7ed99bbc87fe1b4bd0f591d03;hpb=978db1f1e8d307d1bd8649f69e8eb581502ba317;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index 042d2d69..63935da1 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -1,24 +1,25 @@ require 'open-uri' # plugin submitted by Jeremy Voorhis (jvoorhis) - + class LastFmPlugin < Plugin def help(plugin, topic="") "lastfm => lastfm data for on last.fm where in [recenttracks, topartists, topalbums, toptracks, tags, friends, neighbors]" end - + def do_lastfm (m, params) begin + if params[:action] == "neighbors" || params[:action] == "neighbours" then + params[:action]="neighbours" + end data = open("http://ws.audioscrobbler.com/1.0/user/#{params[:user]}/#{params[:action]}.txt") m.reply "#{params[:action]} for #{params[:user]}:" - data.to_a[0..2].each do |line| - m.reply line.split(',')[-1] - end + m.reply data.to_a[0..3].map{|l| l.split(',')[-1].chomp}.join(", ") rescue m.reply "could not find #{params[:action]} for #{params[:user]} (is #{params[:user]} a user?)" end end end - + plugin = LastFmPlugin.new plugin.map 'lastfm :action :user', :action => 'do_lastfm'