UNPKG

@wickr-sample-integrations/wickrio-lex-bot

Version:

Using the AWS SDK for JavaScript V3 to create a Lex chatbot within Wickr.

57 lines (45 loc) 1.33 kB
const WickrIOBotAPI = require('wickrio-bot-api') const {exec, execSync, execFileSync} = require('child_process'); require('dotenv').config({ path: '.env.configure', }) let wickrIOConfigure process.stdin.resume(); //so the program will not close instantly function exitHandler(options, err) { try { if (err) { process.kill(process.pid); process.exit(); } if (options.exit) { process.exit(); } else if (options.pid) { process.kill(process.pid); } } catch (err) { console.log(err); } } //catches ctrl+c and stop.sh events process.on('SIGINT', exitHandler.bind(null, {exit: true})); //catches "kill pid" (for example: nodemon restart) process.on('SIGUSR1', exitHandler.bind(null, {pid: true})); process.on('SIGUSR2', exitHandler.bind(null, {pid: true})); //catches uncaught exceptions process.on('uncaughtException', exitHandler.bind(null, { exit: true, reason: 'uncaughtException' })); main(); async function main() { const tokens = require('./configTokens.json') const fullName = process.cwd() + '/processes.json' wickrIOConfigure = new WickrIOBotAPI.WickrIOConfigure( tokens.tokens, fullName, tokens.supportAdministrators, tokens.supportVerification ) await wickrIOConfigure.configureYourBot(tokens.integration) process.exit() }