@juzi/wechaty
Version:
Wechaty is a RPA SDK for Chatbot Makers.
102 lines • 6.02 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wechatifyUserModuleMixin = void 0;
const wechaty_puppet_1 = require("@juzi/wechaty-puppet");
const mod_js_1 = require("../user-modules/mod.js");
const wechatifyUserModuleMixin = (mixinBase) => {
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'wechatifyUserModuleMixin(%s)', mixinBase.name);
class WechatifyUserModuleMixin extends mixinBase {
constructor(...args) {
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'constructor()');
super(...args);
}
__wechatifiedContact;
__wechatifiedContactSelf;
__wechatifiedDelay;
__wechatifiedFriendship;
__wechatifiedImage;
__wechatifiedLocation;
__wechatifiedMessage;
__wechatifiedMiniProgram;
__wechatifiedPost;
__wechatifiedRoom;
__wechatifiedRoomInvitation;
__wechatifiedTag;
__wechatifiedTagGroup;
__wechatifiedUrlLink;
__wechatifiedChannel;
__wechatifiedMoment;
__wechatifiedCallRecord;
__wechatifiedChatHistory;
__wechatifiedWecom;
get Contact() { return guardWechatify(this.__wechatifiedContact); }
get ContactSelf() { return guardWechatify(this.__wechatifiedContactSelf); }
get Delay() { return guardWechatify(this.__wechatifiedDelay); }
get Friendship() { return guardWechatify(this.__wechatifiedFriendship); }
get Image() { return guardWechatify(this.__wechatifiedImage); }
get Location() { return guardWechatify(this.__wechatifiedLocation); }
get Message() { return guardWechatify(this.__wechatifiedMessage); }
get MiniProgram() { return guardWechatify(this.__wechatifiedMiniProgram); }
get Post() { return guardWechatify(this.__wechatifiedPost); }
get Room() { return guardWechatify(this.__wechatifiedRoom); }
get RoomInvitation() { return guardWechatify(this.__wechatifiedRoomInvitation); }
get Tag() { return guardWechatify(this.__wechatifiedTag); }
get TagGroup() { return guardWechatify(this.__wechatifiedTagGroup); }
get UrlLink() { return guardWechatify(this.__wechatifiedUrlLink); }
get Channel() { return guardWechatify(this.__wechatifiedChannel); }
get Moment() { return guardWechatify(this.__wechatifiedMoment); }
get CallRecord() { return guardWechatify(this.__wechatifiedCallRecord); }
get ChatHistory() { return guardWechatify(this.__wechatifiedChatHistory); }
get Wecom() { return guardWechatify(this.__wechatifiedWecom); }
async init() {
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'init()');
await super.init();
/**
* Skip if already wechatified
*/
if (this.__wechatifiedMessage) {
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'init() Wechaty User Module (WUM)s have already wechatified: skip');
return;
}
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'init() initializing Wechaty User Module (WUM) ...');
/**
* Wechatify User Classes
* 1. Binding the wechaty instance to the class
*
* Huan(202110): FIXME: remove any
*/
this.__wechatifiedContact = (0, mod_js_1.wechatifyUserModule)(mod_js_1.ContactImpl)(this);
this.__wechatifiedContactSelf = (0, mod_js_1.wechatifyUserModule)(mod_js_1.ContactSelfImpl)(this);
this.__wechatifiedDelay = (0, mod_js_1.wechatifyUserModule)(mod_js_1.DelayImpl)(this);
this.__wechatifiedFriendship = (0, mod_js_1.wechatifyUserModule)(mod_js_1.FriendshipImpl)(this);
this.__wechatifiedImage = (0, mod_js_1.wechatifyUserModule)(mod_js_1.ImageImpl)(this);
this.__wechatifiedLocation = (0, mod_js_1.wechatifyUserModule)(mod_js_1.LocationImpl)(this);
this.__wechatifiedMessage = (0, mod_js_1.wechatifyUserModule)(mod_js_1.MessageImpl)(this);
this.__wechatifiedMiniProgram = (0, mod_js_1.wechatifyUserModule)(mod_js_1.MiniProgramImpl)(this);
this.__wechatifiedPost = (0, mod_js_1.wechatifyUserModule)(mod_js_1.PostImpl)(this);
this.__wechatifiedRoom = (0, mod_js_1.wechatifyUserModule)(mod_js_1.RoomImpl)(this);
this.__wechatifiedRoomInvitation = (0, mod_js_1.wechatifyUserModule)(mod_js_1.RoomInvitationImpl)(this);
this.__wechatifiedTag = (0, mod_js_1.wechatifyUserModule)(mod_js_1.TagImpl)(this);
this.__wechatifiedTagGroup = (0, mod_js_1.wechatifyUserModule)(mod_js_1.TagGroupImpl)(this);
this.__wechatifiedUrlLink = (0, mod_js_1.wechatifyUserModule)(mod_js_1.UrlLinkImpl)(this);
this.__wechatifiedChannel = (0, mod_js_1.wechatifyUserModule)(mod_js_1.ChannelImpl)(this);
this.__wechatifiedMoment = (0, mod_js_1.wechatifyUserModule)(mod_js_1.MomentImpl)(this);
this.__wechatifiedCallRecord = (0, mod_js_1.wechatifyUserModule)(mod_js_1.CallRecordImpl)(this);
this.__wechatifiedChatHistory = (0, mod_js_1.wechatifyUserModule)(mod_js_1.ChatHistoryImpl)(this);
this.__wechatifiedWecom = (0, mod_js_1.wechatifyUserModule)(mod_js_1.WecomImpl)(this);
wechaty_puppet_1.log.verbose('WechatifyUserModuleMixin', 'init() initializing Wechaty User Module (WUM) ... done');
}
}
return WechatifyUserModuleMixin;
};
exports.wechatifyUserModuleMixin = wechatifyUserModuleMixin;
/**
* Huan(202008): we will bind the wechaty puppet with user modules (Contact, Room, etc) together inside the start() method
*/
function guardWechatify(userModule) {
if (userModule) {
return userModule;
}
throw new Error('Wechaty User Module (WUM, for example: wechaty.Room) can not be used before wechaty.start()!');
}
//# sourceMappingURL=wechatify-user-module-mixin.js.map