From f2cf9388b9e8b6c7071efad81d0fac446aa0d60a Mon Sep 17 00:00:00 2001 From: "Robert \"ar\" Gerus" Date: Tue, 4 Jun 2013 23:19:06 +0200 Subject: [PATCH] Got rid of the eval(), finally. I felt bad every time i looked at it --- plugins/commands.rb | 4 ++-- plugins/mikrofalowka.rb | 4 ++-- plugins/pretty_print.rb | 2 +- run.rb | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/commands.rb b/plugins/commands.rb index 9cf8961..4283b06 100644 --- a/plugins/commands.rb +++ b/plugins/commands.rb @@ -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? } diff --git a/plugins/mikrofalowka.rb b/plugins/mikrofalowka.rb index 1ff5192..02377ad 100644 --- a/plugins/mikrofalowka.rb +++ b/plugins/mikrofalowka.rb @@ -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]/ } diff --git a/plugins/pretty_print.rb b/plugins/pretty_print.rb index 36087c0..fbd6891 100644 --- a/plugins/pretty_print.rb +++ b/plugins/pretty_print.rb @@ -1,5 +1,5 @@ include EventMachine::IRC::Commands -repost.register_trigger("PRIVMSG") { |msg| +Client.register_trigger("PRIVMSG") { |msg| p msg } diff --git a/run.rb b/run.rb index d2d7f75..68f4ee8 100755 --- a/run.rb +++ b/run.rb @@ -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!