UNPKG

@ginstone/nga-api

Version:

51 lines (50 loc) 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Gift = exports.ReplyInfo = void 0; const AlterInfo_1 = require("./AlterInfo"); const Attachment_1 = require("./attach/Attachment"); const ObjUtils_1 = require("../../utils/ObjUtils"); const Reply_1 = require("./Reply"); const Vote_1 = require("../vote/Vote"); const ItemData_1 = require("../nuke/ItemData"); class ReplyInfo extends Reply_1.ReplySimple { constructor(raw) { super(raw); if (raw[14]) this.gifts = (Object.keys(raw[14]).map(id => new Gift(parseInt(id), raw[14][id]))); if (raw.alterinfo) this.alterInfo = new AlterInfo_1.AlterInfo(raw.alterinfo); if (raw.attachs) this.attachments = Object.keys(raw.attachs).map(key => new Attachment_1.Attachment(raw.attachs[key])); if (raw.hotreply) this.hotReplies = (0, ObjUtils_1.obj2List)(raw.hotreply, (key, value) => new ReplyInfo(value)); if (raw.comment) this.comment = (0, ObjUtils_1.obj2List)(raw.comment, (key, value) => new ReplyInfo(value)); if (raw.from_client) this.fromClient = raw.from_client; if (raw.lou !== undefined) this.floorNumber = raw.lou; if (raw.recommend) this.recommendScore = raw.recommend; if (raw.score != undefined) this.agreeCount = raw.score; if (raw.score_2 != undefined) this.disagreeCount = raw.score_2; if (raw.postdate && typeof raw.postdate !== 'number') this.postDate = raw.postdate; if (raw.postdatetimestamp) this.postDatetime = new Date(raw.postdatetimestamp * 1000); if (raw.vote) { this.voteData = raw.vote.includes("type~1") ? new Vote_1.BetData(raw.vote) : new Vote_1.VoteData(raw.vote); } } } exports.ReplyInfo = ReplyInfo; class Gift { constructor(id, count) { this.id = id; this.count = count; this.url = ItemData_1.ItemInfo.URL_PREFIX + `5_${id}.png`; } } exports.Gift = Gift;