From 4209fd9c41748c21d7a9ed85863e2fddbd122af1 Mon Sep 17 00:00:00 2001 From: Christopher Hambridge Date: Tue, 16 Aug 2016 10:21:30 -0400 Subject: [PATCH] Adding a simple hello script. Closes #12. (#13) --- scripts/hello.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/hello.js diff --git a/scripts/hello.js b/scripts/hello.js new file mode 100644 index 0000000..e84f7c5 --- /dev/null +++ b/scripts/hello.js @@ -0,0 +1,36 @@ +// Description: +// Say hi to your bot and have it greet you back +// +// Configuration: +// +// Commands: +// hubot hello - Greet your bot +// +// Author: +// chambrid +// +/* + * Licensed Materials - Property of IBM + * (C) Copyright IBM Corp. 2016. All Rights Reserved. + * US Government Users Restricted Rights - Use, duplication or + * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. + */ +'use strict'; + +const HI_REGEX = /(hi|hello|hey|hiya|sup|howdy|yo)/i; +const HI_ID = 'hubot.hi'; + +const path = require('path'); +const TAG = path.basename(__filename); + +const greetings = ['Hello', 'Hi', 'Hey', 'Hiya', 'Sup', 'Howdy', 'Yo']; + +module.exports = robot => { + + robot.respond(HI_REGEX, {id: HI_ID}, (res) => { + robot.logger.debug(`${TAG}: hubot-hi`); + let selection = Math.floor((Math.random() * 7)); + res.reply(greetings[selection]); + }); + +};