Skip to content
Snippets Groups Projects
Commit 1774b9de authored by Matheus Faria's avatar Matheus Faria
Browse files

Removing config file path from global scope

parent e6f3c6ef
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ FROM node:alpine
LABEL mantainer "Diego Dorgam <diego.dorgam@rocket.chat>"
ENV HUBOT_LANG='en' \
HUBOT_CORPUS='corpus.yml' \
HUBOT_CORPUS='training_data/corpus.yml' \
HUBOT_ADAPTER=rocketchat \
HUBOT_OWNER=RocketChat \
HUBOT_NAME=HubotNatural \
......
......@@ -50,7 +50,7 @@ services:
- HUBOT_OWNER=RocketChat
- HUBOT_DESCRIPTION='Hubot natural language processing'
- HUBOT_LOG_LEVEL=debug
- HUBOT_CORPUS=corpus.yml
- HUBOT_CORPUS=training_data/corpus.yml
- HUBOT_LANG=pt
- RESPOND_TO_DM=true
- RESPOND_TO_LIVECHAT=true
......
......@@ -135,9 +135,8 @@ clearErrors = (res) ->
key = 'errors_'+res.envelope.room+'_'+res.envelope.user.id
res.robot.brain.set(key, 0)
module.exports = (_config, _configPath, robot) ->
module.exports = (_config, robot) ->
global.config = _config
global.configPath = _configPath
global.usersAndRoles = getUserRoles(robot)
......
path = require 'path'
natural = require 'natural'
{msgVariables, stringElseRandomKey, loadConfigfile} = require path.join '..', 'lib', 'common.coffee'
{msgVariables, stringElseRandomKey, loadConfigfile, getConfigFilePath} = require '../lib/common'
{checkRole} = require path.join '..', 'lib', 'security.coffee'
answers = {}
# usersAndRoles = getUserRoles()
class configure
constructor: (@interaction) ->
......@@ -40,7 +39,7 @@ class configure
retrain: (msg) ->
console.log 'inside retrain'
scriptPath = path.join __dirname, '..'
global.config = loadConfigfile(global.configPath)
global.config = loadConfigfile getConfigFilePath()
global.train()
type = @interaction.type?.toLowerCase() or 'random'
......
path = require 'path'
require 'coffeescript/register'
{loadConfigfile} = require path.join path.join __dirname, 'lib', 'common.coffee'
chatbot = require path.join __dirname, 'bot', 'index.coffee'
path = require 'path'
fs = require 'fs'
hubotPath = module.parent.filename
hubotPath = path.dirname hubotPath for [1..4]
corpus = (process.env.HUBOT_CORPUS || 'corpus.yml')
global.configPath = path.join hubotPath, 'training_data', corpus
{loadConfigfile, getConfigFilePath} = require './lib/common'
chatbot = require './bot/index'
try
global.config = loadConfigfile global.configPath
global.config = loadConfigfile getConfigFilePath()
catch err
process.exit()
chatbot = chatbot.bind null, global.config, global.configPath
chatbot = chatbot.bind null, global.config
module.exports = chatbot
......@@ -24,6 +24,9 @@ common.regexEscape = (string) ->
#http://stackoverflow.com/a/6969486
string.replace /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"
common.getConfigFilePath = () ->
return process.env.HUBOT_CORPUS || 'training_data/corpus.yml'
common.loadConfigfile = (filepath) ->
try
console.log("Loading corpus: " + filepath)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment