dferrante / pywx

python weather bot
10 stars 3 forks source link

alert command crashes bot if no argument is supplied #8

Closed dziban303 closed 5 years ago

dziban303 commented 7 years ago

The alert command works, so long as an argument is given. Even a nonsense number argument ('alert 23473') won't cause a crash.

However, supplying a text argument, or no argument at all, causes the crash.

It seems like this should be easily fixed by sanitizing the argument. Alas, I don't know how to do that.

2017-08-29 01:56:43,902 DEBUG :dziban303!dziban303@user/dziban303 PRIVMSG #dzibania :alert 2017-08-29 01:56:43,904 INFO got command alert {'ident': ':dziban303!dziban303', 'command': 'alert', 'sender': 'dziban303', 'msg': 'alert', 'chan': '#dzibania', 'args': '', 'mask': 'user/dziban303', 'bot': <pythabot.Pythabot instance at 0x7f9122f17d40>} Traceback (most recent call last): File "pywx3.py", line 23, in bot.listen() File "/mnt/e/wxbot/dziwx/pywx/pythabot.py", line 119, in listen self.initparse(line) File "/mnt/e/wxbot/dziwx/pywx/pythabot.py", line 70, in initparse self.parse(parsedline) File "/mnt/e/wxbot/dziwx/pywx/pythabot.py", line 78, in parse reply = command.run(msg) File "/mnt/e/wxbot/dziwx/pywx/modules/weather.py", line 364, in run payload = super(Alert, self).context(msg) File "/mnt/e/wxbot/dziwx/pywx/modules/weather.py", line 186, in context args = self.parse_args(msg) File "/mnt/e/wxbot/dziwx/pywx/modules/weather.py", line 361, in parse_args return parser.parse_args(msg) File "/mnt/e/wxbot/dziwx/pywx/modules/base.py", line 54, in parse_args return super(IRCArgumentParser, self).parse_args(args) File "/usr/lib/python2.7/argparse.py", line 1701, in parse_args args, argv = self.parse_known_args(args, namespace) File "/usr/lib/python2.7/argparse.py", line 1733, in parse_known_args namespace, args = self._parse_known_args(args, namespace) File "/usr/lib/python2.7/argparse.py", line 1950, in _parse_knownargs self.error(('too few arguments')) File "/mnt/e/wxbot/dziwx/pywx/modules/base.py", line 57, in error raise ArgumentError(message) modules.base.ArgumentError: too few arguments

dziban303 commented 5 years ago

think this was fixed