Sha256: ccd5a1b330748f7c91a6e3034034bfe804f312ad9d523252ac0edc21e2e56f0c

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require "whois"

module RobutWhois
  class Plugin
    include Robut::Plugin
    
    # Responds with +message+ if the command sent to robut is 'echo'.
    def handle(time, sender_nick, message)
      words = message.split
      message_type = words.first
      domain = words[1]
      if message_type == 'whois' && domain
        begin
          reply Whois.query(domain).to_s
        rescue Timeout::Error
          reply "Sorry #{sender_nick}, request timed out for #{domain}"
        rescue Whois::ServerNotFound
          reply "Sorry #{sender_nick}, Unable to find a WHOIS server for #{domain}"
        end
      end
    end

    # Returns a description of how to use this plugin
    def usage
      "whois <domain> - Returns the WHOIS information for a domain"
    end
      
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
robut_whois-0.0.2 lib/robut_whois/plugin.rb
robut_whois-0.0.1 lib/robut_whois/plugin.rb