3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

utils.getHostmask: option to return hostmask with real host, use placeholders w/o spaces in them

This commit is contained in:
James Lu 2015-12-31 18:09:19 -08:00
parent 6577013ada
commit 0430e1dae7

View File

@ -490,23 +490,30 @@ def isManipulatableClient(irc, uid):
"""
return irc.isInternalClient(uid) and irc.users[uid].manipulatable
def getHostmask(irc, user):
"""Returns the hostmask of the given user, if present."""
def getHostmask(irc, user, realhost=False):
"""
Returns the hostmask of the given user, if present. If the realhost option
is given, return the real host of the user instead of the displayed host."""
userobj = irc.users.get(user)
if userobj is None:
return '<user object not found>'
try:
nick = userobj.nick
except AttributeError:
nick = '<unknown nick>'
nick = '<unknown-nick>'
try:
ident = userobj.ident
except AttributeError:
ident = '<unknown ident>'
ident = '<unknown-ident>'
try:
if realhost:
host = userobj.realhost
else:
host = userobj.host
except AttributeError:
host = '<unknown host>'
host = '<unknown-host>'
return '%s!%s@%s' % (nick, ident, host)
def loadModuleFromFolder(name, folder):