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

Handle commands in a better way #154

Merged
merged 2 commits into from Mar 11, 2016
Merged

Handle commands in a better way #154

merged 2 commits into from Mar 11, 2016

Conversation

xPaw
Copy link
Member

@xPaw xPaw commented Mar 6, 2016

  • Minor performance boost as commands stop processing as soon as one command is processed, msg as the first command, and any time you send a message, it won't try to execute any other command
  • Removed /ns, /cs, /hs aliases, handled properly by the server now, fixes Don't intercept /(c|h|n)s shortcut commands #153
  • All unknown commands are always sent to the server
  • Allows sending messages starting with / by escaping it as // (or more slashes)

@xPaw xPaw added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Mar 6, 2016
@xPaw xPaw changed the title Better commands Handle commands in a better way Mar 6, 2016
text = "/say " + text;
text = "say " + text;
} else {
text = text.replace(/^\//, "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you have used substr instead of a regex to strip the first char?

@dgw
Copy link
Contributor

dgw commented Mar 6, 2016

I know there was just a release yesterday, but I'm already excited for the next one because it'll let me use /znc commands (once this is merged…). 👍

@maxpoulin64
Copy link
Member

Looks good and works fine for me 👍 Pretty good way to fix it without a rewrite.

} catch (e) {
console.log(path + ": " + e);
}
});

if (result !== true) {
target.network.irc.write(text);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This is the magic sauce that will let things like /znc work! 🙌

@astorije
Copy link
Member

astorije commented Mar 7, 2016

Please hold on before merging, I'd like to take second review :-)
(Either tonight or tomorrow night)

@xPaw xPaw mentioned this pull request Mar 8, 2016
12 tasks
"action",

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this blank line?

@astorije
Copy link
Member

astorije commented Mar 9, 2016

@xPaw, I left you a few comments inline. This is globally great work and I am eager to see what it looks like when you address the comments (assuming I am not mistaken on them).
Also, note that some of the comments above will probably be unnecessary (or less necessary) if my comment about direct lookup vs. sequential lookup of inputs applies. EDIT: It didn't.

@astorije
Copy link
Member

astorije commented Mar 9, 2016

Alright @xPaw, I added a note on all comments that you can ignore for this PR, keeping them around for archive purpose. Left the others untouched.

@astorije astorije assigned astorije and unassigned maxpoulin64 Mar 9, 2016
@xPaw
Copy link
Member Author

xPaw commented Mar 9, 2016

@astorije Fixed some of the things you pointed out except for the /say handling.

@@ -268,18 +268,28 @@ Client.prototype.setPassword = function(hash) {

Client.prototype.input = function(data) {
var client = this;
var text = data.text.trim();
var text = data.text.replace(/\s+$/, "");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astorije This is for you. You're right it's silly to trim the start.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thanks!

@astorije
Copy link
Member

astorije commented Mar 9, 2016

👍 but I will test locally before merging tonight if you don't mind, @xPaw.

}

var args = text.split(" ");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While testing this, I found an issue: any text starting with one or more whitespace does not send anything nor produce an error. It's because test here becomes ['', 'test'].
We can fix this with the first of the 2 solutions below. However, I wonder if it is any good or bad to keep multiple whitespaces within commands. For example, /join #channel becomes ['join', '', '', '#channel'] then back to join #channel... I don't know if that could be an issue in some scenarios, in which case the second solution below would solve it.

var args = text.trim().split(" ");
var args = text.split(" ").filter(function (a) { return a.length !== 0; });

I might be missing an alternative, but I wanted to address the bug in the first place and look for potential solutions :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the trim change, it will have to go into the next overhaul.

@astorije
Copy link
Member

👍 and merging.
@xPaw, thanks for this! I will commit my local changes (require once and for all, direct addressing) within a couple days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't intercept /(c|h|n)s shortcut commands
4 participants