Class: SmfBot
- Inherits:
-
Object
- Object
- SmfBot
- Defined in:
- lib/smfbot.rb
Instance Method Summary collapse
- #add_plugin(plugin, options = nil) ⇒ Object
-
#initialize(params) ⇒ SmfBot
constructor
A new instance of SmfBot.
- #start ⇒ Object
Constructor Details
#initialize(params) ⇒ SmfBot
Returns a new instance of SmfBot.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/smfbot.rb', line 5 def initialize(params) if File.exist?('config.yaml') settings = YAML.load_file('config.yaml')||{} else raise "\n\n Missing configuration file 'config.yaml'.\n\n" end @bot = Cinch::Bot.new do debug "settings <<-EOF\n#{settings.to_yaml}EOF" configure do |c| c.server = settings['server'] c.port = settings['port'] c.channels = settings['channels'] c.nick = settings['nick'] c.username = settings['nick'] c.plugins.plugins = [] end end (settings['plugins'] || []).each{ |plugin, | add_plugin(plugin, ) } end |
Instance Method Details
#add_plugin(plugin, options = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/smfbot.rb', line 25 def add_plugin(plugin, = nil) @bot.info "loading plugin: #{plugin}." @bot.configure do |c| require plugin.downcase.gsub('::','/') plugin = eval plugin c.plugins.plugins << plugin c.plugins.[plugin] = if end rescue @bot.warn "failed loading plugin: #{plugin} ->\n#{}" end |
#start ⇒ Object
37 38 39 |
# File 'lib/smfbot.rb', line 37 def start @bot.start end |