Skip to content
Browse files

youtubeurls plugin added

  • Loading branch information...
1 parent f66109f commit 79e99c23dd39f1f5ed2edf1dbc5f5713fd30cf9e @aktowns committed Jan 21, 2012
View
2 config.yml
@@ -19,6 +19,8 @@ Plugins:
Update: core
- Plugin: update-plugin
Update: core
+ - Plugin: youtubeurls-plugin
+ Update: core
# - Plugin: ey-plugin
# Update: core
# Settings:
View
1 plugins/youtubeurls-plugin/Gemfile
@@ -0,0 +1 @@
+gem 'nokogiri', '~>1.5.0'
View
5 plugins/youtubeurls-plugin/youtubeurls-plugin.yml
@@ -0,0 +1,5 @@
+Name: Youtubeurls
+Author: Ashley Towns <ashleyis@me.com>
+Version: 0.0.1
+Type: Channel
+Files: [ youtubeurls.rb ]
View
14 plugins/youtubeurls-plugin/youtubeurls.rb
@@ -0,0 +1,14 @@
+require 'nokogiri'
+require 'open-uri'
+
+class YoutubeurlsPlugin < Mirai::Plugin
+ def on_register
+ add_channel_handler(/([^\s]*?youtube\.com[^\s]*)/, :youtube_handler, :trigger => :none) # Trigger is assumed as default
+
+ end
+
+ def youtube_handler(info, url)
+ title = Nokogiri::HTML(open("http://www.youtube.com/watch?v=T-hDt2E8MoE&feature=g-logo&context=G25fb8cbFOAAAAAAAAAA")).title.strip.split("\n").first
+ msg info[:chan], "Youtube: #{title}"
+ end
+end

0 comments on commit 79e99c2

Please sign in to comment.
Something went wrong with that request. Please try again.