Skip to content

Instantly share code, notes, and snippets.

@robotlolita

robotlolita/.js Secret

Created September 12, 2015 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/690c420df5a455831386 to your computer and use it in GitHub Desktop.
Save robotlolita/690c420df5a455831386 to your computer and use it in GitHub Desktop.
var commands = {
"foo": function(){ .. },
"bar": function(){ .. },
"baz": function(){ .. }
}
function toCommand(message) {
if (message.indexOf("/foo") != -1) {
return "foo"
}
else if (someCommand.test(message)) {
return "bar"
}
else {
return "baz"
}
}
commands[toCommand(message)]()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment