repost/run.rb

47 lines
1.3 KiB
Ruby
Executable File

#!env ruby
require 'rubygems'
require 'eventmachine'
require 'em-irc'
# Our config file is just a single Hash, nothing too fancy.
require_relative 'config'
require_relative 'repost'
# Will have to change it to a normal EM loop if/when i'll want to make a usable
# local console for the bot.
repost = Repost.new do
host Config[:server][:host]
port Config[:server][:port]
on :connect do
puts "connected! changing nick to #{Config[:client][:nick]}"
nick Config[:client][:nick]
end
on :nick do
Config[:client][:channels].each do |channel|
puts "joining #{channel}"
join channel
end
end
# The provided triggers/callbacks for actions are limited - there are no
# quit/part callbacks, for example - and we'd have to catch raw messages
# anyway. And since we're doing that, we can just go ahead and hook up to
# raw callbacks exclusively.
on :raw do |message|
self.dispatch_raw_message message
end
end
# Loading plugins here, because we need the repost object in scope to be able
# to do anything.
Config[:plugins].each do |plugin|
puts "Loading plugin #{plugin}"
eval File.read(File.dirname($0) + "/plugins/#{plugin}.rb")
end if not Config[:plugins].nil?
repost.run!