Skip to content

Instantly share code, notes, and snippets.

@TvL2386
Created April 1, 2011 07:41
Show Gist options
  • Save TvL2386/897859 to your computer and use it in GitHub Desktop.
Save TvL2386/897859 to your computer and use it in GitHub Desktop.
respond_to_command method
def respond_to_command data
if data =~ /^([^\s]+):\s(?:[^\s]+):\s([^\s]+):\s(.*)$/
sender = $1
command = $3.rstrip
# directed to me?
return nil if not $2.split(',').include?(@my_name)
# if I'm still here, I guess so ;-)
# lets see if uptime is in the allowed commands array
return nil unless ['uptime'].include?(command)
# if I'm still here, I guess so ;-)
yield(sender, command)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment