#include user.js

Umi.Message = (() => {
    const chatBot = new Umi.User('-1', 'Server');

    return function(msgId, time, user, text, channel, highlight, botInfo, isAction, isLog) {
        msgId = (msgId || '').toString();
        time = time === null ? new Date() : (typeof time === 'object' ? time : new Date(parseInt(time || 0) * 1000));
        user = user !== null && typeof user === 'object' ? user : chatBot;
        text = (text || '').toString();
        channel = (channel || '').toString();
        highlight = !!highlight;
        isAction = !!isAction;
        isLog = !!isLog;
        hasSeen = isLog;

        const msgIdInt = parseInt(msgId);

        return {
            getId: () => msgId,
            getIdInt: () => {
                const num = parseInt(msgId);
                return isNaN(num) ? (Math.round(Number.MIN_SAFE_INTEGER * Math.random())) : num;
            },
            getTime: () => time,
            getUser: () => user,
            getText: () => text,
            getChannel: () => channel,
            shouldHighlight: () => highlight,
            getBotInfo: () => botInfo,
            isAction: () => isAction,
            isLog: () => isLog,
            hasSeen: () => hasSeen,
            markSeen: () => hasSeen = true,
        };
    };
})();
