UNPKG

sendingnetwork-bot-sdk

Version:
67 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RoomAlias = exports.UserID = exports.SDNEntity = void 0; /** * Represents a SDN entity * @category Utilities */ class SDNEntity { /** * Creates a new SDN entity * @param {string} fullId The full ID of the entity */ constructor(fullId) { this.fullId = fullId; if (!fullId) throw new Error("No entity ID provided"); if (fullId.length < 2) throw new Error("ID too short"); const parts = fullId.split(/:/g); this.entityLocalpart = parts[0].substring(1); this.entityDomain = parts.splice(1).join(':'); } /** * The localpart for the entity */ get localpart() { return this.entityLocalpart; } /** * The domain for the entity */ get domain() { return this.entityDomain; } // override toString() { return this.fullId; } } exports.SDNEntity = SDNEntity; /** * Represents a SDN user ID * @category Utilities */ class UserID extends SDNEntity { constructor(userId) { super(userId); if (!userId.startsWith("@")) { throw new Error("Not a valid user ID"); } } } exports.UserID = UserID; /** * Represents a SDN room alias * @category Utilities */ class RoomAlias extends SDNEntity { constructor(alias) { super(alias); if (!alias.startsWith("#")) { throw new Error("Not a valid room alias"); } } } exports.RoomAlias = RoomAlias; //# sourceMappingURL=SDNEntity.js.map