mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 20:22:45 +01:00
utils: add getHostmask
This commit is contained in:
parent
c00da49477
commit
1b09a00ea9
18
utils.py
18
utils.py
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user