@wabot-dev/framework 0.1.0-beta.70 → 0.1.0-beta.72
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.
|
@@ -3,12 +3,14 @@ import { injectable } from '../../../core/injection/index.js';
|
|
|
3
3
|
import * as readline from 'readline';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
+
import { Random } from '../../../core/random/Random.js';
|
|
6
7
|
|
|
7
8
|
var CmdChannel_1;
|
|
8
|
-
const
|
|
9
|
+
const chatIdPath = '.cmd-channel/id.json';
|
|
9
10
|
const authInfoPath = '.cmd-channel/auth-info.json';
|
|
10
11
|
let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
11
12
|
authInfo = undefined;
|
|
13
|
+
chatId = undefined;
|
|
12
14
|
rl = readline.createInterface({
|
|
13
15
|
input: process.stdin,
|
|
14
16
|
output: process.stdout,
|
|
@@ -28,8 +30,15 @@ let CmdChannel = CmdChannel_1 = class CmdChannel {
|
|
|
28
30
|
this.rl.close();
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
33
|
+
if (this.chatId === undefined) {
|
|
34
|
+
this.chatId = readJsonFromFile(chatIdPath) ?? undefined;
|
|
35
|
+
if (!this.chatId) {
|
|
36
|
+
this.chatId = Random.alphaNumericLowerCase(10);
|
|
37
|
+
writeJsonToFile(chatIdPath, this.chatId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
31
40
|
const chatConnection = {
|
|
32
|
-
id: chatId,
|
|
41
|
+
id: this.chatId,
|
|
33
42
|
chatType: 'PRIVATE',
|
|
34
43
|
channelName: CmdChannel_1.name,
|
|
35
44
|
};
|
|
@@ -16,6 +16,15 @@ let Auth = class Auth {
|
|
|
16
16
|
}
|
|
17
17
|
this.authInfo = authInfo;
|
|
18
18
|
}
|
|
19
|
+
override(authInfo) {
|
|
20
|
+
this.authInfo = authInfo;
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.authInfo = null;
|
|
24
|
+
}
|
|
25
|
+
isAssigned() {
|
|
26
|
+
return this.authInfo !== null;
|
|
27
|
+
}
|
|
19
28
|
};
|
|
20
29
|
Auth = __decorate([
|
|
21
30
|
scoped(Lifecycle.ContainerScoped)
|
package/dist/src/index.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ declare class Auth<D extends IStorableData> {
|
|
|
25
25
|
private authInfo;
|
|
26
26
|
require(): D;
|
|
27
27
|
assign(authInfo: D): void;
|
|
28
|
+
override(authInfo: D): void;
|
|
29
|
+
clear(): void;
|
|
30
|
+
isAssigned(): boolean;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
interface IEntityData extends IStorableData {
|
|
@@ -1265,6 +1268,7 @@ declare function cmd(): (target: object, propertyKey: string | symbol) => void;
|
|
|
1265
1268
|
|
|
1266
1269
|
declare class CmdChannel implements IChatChannel {
|
|
1267
1270
|
private authInfo;
|
|
1271
|
+
private chatId;
|
|
1268
1272
|
private rl;
|
|
1269
1273
|
private callBack;
|
|
1270
1274
|
listen(callback: (message: IChannelMessage) => void): void;
|