diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-08-03 10:03:36 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-08-03 10:05:33 +0200 |
commit | ff949fe1c9dd0c179ecdce9340c04c05242d3a48 (patch) | |
tree | 93beadde6ab06d8ddffe758e71f3d8f65a19dac9 /data/rbot | |
parent | a915f365139217ba985603181a7c7ceda3f1d9c6 (diff) |
iplookup plugin: support IPv6 too
This is achieved by moving the check for IP vs hostname in the
iplookup() method itself, and using the existing regexps to check if a
string is an IP or not.
Diffstat (limited to 'data/rbot')
-rw-r--r-- | data/rbot/plugins/iplookup.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/data/rbot/plugins/iplookup.rb b/data/rbot/plugins/iplookup.rb index 87c94699..a53b16e4 100644 --- a/data/rbot/plugins/iplookup.rb +++ b/data/rbot/plugins/iplookup.rb @@ -188,8 +188,10 @@ class IPLookupPlugin < Plugin end def iplookup(m, params) - reply = "" - if params[:domain] + debug params + if params[:domain].match(/^#{Regexp::Irc::HOSTADDR}$/) + ip = params[:domain] + else begin ip = Resolv.getaddress(params[:domain]) reply += "#{params[:domain]} | " @@ -197,8 +199,6 @@ class IPLookupPlugin < Plugin m.reply "#{e.message}" return end - else - ip = params[:ip] end reply += ArinWhois.lookup_info(ip) @@ -214,8 +214,7 @@ class IPLookupPlugin < Plugin end plugin = IPLookupPlugin.new -plugin.map 'iplookup :ip', :action => 'iplookup', :requirements => {:ip => /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/}, :thread => true -plugin.map 'iplookup :domain', :action => 'iplookup', :requirements => {:domain => /^[a-z0-9\.\-]{4,255}$/i}, :thread => true +plugin.map 'iplookup :domain', :action => 'iplookup', :thread => true plugin.map 'userip :user', :action => 'userip', :requirements => {:user => /\w+/}, :thread => true |