Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made nickserv less async (fixes #95, part of #144). #172

Merged
merged 1 commit into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conf/nickserv.example.json
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 "
}
65 changes: 41 additions & 24 deletions modules/nickserv.js
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!');
};