UNPKG

@tgsnake/core

Version:

Pure Telegram MTProto library for nodejs

24 lines (23 loc) 927 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MsgFactory = MsgFactory; const SeqNo_js_1 = require("./SeqNo.js"); const index_js_1 = require("../../raw/index.js"); const platform_node_js_1 = require("../../platform.node.js"); function MsgFactory() { const seqNo = new SeqNo_js_1.SeqNo(); const notRelatedContent = (content) => { if (content instanceof index_js_1.Raw.Ping) return true; if (content instanceof index_js_1.Raw.HttpWait) return true; if (content instanceof index_js_1.Raw.MsgsAck) return true; if (content instanceof index_js_1.MsgContainer) return true; return false; }; return (body, msgId) => { return new index_js_1.Message(body, BigInt(msgId.getMsgId()), seqNo.getSeqNo(!notRelatedContent(body)), platform_node_js_1.Buffer.byteLength(body.write())); }; }