Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #28 from dungdung/sentry-detection-cleanup
Browse files Browse the repository at this point in the history
Cleaned up sentry file detection code
  • Loading branch information
dungdung committed Mar 31, 2015
2 parents 4eacdec + fe7ce31 commit 2254d2d
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions lib/chatBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,20 @@ var ChatBot = function(username, password, options) {
}
} else {
this.winston.info("Config file does not define a sentryfile. Attempting to autodetect sentry...");
if(fs.existsSync("sentry."+this.username+".hash")) {
this.sentryFile = "sentry."+this.username+".hash";
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("sentry."+this.username)) {
this.sentryFile = "sentry."+this.username;
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("sentryfile."+this.username)) {
this.sentryFile = "sentryfile."+this.username;
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("sentryfile."+this.username+".hash")) {
this.sentryFile = "sentryfile."+this.username+".hash";
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("bot."+this.username+".hash")) {
this.sentryFile = "bot."+this.username+".hash";
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("bot."+this.username+".sentry")) {
this.sentryFile = "bot."+this.username+".sentry";
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync(this.username+".hash")) {
this.sentryFile = this.username+".hash";
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync(this.username+".sentry")) {
this.sentryFile = this.username+".sentry";
var sentryFile = _.find([
"sentry."+this.username+".hash",
"sentry."+this.username,
"sentryfile."+this.username,
"sentryfile."+this.username+".hash",
"bot."+this.username+".hash",
"bot."+this.username+".sentry",
this.username+".hash",
this.username+".sentry"
], function(val) {
return fs.existsSync(val);
});
if ("undefined" !== typeof sentryFile) {
this.sentryFile = sentryFile;
this.winston.info("Sentry file "+this.sentryFile+" detected.");
} else if(fs.existsSync("sentry")) {
this.sentryFile = "sentry";
Expand Down

0 comments on commit 2254d2d

Please sign in to comment.