diff options
author | Matthias H <apoc@sixserv.org> | 2014-02-21 01:26:24 +0100 |
---|---|---|
committer | Matthias H <apoc@sixserv.org> | 2014-02-21 01:26:24 +0100 |
commit | 46861ac79ba3963cefde7402b3a167b83badeca7 (patch) | |
tree | 6e31a31f81bbc9e942f7fca996a35bd5aa11c213 /data/rbot/plugins | |
parent | 02bde5b4faa40b23e098417f89a44a24326ea6a8 (diff) |
[plugin] youtube fixed, added help text
Used the httputils api wrongly, had no help text.
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/youtube.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/data/rbot/plugins/youtube.rb b/data/rbot/plugins/youtube.rb index aede86e8..abda9ca3 100644 --- a/data/rbot/plugins/youtube.rb +++ b/data/rbot/plugins/youtube.rb @@ -24,6 +24,10 @@ class YouTubePlugin < Plugin :default => true, :desc => "Should the bot display alternative URLs (swf, rstp) for YouTube videos?") + def help(plugin, topic="") + 'youtube [search] <query> : searches youtube videos | youtube info <id> : returns description and video links' + end + def youtube_filter(s) loc = Utils.check_location(s, /youtube\.com/) return nil unless loc @@ -116,6 +120,7 @@ class YouTubePlugin < Plugin vids = [] title = nil begin +debug s.inspect doc = REXML::Document.new(s[:text]) title = doc.elements["feed/title"].text doc.elements.each("*/entry") { |e| @@ -148,8 +153,9 @@ class YouTubePlugin < Plugin debug id url = YOUTUBE_VIDEO % {:id => id} - resp, xml = @bot.httputil.get_response(url) - unless Net::HTTPSuccess === resp + resp = @bot.httputil.get_response(url) + xml = resp.body + unless resp.kind_of? Net::HTTPSuccess debug("error looking for movie %{id} on youtube: %{e}" % {:id => id, :e => xml}) return nil end @@ -198,8 +204,9 @@ class YouTubePlugin < Plugin what = params[:words].to_s searchfor = CGI.escape what url = YOUTUBE_SEARCH % {:words => searchfor} - resp, xml = @bot.httputil.get_response(url) - unless Net::HTTPSuccess === resp + resp = @bot.httputil.get_response(url) + xml = resp.body + unless resp.kind_of? Net::HTTPSuccess m.reply(_("error looking for %{what} on youtube: %{e}") % {:what => what, :e => xml}) return end @@ -235,3 +242,4 @@ plugin = YouTubePlugin.new plugin.map "youtube info :movie", :action => 'info', :threaded => true plugin.map "youtube [search] *words", :action => 'search', :threaded => true + |