@juzi/wechaty
Version:
Wechaty is a RPA SDK for Chatbot Makers.
99 lines • 5.59 kB
JavaScript
import { log } from '@juzi/wechaty-puppet';
import { ContactImpl, ContactSelfImpl, DelayImpl, FriendshipImpl, ImageImpl, LocationImpl, MessageImpl, MiniProgramImpl, PostImpl, RoomImpl, RoomInvitationImpl, TagImpl, TagGroupImpl, UrlLinkImpl, ChannelImpl, MomentImpl, CallRecordImpl, ChatHistoryImpl, WecomImpl, wechatifyUserModule, } from '../user-modules/mod.js';
const wechatifyUserModuleMixin = (mixinBase) => {
log.verbose('WechatifyUserModuleMixin', 'wechatifyUserModuleMixin(%s)', mixinBase.name);
class WechatifyUserModuleMixin extends mixinBase {
constructor(...args) {
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() {
log.verbose('WechatifyUserModuleMixin', 'init()');
await super.init();
/**
* Skip if already wechatified
*/
if (this.__wechatifiedMessage) {
log.verbose('WechatifyUserModuleMixin', 'init() Wechaty User Module (WUM)s have already wechatified: skip');
return;
}
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 = wechatifyUserModule(ContactImpl)(this);
this.__wechatifiedContactSelf = wechatifyUserModule(ContactSelfImpl)(this);
this.__wechatifiedDelay = wechatifyUserModule(DelayImpl)(this);
this.__wechatifiedFriendship = wechatifyUserModule(FriendshipImpl)(this);
this.__wechatifiedImage = wechatifyUserModule(ImageImpl)(this);
this.__wechatifiedLocation = wechatifyUserModule(LocationImpl)(this);
this.__wechatifiedMessage = wechatifyUserModule(MessageImpl)(this);
this.__wechatifiedMiniProgram = wechatifyUserModule(MiniProgramImpl)(this);
this.__wechatifiedPost = wechatifyUserModule(PostImpl)(this);
this.__wechatifiedRoom = wechatifyUserModule(RoomImpl)(this);
this.__wechatifiedRoomInvitation = wechatifyUserModule(RoomInvitationImpl)(this);
this.__wechatifiedTag = wechatifyUserModule(TagImpl)(this);
this.__wechatifiedTagGroup = wechatifyUserModule(TagGroupImpl)(this);
this.__wechatifiedUrlLink = wechatifyUserModule(UrlLinkImpl)(this);
this.__wechatifiedChannel = wechatifyUserModule(ChannelImpl)(this);
this.__wechatifiedMoment = wechatifyUserModule(MomentImpl)(this);
this.__wechatifiedCallRecord = wechatifyUserModule(CallRecordImpl)(this);
this.__wechatifiedChatHistory = wechatifyUserModule(ChatHistoryImpl)(this);
this.__wechatifiedWecom = wechatifyUserModule(WecomImpl)(this);
log.verbose('WechatifyUserModuleMixin', 'init() initializing Wechaty User Module (WUM) ... done');
}
}
return 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()!');
}
export { wechatifyUserModuleMixin, };
//# sourceMappingURL=wechatify-user-module-mixin.js.map