summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-09-21 09:22:55 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-09-21 09:22:55 +0000
commit978db1f1e8d307d1bd8649f69e8eb581502ba317 (patch)
treee2cfb9e8e2469964cd7c8ffa3fc4b0b9278e5d06
parent6ff6992f6282759831e0778b6d264b46b15c7986 (diff)
lastfm plugin from Jeremy Voorhis :)
-rw-r--r--data/rbot/plugins/lastfm.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb
new file mode 100644
index 00000000..042d2d69
--- /dev/null
+++ b/data/rbot/plugins/lastfm.rb
@@ -0,0 +1,24 @@
+require 'open-uri'
+
+# plugin submitted by Jeremy Voorhis (jvoorhis)
+
+class LastFmPlugin < Plugin
+ def help(plugin, topic="")
+ "lastfm <function> <user> => lastfm data for <user> on last.fm where <function> in [recenttracks, topartists, topalbums, toptracks, tags, friends, neighbors]"
+ end
+
+ def do_lastfm (m, params)
+ begin
+ 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
+ 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'