diff options
author | Casey Link <unnamedrambler@gmail.com> | 2008-06-21 08:50:32 -0400 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-06-21 15:08:52 +0200 |
commit | f267acc58f5e0765eb0c1224cf5c7775646c0b93 (patch) | |
tree | 0c35b80180d53f901a3221a0d54758afb0ee5837 | |
parent | 34bf735f9e69adb741706d874f50fab586f83ccf (diff) |
lastfm plugin: Added now playing command
-rw-r--r-- | data/rbot/plugins/lastfm.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb index 28279881..bc7f819c 100644 --- a/data/rbot/plugins/lastfm.rb +++ b/data/rbot/plugins/lastfm.rb @@ -137,6 +137,24 @@ class LastFmPlugin < Plugin end end + def now_playing(m, params) + opts = { :cache => false } + user = params[:who].to_s + page = nil + begin + page = @bot.httputil.get("#{LASTFM}/user/#{user}", opts) + if page + if page.match(/class="nowListening">\s*<td class="subject">\s*<a href="\/music.*?">(.*)<\/a>\s*<\/td/) + m.reply "#{user} is jammin to #{$1.ircify_html}" + else + m.reply "#{user} isn't listening to anything right now." + end + end + rescue + m.reply "I had problems getting #{user}'s current info" + end + end + def find_artist(m, params) artist = params[:who].to_s page = nil @@ -198,6 +216,7 @@ plugin.map 'lastfm [:num] event[s] by *who', :action => :find_event, :requiremen plugin.map 'lastfm [:num] event[s] [for] *who', :action => :find_event, :requirements => { :num => /\d+/ }, :thread => true plugin.map 'lastfm artist *who', :action => :find_artist, :thread => true plugin.map 'lastfm group *who', :action => :find_artist, :thread => true +plugin.map 'lastfm now *who', :action => :now_playing, :thread => true plugin.map 'lastfm track *dunno', :action => :find_track plugin.map 'lastfm song *dunno', :action => :find_track plugin.map 'lastfm album *dunno', :action => :find_album |