Skip to content

Commit

Permalink
Disallow options for ModBot commands
Browse files Browse the repository at this point in the history
Up to now using a word in a ModBot reason argument which started with a
hypen would ModBot not to process the command, as its argparse parser
would consider that word as an not existing option. As we don't use
options and only use arguments for ModBot commands, this disables option
detection for the argparse parser. While this isn't officially supported
by argparse, using a list with `None` as only item for the prefix
characters, which are supposed to be a string instead of a list, does
achieve exactly that.
  • Loading branch information
Dunedan committed Mar 11, 2024
1 parent ddacb09 commit 419ebb3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions xpartamupp/modbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def __init__(self, *args, **kwargs) -> None:
"""
kwargs["add_help"] = False
kwargs["exit_on_error"] = False
kwargs["prefix_chars"] = [None]
super().__init__(*args, **kwargs)
self._positionals = self.add_argument_group("arguments")

Expand Down

0 comments on commit 419ebb3

Please sign in to comment.