diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-09 23:13:50 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-09 23:16:15 +0200 |
commit | 29397fb64d302d9dac81521c24e934e588d61ee8 (patch) | |
tree | bc3078a255640acab823ce9bf8216ea573d286dd /data/rbot/plugins | |
parent | b1155710d58091f8a3c5db6f764eeb6a6dd36b2a (diff) |
hl2 plugin: handle send errors as well
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/hl2.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/data/rbot/plugins/hl2.rb b/data/rbot/plugins/hl2.rb index 5023e01c..c11beee9 100644 --- a/data/rbot/plugins/hl2.rb +++ b/data/rbot/plugins/hl2.rb @@ -24,14 +24,15 @@ class HL2Plugin < Plugin def a2s_info(addr, port) socket = UDPSocket.new() - socket.send(A2S_INFO, 0, addr, port.to_i) - response = nil - begin + socket.send(A2S_INFO, 0, addr, port.to_i) + response = nil + timeout(TIMEOUT) do response = socket.recvfrom(1400,0) end - rescue Exception + rescue Exception => e + error e end socket.close() @@ -45,7 +46,7 @@ class HL2Plugin < Plugin def hl2(m, params) addr, port = params[:conn_str].split(':') info = a2s_info(addr, port) - if info != nil + if info m.reply "#{info[3]} is online with #{info[8]}/#{info[9]} players." else m.reply "Couldn't connect to #{params[:conn_str]}" |