wx2tg-puppet 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/config.entity.d.ts +1 -0
- package/dist/entities/config.entity.js +4 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +24 -0
- package/dist/services/config.service.d.ts +1 -0
- package/dist/services/config.service.js +5 -0
- package/dist/services/contact.service.d.ts +1 -0
- package/dist/services/contact.service.js +5 -0
- package/dist/services/message.service.d.ts +1 -0
- package/dist/services/message.service.js +5 -0
- package/dist/services/room.service.d.ts +1 -0
- package/dist/services/room.service.js +5 -0
- package/package.json +1 -1
|
@@ -34,6 +34,10 @@ __decorate([
|
|
|
34
34
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
35
35
|
__metadata("design:type", String)
|
|
36
36
|
], Config.prototype, "DeviceName", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], Config.prototype, "DeviceType", void 0);
|
|
37
41
|
exports.Config = Config = __decorate([
|
|
38
42
|
(0, typeorm_1.Entity)()
|
|
39
43
|
], Config);
|
package/dist/index.d.ts
CHANGED
|
@@ -32,8 +32,12 @@ export declare class WxBot extends EventEmitter {
|
|
|
32
32
|
private checkLoginStatus;
|
|
33
33
|
info(): Promise<Contact | null>;
|
|
34
34
|
private clearAllIntervals;
|
|
35
|
-
loginSuccess
|
|
35
|
+
private loginSuccess;
|
|
36
36
|
private logOut;
|
|
37
|
+
/**
|
|
38
|
+
* 清空登录信息
|
|
39
|
+
*/
|
|
40
|
+
clearCache(): Promise<void>;
|
|
37
41
|
login(): Promise<void>;
|
|
38
42
|
start(): Promise<void>;
|
|
39
43
|
static get Contact(): typeof Contact;
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@ const MessageType_1 = require("./type/MessageType");
|
|
|
41
41
|
const Friendship_1 = require("./core/Friendship");
|
|
42
42
|
const UserApi_1 = require("./api/UserApi");
|
|
43
43
|
const ContactEntity_1 = require("./entities/ContactEntity");
|
|
44
|
+
const room_service_1 = require("./services/room.service");
|
|
45
|
+
const message_service_1 = require("./services/message.service");
|
|
44
46
|
class WxBot extends events_1.EventEmitter {
|
|
45
47
|
constructor({ baseUrl, databasePath, deviceType = 'ipad' }) {
|
|
46
48
|
super();
|
|
@@ -70,6 +72,11 @@ class WxBot extends events_1.EventEmitter {
|
|
|
70
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
73
|
try {
|
|
72
74
|
const config = yield config_service_1.configService.get();
|
|
75
|
+
if (config && config.DeviceType !== this.deviceType) {
|
|
76
|
+
yield this.clearCache();
|
|
77
|
+
config.deviceId = "";
|
|
78
|
+
config.DeviceName = "";
|
|
79
|
+
}
|
|
73
80
|
let response;
|
|
74
81
|
// 根据 deviceType 调用不同接口
|
|
75
82
|
switch (this.deviceType) {
|
|
@@ -253,6 +260,7 @@ class WxBot extends events_1.EventEmitter {
|
|
|
253
260
|
yield config_service_1.configService.save({
|
|
254
261
|
deviceId: cacheInfo.data.Data.Deviceid_str,
|
|
255
262
|
DeviceName: cacheInfo.data.Data.DeviceName,
|
|
263
|
+
DeviceType: this.deviceType,
|
|
256
264
|
});
|
|
257
265
|
}
|
|
258
266
|
// 获取详情
|
|
@@ -365,6 +373,22 @@ class WxBot extends events_1.EventEmitter {
|
|
|
365
373
|
this.emit('logout');
|
|
366
374
|
});
|
|
367
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* 清空登录信息
|
|
378
|
+
*/
|
|
379
|
+
clearCache() {
|
|
380
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
381
|
+
this.logOut();
|
|
382
|
+
const config = yield config_service_1.configService.get();
|
|
383
|
+
if (config) {
|
|
384
|
+
const res = yield LoginApi_1.loginApi.LogOut(config.wxid);
|
|
385
|
+
}
|
|
386
|
+
config_service_1.configService.clear();
|
|
387
|
+
room_service_1.roomService.clear();
|
|
388
|
+
contact_service_1.contactService.clear();
|
|
389
|
+
message_service_1.messageService.clear();
|
|
390
|
+
});
|
|
391
|
+
}
|
|
368
392
|
login() {
|
|
369
393
|
return __awaiter(this, void 0, void 0, function* () {
|
|
370
394
|
this.clearAllIntervals(); // 确保清理所有定时器
|
|
@@ -6,6 +6,7 @@ declare class ContactService {
|
|
|
6
6
|
save(contact: Partial<ContactEntity>): Promise<ContactEntity>;
|
|
7
7
|
update(userName: string, update: Partial<ContactEntity>): Promise<ContactEntity | null>;
|
|
8
8
|
clearRoom(): Promise<void>;
|
|
9
|
+
clear(): Promise<void>;
|
|
9
10
|
upsertByUsername(userName: string, data: Partial<ContactEntity>): Promise<ContactEntity>;
|
|
10
11
|
delete(userName: string): Promise<boolean>;
|
|
11
12
|
searchByNickNameOrRemark(keyword: string): Promise<ContactEntity[]>;
|
|
@@ -49,6 +49,11 @@ class ContactService {
|
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
clear() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
yield this.repo.clear();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
52
57
|
upsertByUsername(userName, data) {
|
|
53
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
59
|
let contact = yield this.getByUserName(userName);
|
|
@@ -7,6 +7,7 @@ declare class MessageService {
|
|
|
7
7
|
update(MsgId: number, update: Partial<MessageEntity>): Promise<MessageEntity | null>;
|
|
8
8
|
upsertByMsgId(MsgId: number, data: Partial<MessageEntity>): Promise<MessageEntity>;
|
|
9
9
|
delete(MsgId: number): Promise<boolean>;
|
|
10
|
+
clear(): Promise<void>;
|
|
10
11
|
}
|
|
11
12
|
export declare const messageService: MessageService;
|
|
12
13
|
export {};
|
|
@@ -7,6 +7,7 @@ declare class RoomService {
|
|
|
7
7
|
update(chatroomId: string, update: Partial<RoomEntity>): Promise<RoomEntity | null>;
|
|
8
8
|
upsertByChatroomId(chatroomId: string, data: Partial<RoomEntity>): Promise<RoomEntity>;
|
|
9
9
|
delete(chatroomId: string): Promise<boolean>;
|
|
10
|
+
clear(): Promise<void>;
|
|
10
11
|
}
|
|
11
12
|
export declare const roomService: RoomService;
|
|
12
13
|
export {};
|