From 8de7b30333ae2a5bd419306a791e52b2d53b17fc Mon Sep 17 00:00:00 2001 From: luk3yx Date: Sat, 7 May 2022 19:48:07 +1200 Subject: Parse NOTICE and ACTION --- miniirc_idc.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/miniirc_idc.py b/miniirc_idc.py index 726d2e2..d8a3d46 100644 --- a/miniirc_idc.py +++ b/miniirc_idc.py @@ -109,14 +109,8 @@ class IDC(miniirc.IRC): # Translate IDC keyword arguments into IRC positional ones tags = {} if idc_cmd == 'PRIVMSG': - msg = idc_args['MESSAGE'] command = 'PRIVMSG' - msg_type = idc_args.get('TYPE') - if msg_type == 'NOTICE': - command = 'NOTICE' - elif msg_type == 'ACTION': - msg = f'\x01ACTION {msg}\x01' - args = [self.current_nick, msg] + args = [self.current_nick, idc_args['MESSAGE']] elif idc_cmd == 'CHANMSG': command = 'PRIVMSG' args = ['#' + idc_args['TARGET'], idc_args['MESSAGE']] @@ -147,10 +141,18 @@ class IDC(miniirc.IRC): else: hostmask = ('', '', '') - # If echo-message wasn't requested then don't send self messages - if (command == 'PRIVMSG' and hostmask[0] == self.current_nick and - 'echo-message' not in self.active_caps): - return None + if command == 'PRIVMSG': + # If echo-message wasn't requested then don't send self messages + if (hostmask[0] == self.current_nick and + 'echo-message' not in self.active_caps): + return None + + # Parse the message type + msg_type = idc_args.get('TYPE', '').upper() + if msg_type == 'NOTICE': + command = 'NOTICE' + elif msg_type == 'ACTION': + args[1] = f'\x01ACTION {args[1]}\x01' if 'TS' in idc_args: dt = datetime.datetime.utcfromtimestamp(float(idc_args['TS'])) -- cgit v1.2.3