From ad9a51fc335a911587457faefd3a99c66fcb6260 Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 9 Apr 2019 19:10:20 -0700 Subject: [PATCH] commands.showuser: properly handle numeric-type UIDs and channels --- plugins/commands.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/commands.py b/plugins/commands.py index 46d62c3..8f69d14 100644 --- a/plugins/commands.py +++ b/plugins/commands.py @@ -43,10 +43,22 @@ def showuser(irc, source, args): except IndexError: irc.error("Not enough arguments. Needs 1: nick.") return + u = irc.nick_to_uid(target) or target + + # Some protocol modules store UIDs as ints; make sure we check for that. + try: + int_u = int(u) + except ValueError: + pass + else: + if int_u in irc.users: + u = int_u + # Only show private info if the person is calling 'showuser' on themselves, # or is an oper. verbose = irc.is_oper(source) or u == source + if u not in irc.users: irc.error('Unknown user %r.' % target) return @@ -73,7 +85,7 @@ def showuser(irc, source, args): f('\x02Protocol UID\x02: %s; \x02Real host\x02: %s; \x02IP\x02: %s' % \ (u, userobj.realhost, userobj.ip)) channels = sorted(userobj.channels) - f('\x02Channels\x02: %s' % (' '.join(channels) or _none)) + f('\x02Channels\x02: %s' % (' '.join(map(str, channels)) or _none)) f('\x02PyLink identification\x02: %s; \x02Services account\x02: %s; \x02Away status\x02: %s' % \ ((userobj.account or _none), (userobj.services_account or _none), userobj.away or _none))