irc: Minor optimization in command parser
patch 96012123940ebb5a2671eb761cfd6540e18761a2
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sun Feb 14 01:02:09 CET 2021
* irc: Minor optimization in command parser
diff -rN -u old-irgramd/irc.py new-irgramd/irc.py
--- old-irgramd/irc.py 2024-11-23 03:13:39.294689861 +0100
+++ new-irgramd/irc.py 2024-11-23 03:13:39.298689855 +0100
@@ -63,12 +63,10 @@
break
message = message.decode()
self.logger.debug(message)
- matched = False
for pattern, handler, register_required in self.irc_handlers:
matches = pattern.match(message)
if matches:
- matched = True
if user.registered or not register_required:
params = matches.groupdict()
# Remove possible extra characters in parameters
@@ -81,8 +79,9 @@
await self.reply_code(user, 'ERR_NEEDMOREPARAMS')
else:
await self.reply_code(user, 'ERR_NOTREGISTERED', ('',), '*')
+ break
- if not matched and user.registered:
+ if not matches and user.registered:
await self.reply_code(user, 'ERR_UNKNOWNCOMMAND')
def set_telegram(self, tg):