patch ba3e7dc07a05acfd34ca1f04ce176d0e1e48a03f
Author: E. Bosch <presidev@AT@gmail.com>
Date: Tue Nov 24 23:25:57 CET 2020
* irc: Improve the regular expresions for command parsing
hunk ./irc.py 16
-IRC_NICK_RX = re.compile(r'NICK :(?P<nick>[^\n\r]+)')
-IRC_PASS_RX = re.compile(r'PASS :(?P<app_id>[^\s]+) (?P<app_hash>[^\n\r]+)')
-IRC_PING_RX = re.compile(r'PING (?P<payload>[^\n\r]+)')
-IRC_PRIVMSG_RX = re.compile(r'PRIVMSG (?P<nick>[^\s]+) :(?P<message>[^\n\r]+)')
-IRC_USER_RX = re.compile(r'USER (?P<username>[^\s]+) [^\s]+ [^\s]+ :(?P<realname>[^\n\r]+)')
-IRC_JOIN_RX = re.compile(r'JOIN (?P<channel>[^\s]+)')
+PREFIX = r'(:[^ ]+ +|)'
+IRC_NICK_RX = re.compile(PREFIX + r'NICK +(:|)(?P<nick>[^\n\r]+)')
+IRC_PASS_RX = re.compile(PREFIX + r'PASS +(:|)(?P<password>[^\n\r]+)')
+IRC_PING_RX = re.compile(PREFIX + r'PING +(:|)(?P<payload>[^\n\r]+)')
+IRC_PRIVMSG_RX = re.compile(PREFIX + r'PRIVMSG +(?P<nick>[^ ]+) +(:|):(?P<message>[^\n\r]+)')
+IRC_USER_RX = re.compile(PREFIX + r'USER +(?P<username>[^ ]+) +[^ ]+ +[^ ]+ +(:|)(?P<realname>[^\n\r]+)')
+IRC_JOIN_RX = re.compile(PREFIX + r'JOIN +(?P<channel>[^ ]+)')