# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


from twisted.words.protocols import irc
from txircd.utils import epoch, now
from copy import deepcopy
        from txircd.server import ChannelMessage
            from txircd.server import SetMode
        from txircd.server import SetTopic
        from txircd.server import SetMetadata # This import is moved to here to alleviate issues with circular dependencies
        from txircd.server import SetMetadata
                lineSource = displayPrefix
            else:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name)
                lineSource = self.ircd.name
            
            for server in self.ircd.servers.itervalues():
                if server.nearHop == self.ircd.name:
                    server.callRemote(SetMode, target=self.name, targetts=epoch(self.created), source=lineSource, modestring="".join(modestring), params=showParams)
            for action in self.ircd.actions["mode"]:
                action(self, lineSource, modeLine, modeDisplay)
            return modeLine
        return ""
    
    def modeString(self, user):
        modes = [] # Since we're appending characters to this string, it's more efficient to store the array of characters and join it rather than keep making new strings
        params = []
        for mode, param in self.mode.iteritems():
            modetype = self.ircd.channel_mode_type[mode]
            if modetype > 0:
                modes.append(mode)
                if param:
                    params.append(self.ircd.channel_modes[modetype][mode].showParam(user, self, param))
        return ("+{} {}".format("".join(modes), " ".join(params)) if params else "+{}".format("".join(modes)))
    
    def setTopic(self, topic, setter):
        for action in self.ircd.actions["topic"]:
            action(self, topic, setter)
        self.topic = str(topic)
        self.topicSetter = str(setter)

# Path: txircd/utils.py
# def epoch(utc_datetime):
#     delta = utc_datetime - UNIX_EPOCH
#     return int(delta.total_seconds())
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


# Path: txircd/channel.py
from twisted.words.protocols import irc
from txircd.utils import epoch, now
from copy import deepcopy
        from txircd.server import ChannelMessage
            from txircd.server import SetMode
        from txircd.server import SetTopic
        from txircd.server import SetMetadata # This import is moved to here to alleviate issues with circular dependencies
        from txircd.server import SetMetadata

                lineSource = displayPrefix
            else:
                for u in self.users.iterkeys():
                    u.sendMessage("MODE", modeLine, to=self.name)
                lineSource = self.ircd.name
            
            for server in self.ircd.servers.itervalues():
                if server.nearHop == self.ircd.name:
                    server.callRemote(SetMode, target=self.name, targetts=epoch(self.created), source=lineSource, modestring="".join(modestring), params=showParams)
            for action in self.ircd.actions["mode"]:
                action(self, lineSource, modeLine, modeDisplay)
            return modeLine
        return ""
    
    def modeString(self, user):
        modes = [] # Since we're appending characters to this string, it's more efficient to store the array of characters and join it rather than keep making new strings
        params = []
        for mode, param in self.mode.iteritems():
            modetype = self.ircd.channel_mode_type[mode]
            if modetype > 0:
                modes.append(mode)
                if param:
                    params.append(self.ircd.channel_modes[modetype][mode].showParam(user, self, param))
        return ("+{} {}".format("".join(modes), " ".join(params)) if params else "+{}".format("".join(modes)))
    
    def setTopic(self, topic, setter):
        for action in self.ircd.actions["topic"]:
            action(self, topic, setter)
        self.topic = str(topic)
        self.topicSetter = str(setter)

        self.topicTime = now()