aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.rb12
-rw-r--r--dinobot.rb13
-rw-r--r--test.rb6
3 files changed, 20 insertions, 11 deletions
diff --git a/admin.rb b/admin.rb
index 61e454b..fceaa26 100644
--- a/admin.rb
+++ b/admin.rb
@@ -36,15 +36,15 @@ module Dinobot
end
def load(user, channel, argument)
- argument.split.map do |x|
- [:load_module, x.intern]
- end
+ return unless is_admin?(user)
+
+ argument.split.map { |x| [:load_module, x.intern] }
end
def unload(user, channel, argument)
- argument.split.map do |x|
- [:unload_module, x.intern]
- end
+ return unless is_admin?(user)
+
+ argument.split.map { |x| [:unload_module, x.intern] }
end
end
end
diff --git a/dinobot.rb b/dinobot.rb
index 052bb10..68c901a 100644
--- a/dinobot.rb
+++ b/dinobot.rb
@@ -1,4 +1,5 @@
require 'socket'
+require 'timeout'
module Dinobot
class Bot
@@ -44,10 +45,14 @@ module Dinobot
str.chomp!
puts "<< #{str.inspect}"
- begin
- parse_line(str)
- rescue => e
- puts "!! Error parsing line. (#{e})"
+ Thread.new do
+ begin
+ Timeout.timeout(30) do
+ parse_line(str)
+ end
+ rescue => e
+ puts "!! Error parsing line. (#{e})"
+ end
end
end
diff --git a/test.rb b/test.rb
index f2010a0..bc9db29 100644
--- a/test.rb
+++ b/test.rb
@@ -5,7 +5,7 @@ module Dinobot
def initialize
super
- @commands << :echo << :error
+ @commands << :echo << :error << :timeout
end
def echo(user, channel, argument)
@@ -15,5 +15,9 @@ module Dinobot
def error(user, channel, argument)
x
end
+
+ def timeout(user, channel, argument)
+ sleep 60
+ end
end
end