forked from FabricLabs/doorman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
General refactor, new
Service
API, general messaging
- Loading branch information
1 parent
20ec468
commit ad90f22
Showing
18 changed files
with
437 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,11 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const chalk = require('chalk'); | ||
const config = require('./config'); | ||
const Doorman = require('./lib/doorman'); | ||
|
||
console.log(chalk.green(`Starting Doorman...`)); | ||
console.log(chalk.green(`Node version: ${process.version}`)); | ||
function main () { | ||
let doorman = new Doorman(config); | ||
doorman.start(); | ||
} | ||
|
||
// Helpers | ||
exports.require = function (filePath) { | ||
delete require.cache[path.join(path.dirname(require.main.filename), filePath)]; | ||
return require(path.join(path.dirname(require.main.filename), filePath))(this); | ||
}; | ||
|
||
exports.getFileContents = function (filePath) { | ||
try { | ||
return fs.readFileSync(path.join(path.dirname(require.main.filename), filePath), 'utf-8'); | ||
} catch (err) { | ||
return ''; | ||
} | ||
}; | ||
|
||
exports.getFileArray = function (srcPath) { | ||
try { | ||
srcPath = path.join(path.dirname(require.main.filename), srcPath); | ||
return fs.readdirSync(srcPath).filter(file => fs.statSync(path.join(srcPath, file)).isFile()); | ||
} catch (err) { | ||
return []; | ||
} | ||
}; | ||
|
||
exports.getJsonObject = function (filePath) { | ||
return JSON.parse(exports.getFileContents(filePath)); | ||
}; | ||
|
||
exports.resolveMention = function (usertxt) { | ||
let userid = usertxt; | ||
if (usertxt.startsWith('<@!')) { | ||
userid = usertxt.substr(3, usertxt.length - 4); | ||
} else if (usertxt.startsWith('<@')) { | ||
userid = usertxt.substr(2, usertxt.length - 3); | ||
} | ||
return userid; | ||
}; | ||
|
||
exports.config = require('./config'); | ||
exports.auth = require('./config/auth'); | ||
|
||
// Now for the good stuff! | ||
require('./lib/maki')(this); | ||
require('./lib/doorman')(this); | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
|
||
function Disk () { | ||
this.type = 'Disk'; | ||
} | ||
|
||
Disk.prototype.exists = function (path) { | ||
return fs.existsSync(path); | ||
}; | ||
|
||
module.exports = Disk; |
Oops, something went wrong.