2013-05-29 14:46:16 +00:00
|
|
|
#!env ruby
|
2013-06-09 14:44:28 +00:00
|
|
|
# encoding: utf-8
|
2013-05-29 14:46:16 +00:00
|
|
|
|
|
|
|
require 'rubygems'
|
|
|
|
require 'eventmachine'
|
|
|
|
require 'em-irc'
|
2013-05-30 06:38:37 +00:00
|
|
|
# Our config file is just a single Hash, nothing too fancy.
|
2013-05-29 18:55:52 +00:00
|
|
|
require_relative 'config'
|
|
|
|
require_relative 'repost'
|
2013-05-29 14:46:16 +00:00
|
|
|
|
2013-06-04 19:30:57 +00:00
|
|
|
# Will have to change it to a normal EM loop if/when i'll want to make a usable
|
|
|
|
# local console for the bot.
|
2013-06-04 21:19:06 +00:00
|
|
|
Client = Repost.new do
|
2013-05-29 14:46:16 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2013-05-30 06:38:37 +00:00
|
|
|
# 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.
|
2013-05-29 14:46:16 +00:00
|
|
|
on :raw do |message|
|
|
|
|
self.dispatch_raw_message message
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-06-04 21:19:06 +00:00
|
|
|
# Loading plugins here, because we need the Client object in scope to be able
|
2013-05-30 06:38:37 +00:00
|
|
|
# to do anything.
|
2013-06-09 16:21:55 +00:00
|
|
|
Client.load_plugins
|
2013-05-29 14:46:16 +00:00
|
|
|
|
2013-06-04 21:19:06 +00:00
|
|
|
Client.run!
|