UNPKG

@kotori-bot/core

Version:
74 lines (73 loc) 2.21 kB
/** * @Package @kotori-bot/core * @Version 1.7.0 * @Author Arimura Sena <me@hotaru.icu> * @Copyright 2024-2025 Hotaru. All rights reserved. * @License BAN-ZHINESE-USING * @Link https://github.com/kotorijs/kotori * @Date 17:26:09 */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var adapter_exports = {}; __export(adapter_exports, { Adapter: () => Adapter, default: () => adapter_default }); module.exports = __toCommonJS(adapter_exports); var import_session = require("./session"); class Adapter { constructor(ctx, config, identity) { this.ctx = ctx; this.config = config; this.identity = identity; } online() { if (this.status.value !== "offline") return; this.status.value = "online"; this.ctx.emit("status", { adapter: this, status: "online" }); } offline() { if (this.status.value !== "online") return; this.status.value = "offline"; this.status.offlineTimes += 1; this.ctx.emit("status", { adapter: this, status: "offline" }); } session(type, data) { const session = new import_session.Session(data, this); this.ctx.emit(type, ...[session]); } ctx; config; identity; status = { value: "offline", createTime: /* @__PURE__ */ new Date(), lastMsgTime: null, receivedMsg: 0, sentMsg: 0, offlineTimes: 0 }; selfId = ""; } var adapter_default = Adapter; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Adapter });