patch 6acc2599b3961c177cac87db79969190e17ec6ee
Author: E. Bosch <presidev@AT@gmail.com>
Date: Sat Feb 12 01:29:36 CET 2022
* irc: Improve MODE command hanlder
Add support for empty banlist response
diff -rN -u old-irgramd/irc.py new-irgramd/irc.py
--- old-irgramd/irc.py 2024-11-22 15:49:29.067872810 +0100
+++ new-irgramd/irc.py 2024-11-22 15:49:29.071872804 +0100
@@ -258,20 +258,30 @@
async def handle_irc_mode(self, user, target, mode, arguments):
self.logger.debug('Handling MODE: %s, %s, %s', target, mode, arguments)
- if not mode:
- tgt = target.lower()
- if tgt in self.users.keys():
- if tgt == user.irc_nick:
- await self.mode_user(user, user, False)
- else:
- await self.reply_code(user, 'ERR_USERSDONTMATCH')
- elif tgt[0] == '#':
- if tgt in self.irc_channels.keys():
- await self.mode_channel(user, target, False)
- else:
- await self.reply_code(user, 'ERR_NOSUCHCHANNEL', (target,))
+ is_user = False
+ is_channel = False
+
+ tgt = target.lower()
+ if tgt in self.users.keys():
+ if tgt == user.irc_nick:
+ is_user = True
+ else:
+ await self.reply_code(user, 'ERR_USERSDONTMATCH')
+ elif tgt[0] == '#':
+ if tgt in self.irc_channels.keys():
+ is_channel = True
else:
- await self.reply_code(user, 'ERR_NOSUCHNICK', (target,))
+ await self.reply_code(user, 'ERR_NOSUCHCHANNEL', (target,))
+ else:
+ await self.reply_code(user, 'ERR_NOSUCHNICK', (target,))
+
+ if not mode:
+ if is_user:
+ await self.mode_user(user, user, False)
+ if is_channel:
+ await self.mode_channel(user, target, False)
+ elif mode == 'b' and is_channel:
+ await self.reply_code(user, 'RPL_ENDOFBANLIST', (target,))
async def handle_irc_motd(self, user, target):
self.logger.debug('Handling MOTD: %s', target)
diff -rN -u old-irgramd/irc_replies.py new-irgramd/irc_replies.py
--- old-irgramd/irc_replies.py 2024-11-22 15:49:29.067872810 +0100
+++ new-irgramd/irc_replies.py 2024-11-22 15:49:29.071872804 +0100
@@ -28,6 +28,7 @@
'RPL_WHOREPLY': ('352', '{} {} {} {} {} H{} :0 {}'),
'RPL_NAMREPLY': ('353', '{} {} :{}'),
'RPL_ENDOFNAMES': ('366', '{} :End of NAME reply'),
+ 'RPL_ENDOFBANLIST': ('368', '{} :End of channel ban list'),
'RPL_MOTDSTART': ('375', ':- {} Message of the day - '),
'RPL_MOTD': ('372', ':- {}'),
'RPL_ENDOFMOTD': ('376', 'End of MOTD command'),