Closed Clasko closed 1 year ago
Hi Clasko,
thank you for digging this up. I could reproduce it by using the !poll
command provided by the respective module in the repository without any arguments.
Returning an empty string here is indeed a very radical step which should be replaced. My suggestion is the following:
if len(argsMsg) == 0 and (len(argsAnswer) > 0 or re.match('.*\$arg@', answerText)):
# … return an empty string, i.e. prevent the bot from reacting with a message.
return answerText.replace("$arg", "missingArg")
This way, the actual string for calling the function is preserved and detecting as well as handling the wrong string arguments missingArg[0-9@]
is something the function called via the command has to take care of.
Please let me know what you think of this solution.
Regards, Weidengeist
Sure, this would do the job. :)
Thank you very much for your feedback. :-) I have just updated the repository with the fix above and will mark the issue as solved.
There is currently no way to create a command with a function where arguments are optional.
The
resolveArguments
function returns an empty string when no argument are passed to the command: https://github.com/weidengeist/Willowbot/blob/744626bbf1aab412c3e630c00d2176410b4bd495/modules/message.py#L190-L192This breaks the
eval(func)
for functions: