-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Changed arrow func to function for logging. Now using regex for nickserv success message tests.
- Loading branch information
1 parent
3117144
commit 5a84066
Showing
2 changed files
with
44 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"password" : "dicks" | ||
"nickserv": "nickserv", | ||
"password" : "dicks", | ||
"successtext": "^You are now identified for " | ||
} |
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,31 +1,48 @@ | ||
var config = null; | ||
var bot = null; | ||
let config = null; | ||
let bot = null; | ||
let log = null; | ||
|
||
module.exports.init = function(b) { | ||
bot = b; | ||
// Only respond to a nickserv notice once. | ||
let identified = false; | ||
|
||
bot.getConfig('nickserv.json', function(err, conf) { | ||
console.log(err); | ||
if(err) return; | ||
module.exports.init = function (b) { | ||
bot = b; | ||
log = this.log; | ||
|
||
config = conf; | ||
bot.getConfig('nickserv.json', (err, conf) => { | ||
if (err) { | ||
log.error(err); | ||
return; | ||
} | ||
|
||
bot.sayTo(config.nickserv || 'nickserv', 'identify', bot.client.nick, config.password); | ||
}); | ||
} | ||
config = conf; | ||
|
||
module.exports.run_register = function(r, parts, reply) { | ||
console.log(config); | ||
if(config === null) { | ||
reply("Please configure a password"); | ||
return; | ||
} | ||
bot.sayTo(config.nickserv || 'nickserv', 'identify', bot.client.nick, config.password); | ||
}); | ||
}; | ||
|
||
if(parts.length < 1) { | ||
reply("Usage: !register <email address>"); | ||
return; | ||
} | ||
module.exports.pmnotice = (text, from) => { | ||
const nickServText = config.nickservsuccess || '^You are now identified for '; | ||
|
||
bot.sayTo(config.nickserv || 'nickserv', 'register', config.password, parts[0]); | ||
reply("Registered!"); | ||
} | ||
if (!identified && from.toLowerCase() === (config.nickserv || 'nickserv') | ||
&& new RegExp(nickServText, 'i').test(text)) { | ||
bot.joinChannels(); | ||
identified = true; | ||
log.info('Identified with nickserv, rejoining channels.'); | ||
} | ||
}; | ||
|
||
module.exports.run_register = (r, parts, reply) => { | ||
if (config === null) { | ||
reply('Please configure a password'); | ||
return; | ||
} | ||
|
||
if (parts.length < 1) { | ||
reply('Usage: !register <email address>'); | ||
return; | ||
} | ||
|
||
bot.sayTo(config.nickserv || 'nickserv', 'register', config.password, parts[0]); | ||
reply('Registered!'); | ||
}; |