@futdevpro/nts-dynamo 1.11.22 → 1.11.24

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.
Files changed (55) hide show
  1. package/build/_collections/archive.util.js +2 -2
  2. package/build/_collections/archive.util.js.map +1 -1
  3. package/build/_collections/atlas-default-db-options.const.d.ts +0 -25
  4. package/build/_collections/atlas-default-db-options.const.d.ts.map +1 -1
  5. package/build/_collections/get-environment-settings.util.js +1 -2
  6. package/build/_collections/get-environment-settings.util.js.map +1 -1
  7. package/build/_models/control-models/app-params.control-model.d.ts +0 -25
  8. package/build/_models/control-models/app-params.control-model.d.ts.map +1 -1
  9. package/build/_models/interfaces/certification-settings.interface.d.ts +0 -1
  10. package/build/_models/interfaces/certification-settings.interface.d.ts.map +1 -1
  11. package/build/_modules/custom-data/get-custom-data-routing-module.util.js +1 -2
  12. package/build/_modules/custom-data/get-custom-data-routing-module.util.js.map +1 -1
  13. package/build/_modules/discord-assistant/_collections/dias.util.d.ts +19 -3
  14. package/build/_modules/discord-assistant/_collections/dias.util.d.ts.map +1 -1
  15. package/build/_modules/discord-assistant/_collections/dias.util.js +19 -15
  16. package/build/_modules/discord-assistant/_collections/dias.util.js.map +1 -1
  17. package/build/_modules/discord-assistant/_services/dias-io.control-service.js +6 -2
  18. package/build/_modules/discord-assistant/_services/dias-io.control-service.js.map +1 -1
  19. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts +3 -1
  20. package/build/_modules/discord-assistant/_services/dias.service-base.d.ts.map +1 -1
  21. package/build/_modules/discord-assistant/_services/dias.service-base.js +10 -1
  22. package/build/_modules/discord-assistant/_services/dias.service-base.js.map +1 -1
  23. package/build/_modules/discord-bot/_services/dibo-io.control-service.d.ts.map +1 -1
  24. package/build/_modules/discord-bot/_services/dibo-io.control-service.js +6 -2
  25. package/build/_modules/discord-bot/_services/dibo-io.control-service.js.map +1 -1
  26. package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts +4 -2
  27. package/build/_modules/discord-bot/_services/dibo-main.control-service.d.ts.map +1 -1
  28. package/build/_modules/discord-bot/_services/dibo-main.control-service.js +60 -2
  29. package/build/_modules/discord-bot/_services/dibo-main.control-service.js.map +1 -1
  30. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts +2 -0
  31. package/build/_modules/discord-bot/_services/dibo-routines.control-service.d.ts.map +1 -1
  32. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js +5 -0
  33. package/build/_modules/discord-bot/_services/dibo-routines.control-service.js.map +1 -1
  34. package/build/_modules/mock/auth-service.mock.d.ts.map +1 -1
  35. package/build/_modules/oauth2/_services/oauth2.auth-service.d.ts.map +1 -1
  36. package/build/_modules/open-ai/_collections/oai-global-settings.const.js +1 -1
  37. package/build/_modules/open-ai/_collections/oai-global-settings.const.js.map +1 -1
  38. package/build/_modules/open-ai/_services/oai-llm-chat.service-base.d.ts.map +1 -1
  39. package/build/_modules/open-ai/_services/oai-llm.service-base.d.ts.map +1 -1
  40. package/build/_modules/open-ai/_services/oai-llm.service-base.js +4 -4
  41. package/build/_modules/open-ai/_services/oai-llm.service-base.js.map +1 -1
  42. package/build/_modules/test/get-test-routing-module.util.js +1 -2
  43. package/build/_modules/test/get-test-routing-module.util.js.map +1 -1
  44. package/build/_modules/usage/get-usage-routing-module.util.js +1 -2
  45. package/build/_modules/usage/get-usage-routing-module.util.js.map +1 -1
  46. package/build/_services/base/db.service.d.ts.map +1 -1
  47. package/build/_services/server/app.server.d.ts +0 -27
  48. package/build/_services/server/app.server.d.ts.map +1 -1
  49. package/package.json +5 -5
  50. package/src/_modules/discord-assistant/_collections/dias.util.ts +37 -28
  51. package/src/_modules/discord-assistant/_services/dias-io.control-service.ts +6 -6
  52. package/src/_modules/discord-assistant/_services/dias.service-base.ts +16 -1
  53. package/src/_modules/discord-bot/_services/dibo-io.control-service.ts +14 -4
  54. package/src/_modules/discord-bot/_services/dibo-main.control-service.ts +90 -2
  55. package/src/_modules/discord-bot/_services/dibo-routines.control-service.ts +7 -0
@@ -80,7 +80,9 @@ export abstract class DyNTS_DiBo_Main_ControlService extends DyNTS_SingletonServ
80
80
 
81
81
  protected debugLog = false;
82
82
 
83
- protected constructor() {
83
+ protected constructor(
84
+ dontSetupAutomatically?: boolean,
85
+ ) {
84
86
  super();
85
87
 
86
88
  DyNTS_global_settings.bot_settings ??= DyNTS_DiBo_global_settings;
@@ -101,7 +103,9 @@ export abstract class DyNTS_DiBo_Main_ControlService extends DyNTS_SingletonServ
101
103
  partials: DyNTS_global_settings.bot_settings.partials,
102
104
  })
