Class: Lita::Handlers::Netping
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Netping
- Defined in:
- lib/lita/handlers/netping.rb
Instance Method Summary collapse
Instance Method Details
#ping(response) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/lita/handlers/netping.rb', line 13 def ping(response) proto = response.match_data['proto'] || 'icmp' target = response.match_data['target'] # Update the protocol based on the target proto = URI(target).scheme if target =~ %r{^(\S+)://\S+} if valid_protocol?(proto) response.reply(format(target, ping_target(proto.downcase, target))) else response.reply(t('ping.unsupported', proto: proto)) end end |