From f9a4d4fb440e076c978cfbee13918824c272458e Mon Sep 17 00:00:00 2001 From: Casey Link Date: Sat, 21 Jun 2008 10:18:52 -0400 Subject: lastfm plugin: no need to specify a username for functions that act on a user. fixed help too. --- data/rbot/plugins/lastfm.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'data/rbot') diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index 42f2ea9e..0118daff 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -80,7 +80,7 @@ class LastFmPlugin < Plugin when :who "lastfm who [] => show who is at last.fm. if is empty, show who you are at lastfm." else - "lastfm => show your now playing track at lastfm. lastfm => lastfm data for on last.fm where in [recenttracks, topartists, topalbums, toptracks, tags, friends, neighbors]. other topics: events, artist, group, song, track, album, now" + "lastfm => show your now playing track at lastfm. lastfm [] => lastfm data for on last.fm where in [recenttracks, topartists, topalbums, toptracks, tags, friends, neighbors]. other topics: events, artist, group, song, track, album, now, set, who" end end @@ -249,7 +249,15 @@ class LastFmPlugin < Plugin def lastfm(m, params) action = params[:action].intern action = :neighbours if action == :neighbors - user = params[:user] + user = nil + if params[:user] then + user = params[:user].to_s + elsif @registry.has_key? ( m.sourcenick ) then + user = @registry[ m.sourcenick ] + else + m.reply "I don't know who you are on last.fm. Use 'lastfm set username' to identify yourself." + return + end begin data = @bot.httputil.get("http://ws.audioscrobbler.com/1.0/user/#{user}/#{action}.txt") m.reply "#{action} for #{user}:" @@ -275,4 +283,5 @@ plugin.map 'lastfm set *who', :action => :set_user, :thread => true plugin.map 'lastfm who *who', :action => :get_user, :thread => true plugin.map 'lastfm who', :action => :get_user, :thread => true plugin.map 'lastfm :action *user', :thread => true +plugin.map 'lastfm :action', :thread => true plugin.map 'lastfm', :action => :now_playing, :thread => true -- cgit v1.2.3