diff --git a/utils.py b/utils.py index 39f26ae..212f6e0 100644 --- a/utils.py +++ b/utils.py @@ -331,3 +331,21 @@ def isOper(irc, uid): Returns whether 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 '' + try: + nick = userobj.nick + except AttributeError: + nick = '' + try: + ident = userobj.ident + except AttributeError: + ident = '' + try: + host = userobj.host + except AttributeError: + host = '' + return '%s!%s@%s' % (nick, ident, host)