103
105
 
104
- this.setup('system-init');
106
+ if (!dontSetupAutomatically) {
107
+ this.setup('system-init');
108
+ }
105
109
  }
106
110
 
107
111
  async setup(issuer: string): Promise<void> {
@@ -186,6 +190,7 @@ export abstract class DyNTS_DiBo_Main_ControlService extends DyNTS_SingletonServ
186
190
 
187
191
  //await Operations.reportIn(this._discordServer, this.client)
188
192
 
193
+ DyFM_Log.success('Discord Bot setup complete')
189
194
  resolve();
190
195
  });
191
196
 
@@ -241,6 +246,7 @@ export abstract class DyNTS_DiBo_Main_ControlService extends DyNTS_SingletonServ
241
246
  await this.routines_CS.start(issuer);
242
247
  await this.botIO_CS.start(issuer);
243
248
 
249
+ DyFM_Log.success('Discord Bot started')
244
250
  } catch (error) {
245
251
  throw new DyFM_Error({
246
252
  ...this.getDefaultErrorSettings('start', error, issuer),
@@ -277,6 +283,88 @@ export abstract class DyNTS_DiBo_Main_ControlService extends DyNTS_SingletonServ
277
283
 
278
284
  return this._channelsByNames[channelName];
279
285
  }
286
+
287
+ async sendMessageToChannelByName(
288
+ channelName: string,
289
+ message: string,
290
+ issuer: string,
291
+ ): Promise<Message> {
292
+ try {
293
+ const channel = await this.getChannelByName(channelName);
294
+
295
+ if (!channel) {
296
+ throw new DyFM_Error({
297
+ ...this.getDefaultErrorSettings(
298
+ 'sendMessageToChannelByName',
299
+ new Error('Channel not found'),
300
+ issuer
301
+ ),
302
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiBo-MCS-SMCN1`,
303
+ })
304
+ }
305
+
306
+ if (!channel.isTextBased()) {
307
+ throw new DyFM_Error({
308
+ ...this.getDefaultErrorSettings(
309
+ 'sendMessageToChannelByName',
310
+ new Error('Channel is not a text channel'),
311
+ issuer
312
+ ),
313
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiBo-MCS-SMCN2`,
314
+ })
315
+ }
316
+
317
+ return await channel.send(message);
318
+ } catch (error) {
319
+ throw new DyFM_Error({
320
+ ...this.getDefaultErrorSettings('sendMessageToChannelByName', error, issuer),
321
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiBo-MCS-SMCN0`,
322
+ })
323
+ }
324
+ }
325
+
326
+ async clearChannel(
327
+ channel: TextChannel,
328
+ issuer: string,
329
+ ): Promise<void> {
330
+ try {
331
+ DyFM_Log.testInfo('Clearing channel... ', channel.name);
332
+
333
+ let messages: Message[] = (await DyNTS_DiBo_Operations_Util.fetchAllMessagesWithPaging(channel)).map(
334
+ (message) => message,
335
+ );
336
+
337
+ while (messages.length) {
338
+ DyFM_Log.testInfo('Deleting next 1000 messages... ', messages.length);
339
+
340
+ await Promise.all(messages.map(message => {
341
+ return new Promise(async (resolve, reject) => {
342
+ await DyNTS_DiBo_Operations_Util.deleteMessage(message).catch((error) => {
343
+ DyFM_Log.error('Failed to delete message', error);
344
+ });
345
+ messages = messages.filter(m => m.id !== message.id);
346
+ DyFM_Log.success('Deleted message', message.content);
347
+ resolve(true);
348
+ });
349
+ }));
350
+
351
+ if (messages.length === 0) {
352
+ messages = (await DyNTS_DiBo_Operations_Util.fetchAllMessagesWithPaging(channel)).map(
353
+ (message) => message,
354
+ );
355
+ }
356
+ }
357
+
358
+ DyFM_Log.success('Deleted messages', messages.length);
359
+
360
+ channel.send('[SYSTEM|OPERATION|RESULT] Csatorna üzeneteinek törlése sikeresen befejeződött.');
361
+ } catch (error) {
362
+ throw new DyFM_Error({
363
+ ...this.getDefaultErrorSettings('clearChannel', error, issuer),
364
+ errorCode: `${DyNTS_global_settings.systemShortCodeName}|DyNTS-DiBo-MCS-CC0`,
365
+ })
366
+ }
367
+ }
280
368
  }
281
369
 
282
370
  /**
@@ -22,6 +22,11 @@ export abstract class DyNTS_DiBo_Routines_ControlService extends DyNTS_Singleton
22
22
  return this.mainDiscordBot_CS?.discordServer;
23
23
  }
24
24
 
25
+ private _routinesStarted: boolean;
26
+ get routinesStarted(): boolean {
27
+ return this._routinesStarted;
28
+ }
29
+
25
30
  protected constructor() {
26
31
  super();
27
32
 
@@ -43,6 +48,8 @@ export abstract class DyNTS_DiBo_Routines_ControlService extends DyNTS_Singleton
43
48
  async start(issuer: string): Promise<void> {
44
49
  try {
45
50
  await this.startRoutines(issuer);
51
+
52
+ this._routinesStarted = true;
46
53
  } catch (error) {
47
54
  throw new DyFM_Error({
48
55
  ...this.getDefaultErrorSettings('start', error, issuer),