diff options
author | luk3yx <luk3yx@users.noreply.github.com> | 2022-05-07 17:14:09 +1200 |
---|---|---|
committer | luk3yx <luk3yx@users.noreply.github.com> | 2022-05-07 17:14:09 +1200 |
commit | 9f305535df4245df94c4d621bd3f2eaa078ab942 (patch) | |
tree | adca5f9c1e95c06f78e7b69727b901e3802baa33 | |
parent | ea3245d8b435a9da5ab960dc11e2141555a2634c (diff) | |
download | miniirc_idc-9f305535df4245df94c4d621bd3f2eaa078ab942.tar.gz miniirc_idc-9f305535df4245df94c4d621bd3f2eaa078ab942.zip |
Fix CHANMSG and don't swallow exceptions
-rw-r--r-- | miniirc_idc.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/miniirc_idc.py b/miniirc_idc.py index ed42afd..1044144 100644 --- a/miniirc_idc.py +++ b/miniirc_idc.py @@ -27,7 +27,7 @@ from __future__ import annotations from collections.abc import Iterator, Mapping, Sequence from typing import Optional -import datetime, miniirc, re # type: ignore +import datetime, miniirc, re, traceback # type: ignore assert miniirc.ver >= (1,8,1) @@ -50,6 +50,14 @@ def _get_idc_args(command: str, kwargs: Mapping[str, Optional[str | float]] class IDC(miniirc.IRC): + def _idc_message_parser_no_exc( + self, msg: str + ) -> Optional[tuple[str, tuple[str, str, str], dict[str, str], list[str]]]: + try: + return self.idc_message_parser(msg) + except Exception: + traceback.print_exc() + def idc_message_parser( self, msg: str ) -> Optional[tuple[str, tuple[str, str, str], dict[str, str], list[str]]]: @@ -77,7 +85,7 @@ class IDC(miniirc.IRC): args = [self.current_nick, msg] elif idc_cmd == 'CHANMSG': command = 'PRIVMSG' - args = ['#' + idc_args['CHAN'], idc_args['MESSAGE']] + args = ['#' + idc_args['TARGET'], idc_args['MESSAGE']] elif idc_cmd == 'LOGIN_GOOD': command = '001' args = [self.current_nick, f'Welcome to IDC {self.current_nick}'] @@ -174,4 +182,4 @@ class IDC(miniirc.IRC): # Override the message parser to change the default parser. def change_parser(self, parser=None): - super().change_parser(parser or self.idc_message_parser) + super().change_parser(parser or self._idc_message_parser_no_exc) |