diff --git a/lib/playbot.rb b/lib/playbot.rb index 208b8df263929ca61ab0608d37ce45655195adc1..33a6ea66ab23db48850eb3f960b37b2ac9ca1337 100644 --- a/lib/playbot.rb +++ b/lib/playbot.rb @@ -78,7 +78,7 @@ class PlayBot < IRCBot handler = SitePlugin.for_site(url) return if handler.nil? - handler = handler.new + handler = handler.new(@options) content = handler.get(url) msg(event.channel, "#{content[:title]} | #{content[:author]}") diff --git a/plugins/youtube_plugin.rb b/plugins/youtube_plugin.rb index 6bc4710d24050a652538ca327d3fc56f0e6a239c..61aca788136363984e3331897c6ecbda853acfc7 100644 --- a/plugins/youtube_plugin.rb +++ b/plugins/youtube_plugin.rb @@ -1,6 +1,7 @@ require_relative '../lib/site_plugin.rb' require 'rubygems' +require 'bundler/setup' require 'youtube_it' # SitePlugin for YouTube @@ -10,7 +11,7 @@ class YoutubePlugin < SitePlugin end public - def initialize + def initialize(options) @client = YouTubeIt::Client.new end diff --git a/run.rb b/run.rb index 5f25d859322f9075ac94e3c1b4de8592c9b118c1..17adda0e386029d70ebe78198caeaa049707b038 100755 --- a/run.rb +++ b/run.rb @@ -2,6 +2,7 @@ require 'logger' require 'optparse' +require 'yaml' require_relative 'lib/playbot' @@ -9,6 +10,7 @@ require_relative 'lib/playbot' options = {} +# First we read options from command line. OptionParser.new do |opts| opts.banner = "Usage: ./run.rb [OPTIONS]" @@ -34,9 +36,14 @@ OptionParser.new do |opts| end end.parse! +# Next we look to an configuration file. +if File.exists?("#{ENV['HOME']}/.playbot") + YAML.load_file("#{ENV['HOME']}/.playbot").each do |k, v| + options[k.to_sym] = v unless options.has_key?(k) + end +end + options[:silent] ||= false -options[:admin] ||= 'moise' -options[:address] ||= 'irc.iiens.net' bot = PlayBot.new( :address => options[:address],