patch a632ad5590ca682a3409d25be72768761aff0b95
Author: E. Bosch <presidev@AT@gmail.com>
Date: Fri Feb 5 00:38:22 CET 2021
* irc: Add WHO command
hunk ./irc.py 32
+IRC_WHO_RX = re.compile(PREFIX + r'WHO( +:| +|\n)(?P<target>[^\n]+|)')
hunk ./irc.py 98
+ (IRC_WHO_RX, self.handle_irc_who, True),
hunk ./irc.py 164
+ async def handle_irc_who(self, user, target):
+ self.logger.debug('Handling WHO: %s', target)
+ tgt = target.lower()
+ if tgt in self.irc_channels.keys():
+ users = self.irc_channels[tgt]
+ chan = target
+ elif tgt in self.users.keys():
+ users = (self.users[tgt],)
+ chan = '*'
+ else:
+ await self.reply_code(user, 'ERR_NOSUCHSERVER', (target,))
+ return
+ for usr in users:
+ if not isinstance(usr,IRCUser):
+ usr = self.users[usr.lower()]
+ op = self.get_irc_op(usr.irc_nick, chan)
+ await self.reply_code(user, 'RPL_WHOREPLY', (chan, usr.irc_username,
+ usr.address, self.hostname, usr.irc_nick, op, usr.irc_realname
+ ))
+ await self.reply_code(user, 'RPL_ENDOFWHO', (chan,))
+
hunk ./irc_replies.py 9
+ 'RPL_ENDOFWHO': ('315', '{} :End of WHO list'),
+ 'RPL_WHOREPLY': (352, '{} {} {} {} {} H{} :0 {}'),
hunk ./irc_replies.py 15
- 'ERR_NOSUCHSERVER': ('402', 'No such server'),
+ 'ERR_NOSUCHSERVER': ('402', '{} :Target not found'),