3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

utils: add getHostmask

This commit is contained in:
James Lu 2015-07-19 14:59:35 -07:00
parent c00da49477
commit 1b09a00ea9

View File

@ -331,3 +331,21 @@ def isOper(irc, uid):
Returns whether <UID> is an opered client.
"""
return (uid in irc.users and ("o", None) in irc.users[uid].modes)
def getHostmask(irc, user):
userobj = irc.users.get(user)
if userobj is None:
return '<user object not found>'
try:
nick = userobj.nick
except AttributeError:
nick = '<unknown nick>'
try:
ident = userobj.ident
except AttributeError:
ident = '<unknown ident>'
try:
host = userobj.host
except AttributeError:
host = '<unknown host>'
return '%s!%s@%s' % (nick, ident, host)