From 0bf63b771bf514a4883ac3ee8f77c01bc08c1afc Mon Sep 17 00:00:00 2001
From: Alexandre Morignot <erdnaxeli@gmail.com>
Date: Tue, 1 Jan 2013 22:31:18 +0100
Subject: [PATCH] =?UTF-8?q?S=C3=A9lection=20du=20plugin,=20et=20r=C3=A9cep?=
 =?UTF-8?q?tion=20des=20donn=C3=A9es.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/playbot.rb | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/lib/playbot.rb b/lib/playbot.rb
index 53b9411..e67661a 100644
--- a/lib/playbot.rb
+++ b/lib/playbot.rb
@@ -1,13 +1,19 @@
+require 'uri'
+
 require 'rubygems'
 require 'net/yail/irc_bot'
 
-require 'site_plugin'
+require_relative 'site_plugin.rb'
+
+
+# --
+# Changing working directory so the inclusion of plugin can be done correctly.
+# I don't complety know why, but this is necessary.
+Dir.chdir(File.expand_path File.dirname(__FILE__))
 
 # --
 # Add plugins folder to LOAD_PATH and subsequently require all plugins.
-dir = '../plugins'
-$LOAD_PATH << dir
-Dir[File.join(dir, '*.rb')].each {|file| require File.basename(file) }
+Dir[File.join('../plugins', '*.rb')].each { |file| require_relative file }
 
 class PlayBot < IRCBot
 	BOTNAME = 'PlayBot'
@@ -65,5 +71,16 @@ class PlayBot < IRCBot
     def _in_msg(event)
         # we don't care of private messages
         return if event.pm?
+
+        url = URI.extract(event.message, ['http', 'https']).first
+        puts "url = #{url}"
+        
+        handler = SitePlugin.for_site(url)
+        return if handler.nil?
+
+        handler = handler.new
+        content = handler.get(url)
+
+        #TODO: use this content...
     end
 end
-- 
GitLab