diff options
author | Casey Link <unnamedrambler@gmail.com> | 2008-06-21 10:18:52 -0400 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-06-21 17:27:29 +0200 |
commit | f9a4d4fb440e076c978cfbee13918824c272458e (patch) | |
tree | 356a27a10b347136b7117dc667087383e8160e9c /data | |
parent | fdd3325c6958b9d7d4a67f2fcf541f006fcfc305 (diff) |
lastfm plugin: no need to specify a username for functions that act on a user. fixed help too.
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/lastfm.rb | 13 |
1 files changed, 11 insertions, 2 deletions
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 [<nick>] => show who <nick> is at last.fm. if <nick> is empty, show who you are at lastfm." else - "lastfm => show your now playing track at lastfm. lastfm <function> <user> => lastfm data for <user> on last.fm where <function> 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 <function> [<user>] => lastfm data for <user> on last.fm where <function> 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 |