chz-telegram-bot 0.7.26 → 0.7.28

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.
@@ -10,15 +10,15 @@ declare const _SkipTriggerReasonsObject: {
10
10
  };
11
11
  export type SkipTriggerReasons = keyof typeof _SkipTriggerReasonsObject;
12
12
  export declare class CommandTriggerCheckResult {
13
- readonly shouldExecute: boolean;
14
- readonly matchResults: RegExpExecArray[];
15
- readonly skipCooldown: boolean;
16
- readonly reason?: SkipTriggerReasons | undefined;
13
+ shouldExecute: boolean;
14
+ matchResults: RegExpExecArray[];
15
+ skipCooldown: boolean;
16
+ reason?: SkipTriggerReasons | undefined;
17
17
  static DontTriggerAndSkipCooldown(reason: SkipTriggerReasons): CommandTriggerCheckResult;
18
18
  static DoNotTrigger(reason: SkipTriggerReasons): CommandTriggerCheckResult;
19
19
  static Trigger(): CommandTriggerCheckResult;
20
20
  constructor(shouldExecute: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean, reason?: SkipTriggerReasons | undefined);
21
- mergeWith(other: CommandTriggerCheckResult): CommandTriggerCheckResult;
21
+ mergeWith(other: CommandTriggerCheckResult): this;
22
22
  }
23
23
  export {};
24
24
  //# sourceMappingURL=commandTriggerCheckResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../src/dtos/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,yBAAyB;;;;;;;;;CASrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAExE,qBAAa,yBAAyB;IAY9B,QAAQ,CAAC,aAAa,EAAE,OAAO;IAC/B,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE;IACxC,QAAQ,CAAC,YAAY,EAAE,OAAO;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAdxC,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,kBAAkB;IAG5D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB;IAG9C,MAAM,CAAC,OAAO;gBAKD,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,MAAM,CAAC,EAAE,kBAAkB,YAAA;IAGxC,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAQ7C"}
1
+ {"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../src/dtos/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,yBAAyB;;;;;;;;;CASrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAExE,qBAAa,yBAAyB;IAYvB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,eAAe,EAAE;IAC/B,YAAY,EAAE,OAAO;IACrB,MAAM,CAAC,EAAE,kBAAkB;IAdtC,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,kBAAkB;IAG5D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB;IAG9C,MAAM,CAAC,OAAO;gBAKH,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,MAAM,CAAC,EAAE,kBAAkB,YAAA;IAGtC,SAAS,CAAC,KAAK,EAAE,yBAAyB,GAAG,IAAI;CAOpD"}
@@ -29,6 +29,10 @@ export class CommandTriggerCheckResult {
29
29
  this.reason = reason;
30
30
  }
31
31
  mergeWith(other) {
32
- return new CommandTriggerCheckResult(this.shouldExecute || other.shouldExecute, this.matchResults.concat(other.matchResults), this.skipCooldown || other.skipCooldown, other.reason);
32
+ this.shouldExecute = this.shouldExecute || other.shouldExecute;
33
+ this.matchResults.push(...other.matchResults);
34
+ this.skipCooldown = this.skipCooldown || other.skipCooldown;
35
+ this.reason = other.reason;
36
+ return this;
33
37
  }
34
38
  }
@@ -3,10 +3,14 @@ export declare class UserInfo {
3
3
  readonly id: number | null;
4
4
  /** Name of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
5
5
  readonly name: string;
6
+ /** User tag of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
7
+ readonly usertag: string;
6
8
  constructor(
7
9
  /** Id of a user that sent a message that triggered this action. `null` if the user is unknown. */
8
10
  id: number | null,
9
11
  /** Name of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
10
- name: string);
12
+ name: string,
13
+ /** User tag of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
14
+ usertag: string);
11
15
  }
12
16
  //# sourceMappingURL=userInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"userInfo.d.ts","sourceRoot":"","sources":["../../src/dtos/userInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IAEb,kGAAkG;IAClG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAC1B,4GAA4G;IAC5G,QAAQ,CAAC,IAAI,EAAE,MAAM;;IAHrB,kGAAkG;IACzF,EAAE,EAAE,MAAM,GAAG,IAAI;IAC1B,4GAA4G;IACnG,IAAI,EAAE,MAAM;CAE5B"}
1
+ {"version":3,"file":"userInfo.d.ts","sourceRoot":"","sources":["../../src/dtos/userInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IAEb,kGAAkG;IAClG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAC1B,4GAA4G;IAC5G,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,gHAAgH;IAChH,QAAQ,CAAC,OAAO,EAAE,MAAM;;IALxB,kGAAkG;IACzF,EAAE,EAAE,MAAM,GAAG,IAAI;IAC1B,4GAA4G;IACnG,IAAI,EAAE,MAAM;IACrB,gHAAgH;IACvG,OAAO,EAAE,MAAM;CAE/B"}
@@ -1,12 +1,16 @@
1
1
  export class UserInfo {
2
2
  id;
3
3
  name;
4
+ usertag;
4
5
  constructor(
5
6
  /** Id of a user that sent a message that triggered this action. `null` if the user is unknown. */
6
7
  id,
7
8
  /** Name of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
8
- name) {
9
+ name,
10
+ /** User tag of a user that sent a message that triggered this action. `Unknown user` if the user is unknown. */
11
+ usertag) {
9
12
  this.id = id;
10
13
  this.name = name;
14
+ this.usertag = usertag;
11
15
  }
