]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/iplookup.rb
hangman plugin: rudimentary stats tracking along with some other enhancements
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / iplookup.rb
index 87c94699fa9c9d3f42ab1ae21f712a35bd4c6140..495aa614f61f5657e2be379c0eeec159f04248b9 100644 (file)
@@ -189,23 +189,25 @@ class IPLookupPlugin < Plugin
 
   def iplookup(m, params)
     reply = ""
-    if params[:domain]
+    if params[:domain].match(/^#{Regexp::Irc::HOSTADDR}$/)
+      ip = params[:domain]
+    else
       begin
         ip = Resolv.getaddress(params[:domain])
-        reply += "#{params[:domain]} | "
+        reply << "#{params[:domain]} | "
       rescue => e
         m.reply "#{e.message}"
         return
       end
-    else
-      ip = params[:ip]
     end
 
-    reply += ArinWhois.lookup_info(ip)
+    reply << ArinWhois.lookup_info(ip)
+
     m.reply reply
   end
 
   def userip(m, params)
+    m.reply "not implemented yet"
     #users = @channels[m.channel].users
     #m.reply "users = #{users.inspect}"
     #m.reply @bot.sendq("WHO #{params[:user]}")
@@ -214,8 +216,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