Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed May 29, 2017
1 parent 3a67bf9 commit eecabcc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
31 changes: 13 additions & 18 deletions packages/rocketchat-internal-hubot/hubot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable no-use-before-define no-unused-vars */
/* globals __meteor_bootstrap__ */
const CoffeeScript = Npm.require('coffee-script');
CoffeeScript.register();
const Hubot = Npm.require('hubot');
// Start a hubot, connected to our chat room.
// 'use strict'

// Log messages?
const DEBUG = false;

Expand Down Expand Up @@ -167,21 +165,19 @@ class RocketChatAdapter extends Hubot.Adapter {
}
}

class InternalHubotReceiver {
constructor(message) {
if (DEBUG) { console.log(message); }
if (message.u.username !== InternalHubot.name) {
const room = RocketChat.models.Rooms.findOneById(message.rid);
const InternalHubotReceiver = (message) => {
if (DEBUG) { console.log(message); }
if (message.u.username !== InternalHubot.name) {
const room = RocketChat.models.Rooms.findOneById(message.rid);

if (room.t === 'c') {
const InternalHubotUser = new Hubot.User(message.u.username, {room: message.rid});
const InternalHubotTextMessage = new Hubot.TextMessage(InternalHubotUser, message.msg, message._id);
InternalHubot.adapter.receive(InternalHubotTextMessage);
}
if (room.t === 'c') {
const InternalHubotUser = new Hubot.User(message.u.username, {room: message.rid});
const InternalHubotTextMessage = new Hubot.TextMessage(InternalHubotUser, message.msg, message._id);
InternalHubot.adapter.receive(InternalHubotTextMessage);
}
return message;
}
}
return message;
};

class HubotScripts {
constructor(robot) {
Expand All @@ -197,13 +193,12 @@ class HubotScripts {
scriptsToLoad.forEach(scriptFile => {
try {
scriptFile = s.trim(scriptFile);
// Npm.require('hubot-scripts/src/scripts/'+scriptFile)(robot)
// delete require.cache[require.resolve(path+scriptFile)];
const fn = Npm.require(path+scriptFile);

if (typeof(fn) === 'function') { fn(robot); } else { fn.default(robot); }
// robot.loadFile __meteor_bootstrap__.serverDir+'/npm/node_modules/meteor/rocketchat_internal-hubot/node_modules/hubot-scripts/src/scripts', scriptFile
robot.parseHelp(path+scriptFile);
console.log(`Loaded ${ scriptFile }`.green);
console.log(Npm.resolve(path+scriptFile));
} catch (e) {
console.log(`can't load ${ scriptFile }`.red);
console.log(e);
Expand Down Expand Up @@ -237,6 +232,6 @@ Meteor.startup(function() {
userId(/*userId*/) { return true; }
});
Meteor.methods({
reloadInternalHubot: init
reloadInternalHubot: () => init()
});
});
10 changes: 5 additions & 5 deletions packages/rocketchat-internal-hubot/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ RocketChat.settings.add('InternalHubot_Username', 'rocket.cat', { type: 'string'
// RocketChat.settings.add('InternalHubot_ScriptsToLoad', 'hello.coffee,zen.coffee', { type: 'string', group: 'InternalHubot'});
RocketChat.settings.add('InternalHubot_ScriptsToLoad', '', { type: 'string', group: 'InternalHubot'});
RocketChat.settings.add('InternalHubot_PathToLoadCustomScripts', '', { type: 'string', group: 'InternalHubot'});
RocketChat.settings.add('InternalHubot_reload', 'reloadInternalHubot', {
type: 'action',
group: 'InternalHubot',
actionText: 'reload'
});
// RocketChat.settings.add('InternalHubot_reload', 'reloadInternalHubot', {
// type: 'action',
// group: 'InternalHubot',
// actionText: 'reload'
// });

0 comments on commit eecabcc

Please sign in to comment.