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

Allow use of \ for escaping when command chains are enabled. #293

Closed
LikeLakers2 opened this issue Dec 24, 2016 · 1 comment
Closed

Allow use of \ for escaping when command chains are enabled. #293

LikeLakers2 opened this issue Dec 24, 2016 · 1 comment
Labels

Comments

@LikeLakers2
Copy link
Contributor

LikeLakers2 commented Dec 24, 2016

Title says it all. It's uses should be obvious too, though I'm surprised this wasn't already considered when creating command chain functionality.

As to why it's needed, if anyone needs to know: Something like !command "Hello, I'm some \"args with quotes\"" would, with the current code, be given ["Hello, I'm some \\args", "with", "quotes\\"] (or something to that effect, I haven't tested it enough to see where and how many \ there are) as its array of parameters, instead of ["Hello, I'm some \"args with quotes\""] as you would expect.

If need be, I've hacked together a small bit of code for the beginning of this block that replicates this escaping functionality, though I doubt it fits the coding style of the rest of the code:

escaped = false
@chain.each_char.each_with_index do |char, index|
  # Escape character
  if char == '\\' && !escaped
    escaped = true
    next
  elsif escaped
    result += char
    escaped = false
    next
  end
	
  #blah blah blah rest of the code goes here```
@meew0 meew0 added commands Related to CommandBot enhancement labels Jan 2, 2017
@meew0
Copy link
Collaborator

meew0 commented Jan 10, 2017

I've looked into this for a while and can't do this in a satisfactory way. It's not really as simple as your code because your code doesn't account for nested chains, which need to have the escaping propagated in some way, but no matter what I try it either ends up as a really hacky solution (even worse than the adv_func stuff already is) or there's some problem.

You're welcome to try solving the problem yourself but I don't feel like this is important enough, given that you can escape stuff using quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants