Class: RobutWhois::Plugin

Inherits:
Object
  • Object
show all
Includes:
Robut::Plugin
Defined in:
lib/robut_whois/plugin.rb

Instance Method Summary collapse

Instance Method Details

#handle(time, sender_nick, message) ⇒ Object

Responds with message if the command sent to robut is ‘echo’.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/robut_whois/plugin.rb', line 8

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

#usageObject

Returns a description of how to use this plugin



24
25
26
# File 'lib/robut_whois/plugin.rb', line 24

def usage
  "whois <domain> - Returns the WHOIS information for a domain"
end