Skip to content

Instantly share code, notes, and snippets.

@65Mustang289
Created July 29, 2021 13:53
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 65Mustang289/0e1330c52591e39839764b5dca1aca32 to your computer and use it in GitHub Desktop.
Save 65Mustang289/0e1330c52591e39839764b5dca1aca32 to your computer and use it in GitHub Desktop.
Add the following (after line 19) in scripts/sample.js
robot.respond(/get user details for @(.+)/i, async function(res) {
var sampleFunctions = require('./sampleFunctions.js');
var userToSearch = res.match[1];
var searchResult;
try{
searchResult = await sampleFunctions.searchApi(userToSearch);
}
catch(error){
res.reply("Error:" + error);
}
if(searchResult.length == 0){
res.reply("No user details found for @" +userToSearch);
return;
}
res.reply("First: " + searchResult[0].first + "\nLast: " + searchResult[0].last + "\nEmail: " + searchResult[0].email);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment