summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/nslookup.rb
diff options
context:
space:
mode:
authorDmitry Kim <dmitry point kim at gmail point com>2007-09-11 17:37:26 +0000
committerDmitry Kim <dmitry point kim at gmail point com>2007-09-11 17:37:26 +0000
commita6738b25dbe4f8eee9223a60622abac5ac6108e5 (patch)
tree9e0129631b5455c4e9d0f41a4832794f9c595718 /data/rbot/plugins/nslookup.rb
parent38db12d7482f62275ecf9e67819ae148b3514f9a (diff)
+ (plugins) :thread option for plugin.map makes an action automatically threaded
* (plugins/*) converted to the new threading model
Diffstat (limited to 'data/rbot/plugins/nslookup.rb')
-rw-r--r--data/rbot/plugins/nslookup.rb34
1 files changed, 15 insertions, 19 deletions
diff --git a/data/rbot/plugins/nslookup.rb b/data/rbot/plugins/nslookup.rb
index 160fee85..0f901017 100644
--- a/data/rbot/plugins/nslookup.rb
+++ b/data/rbot/plugins/nslookup.rb
@@ -12,32 +12,28 @@ class DnsPlugin < Plugin
end
def name_to_ip(m, params)
- Thread.new do
- begin
- a = getaddresses(params[:host])
- if a.length > 0
- m.reply m.params + ": " + a.join(", ")
- else
- m.reply "#{params[:host]}: not found"
- end
- rescue StandardError => err
+ begin
+ a = getaddresses(params[:host])
+ if a.length > 0
+ m.reply m.params + ": " + a.join(", ")
+ else
m.reply "#{params[:host]}: not found"
end
+ rescue StandardError => err
+ m.reply "#{params[:host]}: not found"
end
end
def ip_to_name(m, params)
- Thread.new do
- begin
- a = gethostname(params[:ip])
- m.reply m.params + ": " + a if a
- rescue StandardError => err
- m.reply "#{params[:ip]}: not found (does not reverse resolve)"
- end
- end
+ begin
+ a = gethostname(params[:ip])
+ m.reply m.params + ": " + a if a
+ rescue StandardError => err
+ m.reply "#{params[:ip]}: not found (does not reverse resolve)"
+ end
end
end
plugin = DnsPlugin.new
-plugin.map 'dns :ip', :action => 'ip_to_name',
+plugin.map 'dns :ip', :action => 'ip_to_name', :thread => true,
:requirements => {:ip => /^\d+\.\d+\.\d+\.\d+$/}
-plugin.map 'dns :host', :action => 'name_to_ip'
+plugin.map 'dns :host', :action => 'name_to_ip', :thread => true