chz-telegram-bot 0.0.51 → 0.0.52
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/dtos/commandTriggerCheckResult.d.ts +5 -5
- package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -1
- package/dist/dtos/commandTriggerCheckResult.js +3 -6
- package/dist/dtos/incomingMessage.d.ts +6 -6
- package/dist/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.d.ts +1 -0
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +38 -37
- package/dist/entities/actions/scheduledAction.d.ts +1 -1
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +12 -16
- package/dist/entities/botInstance.d.ts +11 -3
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +24 -17
- package/dist/entities/context/chatContext.d.ts +10 -10
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +5 -12
- package/dist/entities/context/messageContext.d.ts +4 -2
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +4 -4
- package/dist/helpers/noop.d.ts +4 -2
- package/dist/helpers/noop.d.ts.map +1 -1
- package/dist/helpers/noop.js +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.d.ts +10 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -11
- package/dist/services/jsonFileStorage.d.ts +1 -2
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/jsonFileStorage.js +3 -5
- package/dist/services/jsonLogger.d.ts +8 -0
- package/dist/services/jsonLogger.d.ts.map +1 -0
- package/dist/services/jsonLogger.js +28 -0
- package/dist/services/nodeTimeoutScheduler.d.ts +13 -0
- package/dist/services/nodeTimeoutScheduler.d.ts.map +1 -0
- package/dist/services/nodeTimeoutScheduler.js +33 -0
- package/dist/services/telegramApi.d.ts +7 -5
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +4 -4
- package/dist/types/commandCondition.d.ts +1 -1
- package/dist/types/commandCondition.d.ts.map +1 -1
- package/dist/types/logger.d.ts +6 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +2 -0
- package/dist/types/scheduler.d.ts +7 -0
- package/dist/types/scheduler.d.ts.map +1 -0
- package/dist/types/scheduler.js +2 -0
- package/dist/types/storage.d.ts +1 -2
- package/dist/types/storage.d.ts.map +1 -1
- package/dtos/commandTriggerCheckResult.ts +10 -10
- package/dtos/incomingMessage.ts +6 -6
- package/entities/actions/commandAction.ts +48 -41
- package/entities/actions/scheduledAction.ts +28 -31
- package/entities/botInstance.ts +50 -32
- package/entities/context/chatContext.ts +20 -16
- package/entities/context/messageContext.ts +10 -6
- package/helpers/noop.ts +5 -2
- package/index.ts +3 -1
- package/main.ts +16 -15
- package/package.json +1 -1
- package/services/jsonFileStorage.ts +4 -6
- package/services/{logger.ts → jsonLogger.ts} +3 -3
- package/services/{taskScheduler.ts → nodeTimeoutScheduler.ts} +11 -7
- package/services/telegramApi.ts +15 -8
- package/types/commandCondition.ts +1 -1
- package/types/logger.ts +24 -0
- package/types/scheduler.ts +20 -0
- package/types/storage.ts +1 -2
- package/dtos/actionExecutionResult.ts +0 -11
package/types/logger.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ILogger {
|
|
2
|
+
logObjectWithTraceId(
|
|
3
|
+
botName: string,
|
|
4
|
+
traceId: string | number,
|
|
5
|
+
chatName: string,
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
data: any
|
|
8
|
+
): void;
|
|
9
|
+
|
|
10
|
+
logWithTraceId(
|
|
11
|
+
botName: string,
|
|
12
|
+
traceId: string | number,
|
|
13
|
+
chatName: string,
|
|
14
|
+
text: string
|
|
15
|
+
): void;
|
|
16
|
+
|
|
17
|
+
errorWithTraceId<TData>(
|
|
18
|
+
botName: string,
|
|
19
|
+
traceId: string | number,
|
|
20
|
+
chatName: string,
|
|
21
|
+
errorObj: unknown,
|
|
22
|
+
extraData?: TData | undefined
|
|
23
|
+
): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Milliseconds } from './timeValues';
|
|
2
|
+
|
|
3
|
+
export interface IScheduler {
|
|
4
|
+
stopAll(): void;
|
|
5
|
+
|
|
6
|
+
createTask(
|
|
7
|
+
name: string,
|
|
8
|
+
action: () => void,
|
|
9
|
+
interval: Milliseconds,
|
|
10
|
+
executeRightAway: boolean,
|
|
11
|
+
ownerName: string
|
|
12
|
+
): void;
|
|
13
|
+
|
|
14
|
+
createOnetimeTask(
|
|
15
|
+
name: string,
|
|
16
|
+
action: () => void,
|
|
17
|
+
delay: Milliseconds,
|
|
18
|
+
ownerName: string
|
|
19
|
+
): void;
|
|
20
|
+
}
|
package/types/storage.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ActionExecutionResult } from '../dtos/actionExecutionResult';
|
|
2
1
|
import { IActionState } from './actionState';
|
|
3
2
|
import { ActionKey, IActionWithState } from './actionWithState';
|
|
4
3
|
|
|
@@ -23,6 +22,6 @@ export interface IStorageClient {
|
|
|
23
22
|
saveActionExecutionResult<TActionState extends IActionState>(
|
|
24
23
|
action: IActionWithState<TActionState>,
|
|
25
24
|
chatId: number,
|
|
26
|
-
|
|
25
|
+
state: TActionState
|
|
27
26
|
): Promise<void>;
|
|
28
27
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IActionState } from '../types/actionState';
|
|
2
|
-
|
|
3
|
-
export class ActionExecutionResult<TActionState extends IActionState> {
|
|
4
|
-
readonly data: TActionState;
|
|
5
|
-
readonly shouldUpdate: boolean;
|
|
6
|
-
|
|
7
|
-
constructor(data: TActionState, shouldUpdate: boolean) {
|
|
8
|
-
this.data = data;
|
|
9
|
-
this.shouldUpdate = shouldUpdate;
|
|
10
|
-
}
|
|
11
|
-
}
|