diff --git a/spec/chatbot-spec.js b/spec/chatbot-spec.js new file mode 100644 index 0000000..08cbb5a --- /dev/null +++ b/spec/chatbot-spec.js @@ -0,0 +1,12 @@ +const utils = require('../src/utils'); + +describe('Chatbot Actions', () => { + it('show use exec function properly', (done) => { + utils.exec('echo ping').then((result) => { + expect(result).toBe('ping\n'); + done(); + }).catch(() => { + done.fail('Exec failed.'); + }); + }); +}); diff --git a/src/behaviors/heat.js b/src/behaviors/heat.js new file mode 100644 index 0000000..a48d794 --- /dev/null +++ b/src/behaviors/heat.js @@ -0,0 +1,8 @@ +const Behavior = require('../models/behavior'); +const utils = require('../utils'); + +let heatAction = () => { + return utils.exec('hddtemp /dev/sd?'); +}; + +module.exports = new Behavior('message', heatAction, 'heat'); diff --git a/src/bot.js b/src/bot.js index 39d1697..cb5fdb4 100644 --- a/src/bot.js +++ b/src/bot.js @@ -10,6 +10,7 @@ const state = { const greetBehavior = require('./behaviors/greet'); const helpBehavior = require('./behaviors/help').helpBehavior; const ftoBehavior = require('./behaviors/fto')(state); +const heatBehavior = require('./behaviors/heat'); // Read file synchronously because we'd need this object in later steps anyway. const config = JSON.parse(fs.readFileSync('config.json', 'utf8')); @@ -31,7 +32,8 @@ const joinBehaviors = [ const messageBehaviors = [ helpBehavior, - ftoBehavior + ftoBehavior, + heatBehavior ]; const behaviors = new Behaviors(config.name, client, joinBehaviors, messageBehaviors);