UNPKG

@juzi/wechaty

Version:

Wechaty is a RPA SDK for Chatbot Makers.

64 lines 1.84 kB
import { log } from '@juzi/wechaty-puppet'; import { VERSION } from '../config.js'; const miscMixin = (mixinBase) => { log.verbose('WechatyMiscMixin', 'miscMixin(%s)', mixinBase.name); class MiscMixin extends mixinBase { constructor(...args) { super(...args); } /** * @ignore */ toString() { if (Object.keys(this.__options).length <= 0) { return this.constructor.name; } return [ 'Wechaty#', this.id, `<${(this.__options.puppet) || ''}>`, `(${(this.__memory && this.__memory.name) || ''})`, ].join(''); } /** * Wechaty bot name set by `options.name` * default: `wechaty` */ name() { return this.__options.name || 'wechaty'; } /** * @ignore * Return version of Wechaty * * @returns {string} - the version number * @example * console.log(Wechaty.instance().version()) // return '#git[af39df]' * console.log(Wechaty.instance().version(true)) // return '0.7.9' */ version() { return VERSION; } /** * @ignore */ async sleep(milliseconds) { await new Promise(resolve => setTimeout(resolve, milliseconds)); } /** * @private */ ding(data) { log.silly('WechatyMiscMixin', 'ding(%s)', data || ''); try { this.puppet.ding(data); } catch (e) { this.emitError(e); } } } return MiscMixin; }; export { miscMixin, }; //# sourceMappingURL=misc-mixin.js.map