Sha256: 232120495f7698a7b6ed9937e49a4b31956c74eefa69770bae72f5eaa9edfa50

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# vendor gems
require 'cinch'
require 'httparty'
require 'rainbow'

# custom classes
require 'hibot/helpers/configuration'
require 'api/spotify'
require 'api/giphy'
require 'hibot/plugins/spotify'
require 'hibot/plugins/giphy'


module Hibot
  extend Configuration
  def self.launch(opts)
    # Read the config file and get all the settings in the config hash
    config = self.configure(opts)
    bot = Cinch::Bot.new do
      configure do |c|
        # General bot settings such server, channels etc
        config[:general].each {|opt, value|
          c.send("#{opt}=".to_sym, value)  
        }

        # Load plugins
        c.plugins.plugins = []
        config[:general]['plugins.plugins'.to_sym].each do |plugin|
          c.plugins.plugins << Object.const_get(plugin)
        end
      end
    end

    # Loop to configure each activated plugins
    config[:general]['plugins.plugins'.to_sym].each do |plugin|
      # Format the plugin name to call the appropriate configure method
      plugin_name = plugin.split('::').join('_').downcase
      self.send("configure_#{plugin_name}", config[plugin.to_sym])
    end

    bot.start
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hibot-0.0.2 lib/hibot.rb