UNPKG

@ginstone/nga-api

Version:

42 lines (41 loc) 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ReplySimple = void 0; const ReplyStatus_1 = require("../../enums/ReplyStatus"); const TimeUtils_1 = require("../../utils/TimeUtils"); const BbsTagParser_1 = require("../../bbscode/BbsTagParser"); const StrUtils_1 = require("@ginstone/common-utils/dist/src/utils/StrUtils"); const DiceUtils_1 = require("../../bbscode/DiceUtils"); /** * 简单回复信息 */ class ReplySimple { constructor(raw) { if (raw.content) raw.content = raw.content.replace(/&/g, '&'); if (raw.authorid) this.authorUid = raw.authorid; if (raw.content) this.content = raw.content; if (raw.pid !== undefined) this.replyId = raw.pid; if (raw.reply_to !== undefined) this.replyToId = raw.reply_to; if (typeof raw.postdate == "number") this.postDatetime = (0, TimeUtils_1.secondsToDate)(raw.postdate); if (raw.subject) this.title = (0, StrUtils_1.unEscape)(raw.subject); if (raw.tid) this.topicId = raw.tid; if (raw.type) this.status = (0, ReplyStatus_1.parseStatus)(raw.type); if (raw.content) { this.contentNodes = BbsTagParser_1.BbsTagParser.parseContent(raw.content); //计算随机数 if (this.authorUid !== undefined && this.replyId !== undefined && this.topicId !== undefined) { DiceUtils_1.DiceUtils.calculate(this.contentNodes, this.authorUid + this.topicId + this.replyId); } } } } exports.ReplySimple = ReplySimple;