super3 / IRC-Bot

A very little basic IRCBot that will get improved over the next time.
http://www.wildphp.com
102 stars 47 forks source link

Allow multiple values for $numberOfArguments #50

Closed NanoSector closed 9 years ago

NanoSector commented 9 years ago

Right now, if your command allows both no and 1 argument, you have to set it to -1 (because 1 will error out with no arguments), allowing more than one argument to be passed, requiring you to validate the amount of arguments yourself.

A possible solution would be passing an array to the $numberOfArguments variable, containing (0,1) or similar. Then the command interpreter would check for in_array(count($arguments), $this->numberOfArguments) if the variable is an array; else simply check count($arguments) == $this->numberOfArguments like it does now.

NanoSector commented 9 years ago

Additionally, with the help module, it could be extended to take a different usage string for each number of arguments, with $usage[0] = '!command'; $usage[1] = '!command [parameter]'; And so on.

NanoSector commented 9 years ago

Fixed something up locally. Committing in a bit.

NanoSector commented 9 years ago

PR #54 should fix this, though it has a merge conflict. I'm not familiar with solving those, any help?

NanoSector commented 9 years ago

Oh I see now - the hostname verification commit was screwing up things. Recreating the PR.