Created
April 1, 2011 07:41
-
-
Save TvL2386/897859 to your computer and use it in GitHub Desktop.
respond_to_command method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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