12
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAO/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,qBAAa,aAAa,CACtB,YAAY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA8C;IACnF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyC;IAC1E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IACF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IACF,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IAEF,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,IAAI,E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AAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,sBAAsB,EACjC,gCAAgC,EAAE,MAAM,EACxC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY,EACpC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAyBxC,IAAI,CACN,GAAG,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAC1C,OAAO,CAAC,WAAW,EAAE,CAAC;IA6FzB,OAAO,CAAC,uBAAuB;IA6D/B,OAAO,CAAC,YAAY;CAwCvB"}
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  import { secondsToMilliseconds } from '../../helpers/timeConvertions';
3
2
  import { toArray } from '../../helpers/toArray';
4
3
  import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult';
@@ -52,9 +51,11 @@ export class CommandAction {
52
51
  }
53
52
  try {
54
53
  const state = ctx.storage.getActionState(this, ctx.chatInfo.id);
55
- const { shouldExecute, matchResults, skipCooldown, reason } = this.triggers
56
- .map((x) => this.checkIfShouldBeExecuted(ctx, x, state))
57
- .reduce((acc, curr) => acc.mergeWith(curr), CommandTriggerCheckResult.DoNotTrigger('Other'));
54
+ let triggerCheckResult = CommandTriggerCheckResult.DoNotTrigger('Other');
55
+ for (const trigger of this.triggers) {
56
+ triggerCheckResult = triggerCheckResult.mergeWith(this.checkIfShouldBeExecuted(ctx, trigger, state));
57
+ }
58
+ const { shouldExecute, matchResults, skipCooldown, reason } = triggerCheckResult;
58
59
  if (!shouldExecute) {
59
60
  if (reason == 'OnCooldown') {
60
61
  const cooldownMessage = this.cooldownInfoProvider(ctx).message;
@@ -79,7 +80,7 @@ export class CommandAction {
79
80
  }
80
81
  if (ctx.startCooldown) {
81
82
  this.lastCustomCooldown = ctx.customCooldown;
82
- state.lastExecutedDate = moment().valueOf();
83
+ state.lastExecutedDate = Date.now();
83
84
  }
84
85
  await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
85
86
  ctx.observability.eventEmitter.emit(BotEventType.commandActionExecuted, {
@@ -114,9 +115,9 @@ export class CommandAction {
114
115
  usersWhitelist.includes(ctx.userInfo.id);
115
116
  if (!isUserAllowed)
116
117
  return CommandTriggerCheckResult.DontTriggerAndSkipCooldown('UserForbidden');
117
- const lastExecutedDate = moment(state.lastExecutedDate);
118
+ const lastExecutedDate = state.lastExecutedDate;
118
119
  const cooldownInMilliseconds = secondsToMilliseconds(this.lastCustomCooldown ?? this.cooldownInfoProvider(ctx).cooldown);
119
- const onCooldown = moment().diff(lastExecutedDate) < cooldownInMilliseconds;
120
+ const onCooldown = Date.now() - lastExecutedDate < cooldownInMilliseconds;
120
121
  if (onCooldown)
121
122
  return CommandTriggerCheckResult.DoNotTrigger('OnCooldown');
122
123
  const isCustomConditionMet = this.condition(ctx, state);
@@ -1 +1 @@
1
- {"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/replyCaptureAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,qBAAa,kBAAkB,CAC3B,kBAAkB,SAAS,YAAY,CACzC,YAAW,OAAO;IAChB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CACd,YAAY,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,KACrD,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBA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8BxD,OAAO,CAAC,uBAAuB;CA4ClC"}
@@ -18,9 +18,11 @@ export class ReplyCaptureAction {
18
18
  .replace('.', '')}`;
19
19
  }
20
20
  async exec(ctx) {
21
- const { shouldExecute, matchResults } = this.triggers
22
- .map((x) => this.checkIfShouldBeExecuted(ctx, x))
23
- .reduce((acc, curr) => acc.mergeWith(curr), CommandTriggerCheckResult.DoNotTrigger('Other'));
21
+ let triggerCheckResult = CommandTriggerCheckResult.DoNotTrigger('Other');
22
+ for (const trigger of this.triggers) {
23
+ triggerCheckResult = triggerCheckResult.mergeWith(this.checkIfShouldBeExecuted(ctx, trigger));
24
+ }
25
+ const { shouldExecute, matchResults } = triggerCheckResult;
24
26
  if (!shouldExecute)
25
27
  return Noop.NoResponse;
26
28
  ctx.observability.eventEmitter.emit(BotEventType.replyActionExecuting, {
@@ -1 +1 @@
1
- {"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,qBAAa,eAAe,CACxB,YAAY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAgC;IACrD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,SAAS,CAA0B;IAE3E,QAAQ,CAAC,IAAI,EAAE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AY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAgC;IACrD,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,SAAS,CAA0B;IAE3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA8C;IAClF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA2C;IAC1E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAErC;IAEF,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG7C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACvC,SAAS,EAAE,wBAAwB,EACnC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAclC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,YAAY,CAAC;YAoDnC,cAAc;IA6D5B,OAAO,CAAC,uBAAuB;CAgBlC"}
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  import { Sema as Semaphore } from 'async-sema';
3
2
  import { hoursToMilliseconds } from '../../helpers/timeConvertions';
4
3
  import { Noop } from '../../helpers/noop';
@@ -41,7 +40,7 @@ export class ScheduledAction {
41
40
  traceId: ctx.observability.traceId
42
41
  });
43
42
  await this.handler(ctx, (key) => this.getCachedValue(key, ctx), state);
44
- state.lastExecutedDate = moment().valueOf();
43
+ state.lastExecutedDate = Date.now();
45
44
  await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
46
45
  ctx.observability.eventEmitter.emit(BotEventType.scheduledActionExecuted, {
47
46
  action: this,
@@ -82,14 +81,14 @@ export class ScheduledAction {
82
81
  }
83
82
  }
84
83
  checkIfShouldBeExecuted(state, ctx) {
85
- const startOfToday = moment().startOf('day').valueOf();
86
- const lastExecutedDate = moment(state.lastExecutedDate);
87
- const currentTime = moment();
88
- const scheduledTime = moment()
89
- .startOf('day')
90
- .add(this.timeinHoursProvider(ctx), 'hours');
91
- const isAllowedToTrigger = currentTime.isSameOrAfter(scheduledTime);
92
- const hasTriggeredToday = lastExecutedDate.isAfter(startOfToday);
84
+ const now = new Date();
85
+ const startOfToday = new Date(now).setHours(0, 0, 0, 0);
86
+ const lastExecutedDate = new Date(state.lastExecutedDate);
87
+ const currentTime = now;
88
+ const scheduledTime = new Date(new Date().setHours(0, 0, 0, 0));
89
+ scheduledTime.setTime(scheduledTime.getTime() + this.timeinHoursProvider(ctx) * 3600000);
90
+ const isAllowedToTrigger = currentTime >= scheduledTime;
91
+ const hasTriggeredToday = lastExecutedDate.getTime() > startOfToday;
93
92
  return isAllowedToTrigger && !hasTriggeredToday;
94
93
  }
95
94
  }
@@ -1 +1 @@
1
- {"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE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AAEF;;GAEG;AACH,qBAAa,sBAAsB,CAC/B,YAAY,SAAS,YAAY,CACnC,SAAQ,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACpE,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,yDAAyD;IACzD,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;gBAGlC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,EACnC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO;IA8BpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAgBtB,YAAY;IAIZ,mBAAmB,CAAC,cAAc,EAAE,OAAO;IAK3C;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;YAGxC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;;QAI5C;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM;QAExB;;;;;WAKG;0BACe,MAAM;QAExB;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
@@ -28,7 +28,9 @@ export class MessageContextInternal extends ChatContextInternal {
28
28
  super(storage, scheduler, eventEmitter, action, message.chatInfo, message.traceId, botName);
29
29
  this.messageInfo = new MessageInfo(message.messageId, message.text, message.type, message.updateObject);
30
30
  this.userInfo = new UserInfo(message.from?.id ?? null, (message.from?.first_name ?? 'Unknown user') +
31
- (message.from?.last_name ? ` ${message.from.last_name}` : ''));
31
+ (message.from?.last_name ? ` ${message.from.last_name}` : ''), message.from?.username
32
+ ? `@${message.from.username}`
33
+ : 'Unknown user');
32
34
  this.botInfo = botInfo;
33
35
  }
34
36
  replyWithText(text, quote, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACH,YAAY,EACZ,aAAa,EACb,OAAO,EACV,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,MAAM,MAAM,YAAY,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAC9D,oBAAoB,CAAC,YAAY,CAAC,EAChC,2BAA2B,GAC3B,WAAW,GACX,eAAe,GACf,gBAAgB,CACrB,CAAC;AAEF,qBAAa,oBAAoB,CAC7B,kBAAkB,SAAS,YAAY,CACzC,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,kBAAkB,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OAAO,CAAC,cAAc;IAgBtB;;OAEG;IACH,WAAW;IAIX;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAIvC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;YAIxC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;;QAK5C;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAG5D;;;;;WAKG;0BACe,MAAM;QAIxB;;;;;WAKG;0BACe,MAAM;QAIxB;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
@@ -24,7 +24,9 @@ export class ReplyContextInternal extends BaseContextInternal {
24
24
  this.replyMessageId = message.replyToMessageId;
25
25
  this.messageInfo = new MessageInfo(message.messageId, message.text, message.type, message.updateObject);
26
26
  this.userInfo = new UserInfo(message.from?.id ?? null, (message.from?.first_name ?? 'Unknown user') +
27
- (message.from?.last_name ? ` ${message.from.last_name}` : ''));
27
+ (message.from?.last_name ? ` ${message.from.last_name}` : ''), message.from?.username
28
+ ? `@${message.from.username}`
29
+ : 'Unknown user');
28
30
  this.botInfo = botInfo;
29
31
  }
30
32
  replyWithText(text, quote, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"scheduledActionProcessor.d.ts","sourceRoot":"","sources":["../../../src/services/actionProcessors/scheduledActionProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAIzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAgB,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EA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,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,iBAAiB;IAMnC,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,EAC1C,MAAM,EAAE,OAAO;YA+CL,YAAY;CA8C7B"}
@@ -1,4 +1,3 @@
1
- import moment from 'moment';
2
1
  import { ChatInfo } from '../../dtos/chatInfo';
3
2
  import { ChatContextInternal } from '../../entities/context/chatContext';
4
3
  import { secondsToMilliseconds } from '../../helpers/timeConvertions';
@@ -17,16 +16,17 @@ export class ScheduledActionProcessor extends BaseActionProcessor {
17
16
  this.initializeDependencies(api);
18
17
  this.scheduled = scheduled;
19
18
  if (this.scheduled.length > 0) {
20
- const now = moment();
21
- if (now.minute() == 0 && now.second() == 0) {
19
+ const now = new Date();
20
+ if (now.getMinutes() == 0 && now.getSeconds() == 0) {
22
21
  this.scheduler.createTask('ScheduledProcessing', () => void this.runScheduled(), secondsToMilliseconds(period), true, this.botName);
23
22
  return;
24
23
  }
25
- let nextExecutionTime = now.clone().startOf('hour');
26
- if (now.minute() > 0 || now.second() > 0) {
27
- nextExecutionTime = nextExecutionTime.add(1, 'hour');
24
+ let nextExecutionTime = new Date(now);
25
+ nextExecutionTime.setMinutes(0, 0, 0);
26
+ if (now.getMinutes() > 0 || now.getSeconds() > 0) {
27
+ nextExecutionTime = new Date(nextExecutionTime.getTime() + 3600000);
28
28
  }
29
- const delay = nextExecutionTime.diff(now);
29
+ const delay = nextExecutionTime.getTime() - now.getTime();
30
30
  this.scheduler.createOnetimeTask('ScheduledProcessing_OneTime', () => {
31
31
  this.scheduler.createTask('ScheduledProcessing', () => void this.runScheduled(), secondsToMilliseconds(period), true, this.botName);
32
32
  }, delay, this.botName);
package/package.json CHANGED
@@ -14,11 +14,10 @@
14
14
  "type": "git",
15
15
  "url": "https://github.com/AlexSolari/botFramework.git"
16
16
  },
17
- "version": "0.7.26",
17
+ "version": "0.7.28",
18
18
  "type": "module",
19
19
  "dependencies": {
20
20
  "async-sema": "^3.1.1",
21
- "moment": "^2.30.1",
22
21
  "telegraf": "^4.16.3"
23
22
  },
24
23
  "main": "dist/index.js",