Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic functionality for heat behavior #67

Merged
merged 2 commits into from
Aug 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions spec/chatbot-spec.js
Original file line number Diff line number Diff line change
@@ -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.');
});
});
});
8 changes: 8 additions & 0 deletions src/behaviors/heat.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 3 additions & 1 deletion src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -31,7 +32,8 @@ const joinBehaviors = [

const messageBehaviors = [
helpBehavior,
ftoBehavior
ftoBehavior,
heatBehavior
];

const behaviors = new Behaviors(config.name, client, joinBehaviors, messageBehaviors);
Expand Down