# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
# 
# Path: txircd/utils.py
# class CaseInsensitiveDictionary(MutableMapping):
#     def __init__(self):
#         self._data = {}
# 
#     def __repr__(self):
#         return repr(self._data)
# 
#     def __delitem__(self, key):
#         try:
#             del self._data[irc_lower(key)]
#         except KeyError:
#             raise KeyError(key)
# 
#     def __getitem__(self, key):
#         try:
#             return self._data[irc_lower(key)]
#         except KeyError:
#             raise KeyError(key)
# 
#     def __iter__(self):
#         return iter(self._data)
# 
#     def __len__(self):
#         return len(self._data)
# 
#     def __setitem__(self, key, value):
#         self._data[irc_lower(key)] = value
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


from twisted.python.logfile import DailyLogFile
from txircd.modbase import Module
from txircd.utils import CaseInsensitiveDictionary, now
        logFile.write(line)
    
    def logMsg(self, cmd, data):
        if cmd in ["PRIVMSG", "NOTICE"]:
            if "targetchan" not in data or not data["targetchan"]:
                return
            user = data["user"]
            message = data["message"]
            if cmd == "PRIVMSG":
                if message[0:7] == "\x01ACTION":
                    message = data["message"][8:]
                    if message[-1] == "\x01":
                        message = message[:-1]
                    for index, chan in enumerate(data["targetchan"]):
                        prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                        if data["chanmod"][index]:
                            self.writeLog(chan, "*({}#) {}{} {}".format(data["chanmod"][index], prefix, user.nickname, message))
                        else:
                            self.writeLog(chan, "* {}{} {}".format(prefix, user.nickname, message))
                else:
                    for index, chan in enumerate(data["targetchan"]):
                        prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                        if data["chanmod"][index]:
                            self.writeLog(chan, "<{}#:{}{}> {}".format(data["chanmod"][index], prefix, user.nickname, message))
                        else:
                            self.writeLog(chan, "<{}{}> {}".format(prefix, user.nickname, message))
            elif cmd == "NOTICE":
                for index, chan in enumerate(data["targetchan"]):
                    prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                    if data["chanmod"][index]:

# Path: txircd/modbase.py
# class Module(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
# 
# Path: txircd/utils.py
# class CaseInsensitiveDictionary(MutableMapping):
#     def __init__(self):
#         self._data = {}
# 
#     def __repr__(self):
#         return repr(self._data)
# 
#     def __delitem__(self, key):
#         try:
#             del self._data[irc_lower(key)]
#         except KeyError:
#             raise KeyError(key)
# 
#     def __getitem__(self, key):
#         try:
#             return self._data[irc_lower(key)]
#         except KeyError:
#             raise KeyError(key)
# 
#     def __iter__(self):
#         return iter(self._data)
# 
#     def __len__(self):
#         return len(self._data)
# 
#     def __setitem__(self, key, value):
#         self._data[irc_lower(key)] = value
# 
# def now():
#     return datetime.datetime.utcnow().replace(microsecond=0)


# Path: txircd/modules/channellog.py
from twisted.python.logfile import DailyLogFile
from txircd.modbase import Module
from txircd.utils import CaseInsensitiveDictionary, now

        logFile.write(line)
    
    def logMsg(self, cmd, data):
        if cmd in ["PRIVMSG", "NOTICE"]:
            if "targetchan" not in data or not data["targetchan"]:
                return
            user = data["user"]
            message = data["message"]
            if cmd == "PRIVMSG":
                if message[0:7] == "\x01ACTION":
                    message = data["message"][8:]
                    if message[-1] == "\x01":
                        message = message[:-1]
                    for index, chan in enumerate(data["targetchan"]):
                        prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                        if data["chanmod"][index]:
                            self.writeLog(chan, "*({}#) {}{} {}".format(data["chanmod"][index], prefix, user.nickname, message))
                        else:
                            self.writeLog(chan, "* {}{} {}".format(prefix, user.nickname, message))
                else:
                    for index, chan in enumerate(data["targetchan"]):
                        prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                        if data["chanmod"][index]:
                            self.writeLog(chan, "<{}#:{}{}> {}".format(data["chanmod"][index], prefix, user.nickname, message))
                        else:
                            self.writeLog(chan, "<{}{}> {}".format(prefix, user.nickname, message))
            elif cmd == "NOTICE":
                for index, chan in enumerate(data["targetchan"]):
                    prefix = self.ircd.prefixes[chan.users[user][0]][0] if user in chan.users and chan.users[user] else ""
                    if data["chanmod"][index]:

                        self.writeLog(chan, "-{}#:{}{}- {}".format(data["chanmod"][index], prefix, user.nickname, message))