jenkins-bot has submitted this change and it was merged. Change subject: In command handling section, use 4-space indentation (like the rest of the code) and rename variables ......................................................................
In command handling section, use 4-space indentation (like the rest of the code) and rename variables Change-Id: I5e465147b825179e09ae9783f3cd139621545e1c --- M src/relay.js 1 file changed, 49 insertions(+), 53 deletions(-) Approvals: Paladox: Looks good to me, approved jenkins-bot: Verified diff --git a/src/relay.js b/src/relay.js index 8f40d87..2c51552 100644 --- a/src/relay.js +++ b/src/relay.js @@ -170,79 +170,75 @@ var whitelist_cloaks = /^((mediawiki|wikimedia|wikipedia|wiktionary|wikiquote|wikisource|wikispecies|wikibooks|wikinews|wikiversity|wikivoyage|wikidata|wikimedia-commons)\/|fsf\/member\/marktraceur$)/g; ircClient.whois(from, function(info){ - try { + try { + var command_restart = text.indexOf(ircClient.nick + ': ' + 'restart') === 0; + var command_force_restart = text.indexOf(ircClient.nick + ': ' + 'force-restart') === 0; + var command_nick = text.indexOf(ircClient.nick + ': ' + 'nick') === 0; + var from_trusted = info.host ? info.host.match(whitelist_cloaks) : false; + var using_intended_nick = config.nick.indexOf(ircClient.nick) === 0; - var $irc_nick_restart = text.indexOf(ircClient.nick + ': ' + 'restart') === 0; - var $irc_nick_force_restart = text.indexOf(ircClient.nick + ': ' + 'force-restart') === 0; - var $irc_nick_nick = text.indexOf(ircClient.nick + ': ' + 'nick') === 0; - var $irc_nick_help = text.indexOf(ircClient.nick + ': ' + 'help') === 0; - var $irc_nick1; - var $irc_nick2 = config.nick.indexOf(ircClient.nick) >= 0; + if (command_restart && from_trusted) { + console.log(from + ' => ' + to + ' ' + text); - $irc_nick1 = info.host ? info.host.match(whitelist_cloaks) : false; + logging.info('re-connecting to gerrit..'); - if ($irc_nick_restart && $irc_nick1) { - console.log(from + ' => ' + to + ' ' + text); + ircClient.say(to, "re-connecting to gerrit"); - logging.info('re-connecting to gerrit..'); + if (sshConn) { + sshConn.end(); + } - ircClient.say(to, "re-connecting to gerrit"); - - if (sshConn) { - sshConn.end(); + ircClient.say(to, "reconnected to gerrit"); + } else if (command_restart && !from_trusted) { + ircClient.say(to, "Permission is denied."); } - ircClient.say(to, "reconnected to gerrit"); - } else if ($irc_nick_restart && !$irc_nick1) { - ircClient.say(to, "Permission is denied."); - } + if (command_force_restart && from_trusted) { + console.log(from + ' => ' + to + ' ' + text); - if ($irc_nick_force_restart && $irc_nick1) { - console.log(from + ' => ' + to + ' ' + text); + ircClient.say(to, "re-connecting to gerrit and irc."); - ircClient.say(to, "re-connecting to gerrit and irc."); + logging.info('Disconnecting from irc.'); - logging.info('Disconnecting from irc.'); + ircClient.send('QUIT', "quit"); - ircClient.send('QUIT', "quit"); + logging.info('re-connecting to gerrit..'); - logging.info('re-connecting to gerrit..'); + if (sshConn) { + sshConn.end(); + } - if (sshConn) { - sshConn.end(); + logging.info('re-connected to gerrit.'); + + setTimeout(function(){ ircClient.say(to, "re-connected to gerrit and irc."); }, 17000); + + logging.info('re-connected to irc.'); + } else if (command_force_restart && !from_trusted) { + ircClient.say(to, "Permission is denied."); } - logging.info('re-connected to gerrit.'); + if (command_nick && from_trusted && using_intended_nick) { + console.log(from + ' => ' + to + ' ' + text); - setTimeout(function(){ ircClient.say(to, "re-connected to gerrit and irc."); }, 17000); + ircClient.say(to, "Nick is already " + ircClient.nick + " not changing the nick."); + } else if (command_nick && from_trusted) { + console.log(from + ' => ' + to + ' ' + text); - logging.info('re-connected to irc.'); - } else if ($irc_nick_force_restart && !$irc_nick1) { - ircClient.say(to, "Permission is denied."); - } + logging.info('Changing nick'); - if ($irc_nick_nick && $irc_nick1 && $irc_nick2) { - console.log(from + ' => ' + to + ' ' + text); + ircClient.send('NICK', config.nick); - ircClient.say(to, "Nick is already " + ircClient.nick + " not changing the nick."); - } else if ($irc_nick_nick && $irc_nick1) { - console.log(from + ' => ' + to + ' ' + text); - - logging.info('Changing nick'); - - ircClient.send('NICK', config.nick); - - if (ircClient.pass) { - ircClient.pass(config.password); + if (ircClient.pass) { + ircClient.pass(config.password); + } + logging.info('changed nick to' + ' ' + config.nick); + } else if (command_nick && !from_trusted) { + ircClient.say(to, "Permission is denied."); } - logging.info('changed nick to' + ' ' + config.nick); - } else if ($irc_nick_nick && !$irc_nick1) { - ircClient.say(to, "Permission is denied."); - } - if ($irc_nick_help) { - ircClient.say(to, "My current commands are: " + ircClient.nick + ": restart" + ", " + ircClient.nick + ": force-restart" + ", " + " and " + ircClient.nick + ": nick"); - } - } catch (err) {} + if (text.indexOf(ircClient.nick + ': ' + 'help') === 0) { + ircClient.say(to, "My current commands are: " + ircClient.nick + ": restart" + ", " + ircClient.nick + ": force-restart" + ", " + " and " + ircClient.nick + ": nick"); + } + } catch (err) {} }); }); -- To view, visit https://gerrit.wikimedia.org/r/321336 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5e465147b825179e09ae9783f3cd139621545e1c Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/grrrit Gerrit-Branch: master Gerrit-Owner: Alex Monk <a...@wikimedia.org> Gerrit-Reviewer: Alex Monk <a...@wikimedia.org> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits