-
-
Save 65Mustang289/0e1330c52591e39839764b5dca1aca32 to your computer and use it in GitHub Desktop.
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
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