mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
utils.getHostmask: option to return hostmask with real host, use placeholders w/o spaces in them
This commit is contained in:
parent
6577013ada
commit
0430e1dae7
21
utils.py
21
utils.py
@ -490,23 +490,30 @@ def isManipulatableClient(irc, uid):
|
|||||||
"""
|
"""
|
||||||
return irc.isInternalClient(uid) and irc.users[uid].manipulatable
|
return irc.isInternalClient(uid) and irc.users[uid].manipulatable
|
||||||
|
|
||||||
def getHostmask(irc, user):
|
def getHostmask(irc, user, realhost=False):
|
||||||
"""Returns the hostmask of the given user, if present."""
|
"""
|
||||||
|
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)
|
userobj = irc.users.get(user)
|
||||||
if userobj is None:
|
|
||||||
return '<user object not found>'
|
|
||||||
try:
|
try:
|
||||||
nick = userobj.nick
|
nick = userobj.nick
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
nick = '<unknown nick>'
|
nick = '<unknown-nick>'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ident = userobj.ident
|
ident = userobj.ident
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
ident = '<unknown ident>'
|
ident = '<unknown-ident>'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if realhost:
|
||||||
|
host = userobj.realhost
|
||||||
|
else:
|
||||||
host = userobj.host
|
host = userobj.host
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
host = '<unknown host>'
|
host = '<unknown-host>'
|
||||||
|
|
||||||
return '%s!%s@%s' % (nick, ident, host)
|
return '%s!%s@%s' % (nick, ident, host)
|
||||||
|
|
||||||
def loadModuleFromFolder(name, folder):
|
def loadModuleFromFolder(name, folder):
|
||||||
|
Loading…
Reference in New Issue
Block a user