chz-telegram-bot 0.3.0 → 0.3.1

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.
@@ -58,7 +58,7 @@ class CommandAction {
58
58
  const onCooldown = (0, moment_1.default)().diff(lastExecutedDate) < cooldownInMilliseconds;
59
59
  if (onCooldown)
60
60
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger;
61
- const isCustomConditionMet = this.condition(ctx);
61
+ const isCustomConditionMet = this.condition(ctx, state);
62
62
  if (!isCustomConditionMet)
63
63
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
64
64
  return this.checkTrigger(ctx, trigger);
@@ -1,4 +1,4 @@
1
1
  import { MessageContext } from '../entities/context/messageContext';
2
2
  import { IActionState } from './actionState';
3
- export type CommandCondition<TActionState extends IActionState> = (ctx: MessageContext<TActionState>) => boolean;
3
+ export type CommandCondition<TActionState extends IActionState> = (ctx: MessageContext<TActionState>, state: TActionState) => boolean;
4
4
  //# sourceMappingURL=commandCondition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandCondition.d.ts","sourceRoot":"","sources":["../../types/commandCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI,CAC9D,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC,KAChC,OAAO,CAAC"}
1
+ {"version":3,"file":"commandCondition.d.ts","sourceRoot":"","sources":["../../types/commandCondition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI,CAC9D,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC,EACjC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC"}
@@ -105,7 +105,7 @@ export class CommandAction<TActionState extends IActionState>
105
105
  private checkIfShouldBeExecuted(
106
106
  ctx: MessageContext<TActionState>,
107
107
  trigger: CommandTrigger,
108
- state: IActionState
108
+ state: TActionState
109
109
  ) {
110
110
  if (!ctx.fromUserId)
111
111
  return CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
@@ -126,7 +126,7 @@ export class CommandAction<TActionState extends IActionState>
126
126
 
127
127
  if (onCooldown) return CommandTriggerCheckResult.DoNotTrigger;
128
128
 
129
- const isCustomConditionMet = this.condition(ctx);
129
+ const isCustomConditionMet = this.condition(ctx, state);
130
130
  if (!isCustomConditionMet)
131
131
  return CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
132
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chz-telegram-bot",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "async-sema": "^3.1.1",
@@ -2,5 +2,6 @@ import { MessageContext } from '../entities/context/messageContext';
2
2
  import { IActionState } from './actionState';
3
3
 
4
4
  export type CommandCondition<TActionState extends IActionState> = (
5
- ctx: MessageContext<TActionState>
5
+ ctx: MessageContext<TActionState>,
6
+ state: TActionState
6
7
  ) => boolean;