# Path: txircd/modbase.py
# class Command(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def onUse(self, user, data):
#         pass
#     def processParams(self, user, params):
#         return {
#             "user": user,
#             "params": params
#         }
#     def updateActivity(self, user):
#         user.lastactivity = now()
# 
# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def irc_lower(str):
#     return str.lower().replace("[","{").replace("]","}").replace("/","|").replace("~","^")
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.utils import epoch, irc_lower, now
from fnmatch import fnmatch
        else:
            fields = ""
        if target[0][0] == "#" and target not in self.ircd.channels:
            user.sendMessage(irc.RPL_ENDOFWHO, channel, ":End of /WHO list")
            return {}
        return {
            "user": user,
            "target": target,
            "filters": filters,
            "fields": fields
        }
    
    def sendWhoLine(self, user, targetUser, destination, channel, filters, fields):
        displayChannel = destination
        if not channel:
            for chan in self.ircd.channels.itervalues():
                if user in chan.users and targetUser in chan.users:
                    displayChannel = chan
                    break
            else:
                displayChannel = "*"
        udata = {
            "dest": destination,
            "nick": targetUser.nickname,
            "ident": targetUser.username,
            "host": targetUser.hostname,
            "ip": targetUser.ip,
            "server": targetUser.server,
            "away": "away" in targetUser.metadata["ext"],
            "oper": "o" in targetUser.mode,

# Path: txircd/modbase.py
# class Command(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def onUse(self, user, data):
#         pass
#     def processParams(self, user, params):
#         return {
#             "user": user,
#             "params": params
#         }
#     def updateActivity(self, user):
#         user.lastactivity = now()
# 
# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def irc_lower(str):
#     return str.lower().replace("[","{").replace("]","}").replace("/","|").replace("~","^")
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


# Path: txircd/modules/cmd_who.py
from twisted.words.protocols import irc
from txircd.modbase import Command
from txircd.utils import epoch, irc_lower, now
from fnmatch import fnmatch

        else:
            fields = ""
        if target[0][0] == "#" and target not in self.ircd.channels:
            user.sendMessage(irc.RPL_ENDOFWHO, channel, ":End of /WHO list")
            return {}
        return {
            "user": user,
            "target": target,
            "filters": filters,
            "fields": fields
        }
    
    def sendWhoLine(self, user, targetUser, destination, channel, filters, fields):
        displayChannel = destination
        if not channel:
            for chan in self.ircd.channels.itervalues():
                if user in chan.users and targetUser in chan.users:
                    displayChannel = chan
                    break
            else:
                displayChannel = "*"
        udata = {
            "dest": destination,
            "nick": targetUser.nickname,
            "ident": targetUser.username,
            "host": targetUser.hostname,
            "ip": targetUser.ip,
            "server": targetUser.server,
            "away": "away" in targetUser.metadata["ext"],
            "oper": "o" in targetUser.mode,

            "idle": epoch(now()) - epoch(targetUser.lastactivity),