Got rid of the eval(), finally. I felt bad every time i looked at it

master
Robert "ar" Gerus 2013-06-04 23:19:06 +02:00
parent 01d8a64ebb
commit f2cf9388b9
4 changed files with 9 additions and 9 deletions

View File

@ -1,6 +1,6 @@
include EventMachine::IRC::Commands
repost.register_trigger("PRIVMSG") { |msg|
Client.register_trigger("PRIVMSG") { |msg|
src_nick = msg[:prefix].split('!').first
message = msg[:params][1]
@ -22,6 +22,6 @@ repost.register_trigger("PRIVMSG") { |msg|
end
end
repost.privmsg(target, "#{reply_prefix}command: #{command} arguments: #{arguments.join(' ')}")
Client.privmsg(target, "#{reply_prefix}command: #{command} arguments: #{arguments.join(' ')}") if not command.nil?
}

View File

@ -1,7 +1,7 @@
include EventMachine::IRC::Commands
repost.register_trigger("PRIVMSG") { |msg|
Client.register_trigger("PRIVMSG") { |msg|
nick = msg[:prefix].split('!').first
destination = msg[:params][0]
repost.privmsg(destination, "#{nick}: napraw mikrofalowke") if nick.match /[Bb].[Rr][Tt]/
Client.privmsg(destination, "#{nick}: napraw mikrofalowke") if nick.match /[Bb].[Rr][Tt]/
}

View File

@ -1,5 +1,5 @@
include EventMachine::IRC::Commands
repost.register_trigger("PRIVMSG") { |msg|
Client.register_trigger("PRIVMSG") { |msg|
p msg
}

8
run.rb
View File

@ -9,7 +9,7 @@ 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
Client = Repost.new do
host Config[:server][:host]
port Config[:server][:port]
@ -36,11 +36,11 @@ repost = Repost.new do
end
# Loading plugins here, because we need the repost object in scope to be able
# Loading plugins here, because we need the Client 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")
load File.dirname($0) + '/plugins/' + plugin + '.rb'
end if not Config[:plugins].nil?
repost.run!
Client.run!