Sha256: 6d72822c1043098d007b40fe3db00b41564258f1e0cfe6d543eb6cccf09a4d2b

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 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
      
      on :connect do |m|
        User('nickserv').send("IDENTIFY #{config[:general][:nick]} #{config[:general][:pass]}")
      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.4 lib/hibot.rb