@aracna/telegram-bot 1.9.12 → 1.9.14

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 (84) hide show
  1. package/builders/button.builder.d.ts +2 -2
  2. package/childs/add.d.ts +3 -3
  3. package/childs/answer.d.ts +3 -2
  4. package/childs/answer.js +3 -0
  5. package/childs/approve.d.ts +6 -0
  6. package/childs/approve.js +10 -0
  7. package/childs/ban.d.ts +4 -3
  8. package/childs/ban.js +5 -2
  9. package/childs/close.d.ts +7 -0
  10. package/childs/close.js +13 -0
  11. package/childs/copy.d.ts +7 -0
  12. package/childs/copy.js +13 -0
  13. package/childs/create.d.ts +7 -3
  14. package/childs/create.js +13 -4
  15. package/childs/decline.d.ts +6 -0
  16. package/childs/decline.js +10 -0
  17. package/childs/delete.d.ts +10 -5
  18. package/childs/delete.js +20 -8
  19. package/childs/download.d.ts +2 -3
  20. package/childs/edit.d.ts +9 -5
  21. package/childs/edit.js +19 -3
  22. package/childs/export.d.ts +3 -2
  23. package/childs/export.js +2 -2
  24. package/childs/forward.d.ts +4 -3
  25. package/childs/forward.js +5 -7
  26. package/childs/get.d.ts +22 -11
  27. package/childs/get.js +52 -16
  28. package/childs/hide.d.ts +6 -0
  29. package/childs/hide.js +10 -0
  30. package/childs/leave.d.ts +3 -2
  31. package/childs/leave.js +2 -2
  32. package/childs/log.d.ts +5 -0
  33. package/childs/log.js +10 -0
  34. package/childs/pin.d.ts +3 -3
  35. package/childs/pin.js +2 -2
  36. package/childs/polling.d.ts +1 -1
  37. package/childs/polling.js +1 -1
  38. package/childs/privates/send.private.d.ts +5 -4
  39. package/childs/privates/send.private.js +2 -2
  40. package/childs/promote.d.ts +3 -3
  41. package/childs/promote.js +2 -2
  42. package/childs/refund.d.ts +6 -0
  43. package/childs/refund.js +14 -0
  44. package/childs/reopen.d.ts +7 -0
  45. package/childs/reopen.js +13 -0
  46. package/childs/replace.d.ts +6 -0
  47. package/childs/replace.js +10 -0
  48. package/childs/restrict.d.ts +3 -3
  49. package/childs/restrict.js +1 -3
  50. package/childs/revoke.d.ts +6 -0
  51. package/childs/revoke.js +10 -0
  52. package/childs/send.d.ts +26 -25
  53. package/childs/send.js +22 -41
  54. package/childs/set.d.ts +24 -13
  55. package/childs/set.js +60 -22
  56. package/childs/stop.d.ts +3 -3
  57. package/childs/stop.js +2 -2
  58. package/childs/unban.d.ts +4 -2
  59. package/childs/unban.js +5 -2
  60. package/childs/unhide.d.ts +6 -0
  61. package/childs/unhide.js +10 -0
  62. package/childs/unpin.d.ts +6 -2
  63. package/childs/unpin.js +15 -2
  64. package/childs/upload.d.ts +3 -4
  65. package/childs/upload.js +2 -2
  66. package/childs/webhook.d.ts +5 -3
  67. package/childs/webhook.js +8 -2
  68. package/definitions/interfaces.d.ts +27 -15
  69. package/definitions/interfaces.js +0 -1
  70. package/definitions/types.d.ts +2 -2
  71. package/index.d.ts +367 -162
  72. package/modules/api.d.ts +1 -1
  73. package/modules/configuration.d.ts +1 -1
  74. package/modules/dummy.d.ts +1 -1
  75. package/modules/telegram.d.ts +27 -5
  76. package/modules/telegram.js +37 -4
  77. package/package.json +12 -12
  78. package/utils/callback.query.utils.d.ts +2 -2
  79. package/utils/command.utils.d.ts +2 -3
  80. package/utils/context.utils.d.ts +5 -5
  81. package/utils/context.utils.js +5 -5
  82. package/utils/inline.keyboard.utils.d.ts +1 -1
  83. package/utils/reply.to.message.utils.d.ts +3 -3
  84. package/utils/start.utils.d.ts +4 -4
package/modules/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FetchError, RequestMethod, RestAPI, RestApiConfig } from '@aracna/core';
1
+ import { type FetchError, type RequestMethod, RestAPI, type RestApiConfig } from '@aracna/core';
2
2
  export declare class API extends RestAPI {
3
3
  post<V, W, X = undefined>(path: string, body?: W, config?: RestApiConfig<void>): Promise<V | FetchError<X>>;
4
4
  transformBody<V>(method: RequestMethod, path: string, body: V, config: RestApiConfig<void>): Promise<FormData>;
@@ -1,4 +1,4 @@
1
- import { ConfigurationAPI, ConfigurationDefault, ConfigurationHandler } from '../definitions/interfaces';
1
+ import type { ConfigurationAPI, ConfigurationDefault, ConfigurationHandler } from '../definitions/interfaces';
2
2
  declare class ConfigurationBuilder {
3
3
  api: ConfigurationAPI;
4
4
  default: ConfigurationDefault;
@@ -1,4 +1,4 @@
1
- import { CallbackQueryBody, ConfigurationAPI, ConfigurationDefault, ConfigurationHandler, Handler, MessageBody } from '../definitions/interfaces';
1
+ import type { CallbackQueryBody, ConfigurationAPI, ConfigurationDefault, ConfigurationHandler, Handler, MessageBody } from '../definitions/interfaces';
2
2
  export declare class Dummy {
3
3
  static get callbackQueryBody(): CallbackQueryBody;
4
4
  static get configurationAPI(): ConfigurationAPI;
@@ -1,29 +1,40 @@
1
- import { BotCommand, CallbackQuery, ChatJoinRequest, ChatMemberUpdated, ChosenInlineResult, InlineQuery, Message, Poll, PollAnswer, PreCheckoutQuery, ShippingQuery, Update } from '@aracna/telegram-bot-types';
1
+ import type { BotCommand, CallbackQuery, ChatJoinRequest, ChatMemberUpdated, ChosenInlineResult, InlineQuery, Message, Poll, PollAnswer, PreCheckoutQuery, ShippingQuery, Update } from '@aracna/telegram-bot-types';
2
2
  import { Add } from '../childs/add';
3
3
  import { Answer } from '../childs/answer';
4
+ import { Approve } from '../childs/approve';
4
5
  import { Ban } from '../childs/ban';
6
+ import { Close } from '../childs/close';
7
+ import { Copy } from '../childs/copy';
5
8
  import { Create } from '../childs/create';
9
+ import { Decline } from '../childs/decline';
6
10
  import { Delete } from '../childs/delete';
7
11
  import { Download } from '../childs/download';
8
12
  import { Edit } from '../childs/edit';
9
13
  import { Export } from '../childs/export';
10
14
  import { Forward } from '../childs/forward';
11
15
  import { Get } from '../childs/get';
16
+ import { Hide } from '../childs/hide';
12
17
  import { Leave } from '../childs/leave';
18
+ import { Log } from '../childs/log';
13
19
  import { Pin } from '../childs/pin';
14
20
  import { Polling } from '../childs/polling';
15
21
  import { Promote } from '../childs/promote';
22
+ import { Refund } from '../childs/refund';
23
+ import { Reopen } from '../childs/reopen';
24
+ import { Replace } from '../childs/replace';
16
25
  import { Restrict } from '../childs/restrict';
26
+ import { Revoke } from '../childs/revoke';
17
27
  import { Send } from '../childs/send';
18
28
  import { Set } from '../childs/set';
19
29
  import { Stop } from '../childs/stop';
20
30
  import { Unban } from '../childs/unban';
31
+ import { Unhide } from '../childs/unhide';
21
32
  import { Unpin } from '../childs/unpin';
22
33
  import { Upload } from '../childs/upload';
23
34
  import { Webhook } from '../childs/webhook';
24
35
  import { UpdateType } from '../definitions/enums';
25
- import { Handler, HandlerOptions, TelegramName } from '../definitions/interfaces';
26
- import { HandlerMiddleware } from '../definitions/types';
36
+ import type { Handler, HandlerOptions, TelegramName } from '../definitions/interfaces';
37
+ import type { HandlerMiddleware } from '../definitions/types';
27
38
  import { API } from './api';
28
39
  import { Builder } from './builder';
29
40
  export declare class Telegram {
@@ -31,7 +42,7 @@ export declare class Telegram {
31
42
  api: API;
32
43
  handlers: Handler[];
33
44
  hostname: string;
34
- id: number;
45
+ id: bigint;
35
46
  name: TelegramName;
36
47
  port: number;
37
48
  token: string;
@@ -41,23 +52,34 @@ export declare class Telegram {
41
52
  /** CHILDS */
42
53
  add: Add;
43
54
  answer: Answer;
55
+ approve: Approve;
56
+ ban: Ban;
57
+ close: Close;
58
+ copy: Copy;
44
59
  create: Create;
60
+ decline: Decline;
45
61
  delete: Delete;
46
62
  download: Download;
47
63
  edit: Edit;
48
64
  export: Export;
49
65
  forward: Forward;
50
66
  get: Get;
51
- ban: Ban;
67
+ hide: Hide;
52
68
  leave: Leave;
69
+ log: Log;
53
70
  pin: Pin;
54
71
  polling: Polling;
55
72
  promote: Promote;
73
+ refund: Refund;
74
+ reopen: Reopen;
75
+ replace: Replace;
56
76
  restrict: Restrict;
77
+ revoke: Revoke;
57
78
  send: Send;
58
79
  set: Set;
59
80
  stop: Stop;
60
81
  unban: Unban;
82
+ unhide: Unhide;
61
83
  unpin: Unpin;
62
84
  upload: Upload;
63
85
  webhook: Webhook;
@@ -4,23 +4,34 @@ exports.Telegram = void 0;
4
4
  const core_1 = require("@aracna/core");
5
5
  const add_1 = require("../childs/add");
6
6
  const answer_1 = require("../childs/answer");
7
+ const approve_1 = require("../childs/approve");
7
8
  const ban_1 = require("../childs/ban");
9
+ const close_1 = require("../childs/close");
10
+ const copy_1 = require("../childs/copy");
8
11
  const create_1 = require("../childs/create");
12
+ const decline_1 = require("../childs/decline");
9
13
  const delete_1 = require("../childs/delete");
10
14
  const download_1 = require("../childs/download");
11
15
  const edit_1 = require("../childs/edit");
12
16
  const export_1 = require("../childs/export");
13
17
  const forward_1 = require("../childs/forward");
14
18
  const get_1 = require("../childs/get");
19
+ const hide_1 = require("../childs/hide");
15
20
  const leave_1 = require("../childs/leave");
21
+ const log_1 = require("../childs/log");
16
22
  const pin_1 = require("../childs/pin");
17
23
  const polling_1 = require("../childs/polling");
18
24
  const promote_1 = require("../childs/promote");
25
+ const refund_1 = require("../childs/refund");
26
+ const reopen_1 = require("../childs/reopen");
27
+ const replace_1 = require("../childs/replace");
19
28
  const restrict_1 = require("../childs/restrict");
29
+ const revoke_1 = require("../childs/revoke");
20
30
  const send_1 = require("../childs/send");
21
31
  const set_1 = require("../childs/set");
22
32
  const stop_1 = require("../childs/stop");
23
33
  const unban_1 = require("../childs/unban");
34
+ const unhide_1 = require("../childs/unhide");
24
35
  const unpin_1 = require("../childs/unpin");
25
36
  const upload_1 = require("../childs/upload");
26
37
  const webhook_1 = require("../childs/webhook");
@@ -48,23 +59,34 @@ class Telegram {
48
59
  /** CHILDS */
49
60
  add;
50
61
  answer;
62
+ approve;
63
+ ban;
64
+ close;
65
+ copy;
51
66
  create;
67
+ decline;
52
68
  delete;
53
69
  download;
54
70
  edit;
55
71
  export;
56
72
  forward;
57
73
  get;
58
- ban;
74
+ hide;
59
75
  leave;
76
+ log;
60
77
  pin;
61
78
  polling;
62
79
  promote;
80
+ refund;
81
+ reopen;
82
+ replace;
63
83
  restrict;
84
+ revoke;
64
85
  send;
65
86
  set;
66
87
  stop;
67
88
  unban;
89
+ unhide;
68
90
  unpin;
69
91
  upload;
70
92
  webhook;
@@ -73,30 +95,41 @@ class Telegram {
73
95
  this.handlers = [];
74
96
  this.hostname = hostname;
75
97
  this.name = { first: '', last: '' };
76
- this.id = 0;
98
+ this.id = 0n;
77
99
  this.port = port;
78
100
  this.token = token;
79
101
  this.username = '';
80
102
  this.builder = new builder_1.Builder();
81
103
  this.add = new add_1.Add(this);
82
104
  this.answer = new answer_1.Answer(this);
105
+ this.approve = new approve_1.Approve(this);
106
+ this.ban = new ban_1.Ban(this);
107
+ this.close = new close_1.Close(this);
108
+ this.copy = new copy_1.Copy(this);
83
109
  this.create = new create_1.Create(this);
110
+ this.decline = new decline_1.Decline(this);
84
111
  this.delete = new delete_1.Delete(this);
85
112
  this.download = new download_1.Download(this);
86
113
  this.edit = new edit_1.Edit(this);
87
114
  this.export = new export_1.Export(this);
88
115
  this.forward = new forward_1.Forward(this);
89
116
  this.get = new get_1.Get(this);
90
- this.ban = new ban_1.Ban(this);
117
+ this.hide = new hide_1.Hide(this);
91
118
  this.leave = new leave_1.Leave(this);
119
+ this.log = new log_1.Log(this);
92
120
  this.pin = new pin_1.Pin(this);
93
121
  this.polling = new polling_1.Polling(this);
94
122
  this.promote = new promote_1.Promote(this);
123
+ this.refund = new refund_1.Refund(this);
124
+ this.reopen = new reopen_1.Reopen(this);
125
+ this.replace = new replace_1.Replace(this);
95
126
  this.restrict = new restrict_1.Restrict(this);
127
+ this.revoke = new revoke_1.Revoke(this);
96
128
  this.send = new send_1.Send(this);
97
129
  this.set = new set_1.Set(this);
98
130
  this.stop = new stop_1.Stop(this);
99
131
  this.unban = new unban_1.Unban(this);
132
+ this.unhide = new unhide_1.Unhide(this);
100
133
  this.unpin = new unpin_1.Unpin(this);
101
134
  this.upload = new upload_1.Upload(this);
102
135
  this.webhook = new webhook_1.Webhook(this);
@@ -339,7 +372,7 @@ class Telegram {
339
372
  return handler;
340
373
  handler.middleware(start);
341
374
  if (handler.id.length > 0 && handler.options.deleteOnMessageStart) {
342
- this.delete.message(body.chatID ? start.from?.id ?? 0 : start.chat.id, start.message_id);
375
+ this.delete.message(body.chatID ? start.from?.id ?? 0n : start.chat.id, start.message_id);
343
376
  }
344
377
  return handler;
345
378
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "author": "Dario Sechi",
3
3
  "devDependencies": {
4
- "@aracna/core": "^1.1.77",
5
- "@aracna/telegram-bot-types": "^1.2.10",
6
- "@microsoft/api-extractor": "^7.39.0",
7
- "@types/node": "^20.10.5",
8
- "@vitest/coverage-v8": "^1.1.0",
9
- "@vitest/ui": "^1.1.0",
10
- "dotenv": "^16.3.1",
11
- "fastify": "^4.25.1",
12
- "typescript": "^5.3.3",
13
- "vitest": "^1.1.0"
4
+ "@aracna/core": "^1.1.82",
5
+ "@aracna/telegram-bot-types": "^1.2.13",
6
+ "@microsoft/api-extractor": "^7.47.5",
7
+ "@types/node": "^22.2.0",
8
+ "@vitest/coverage-v8": "^2.0.5",
9
+ "@vitest/ui": "^2.0.5",
10
+ "dotenv": "^16.4.5",
11
+ "fastify": "^4.28.1",
12
+ "typescript": "^5.5.4",
13
+ "vitest": "^2.0.5"
14
14
  },
15
15
  "engines": {
16
16
  "node": ">=16",
@@ -27,10 +27,10 @@
27
27
  "directory": "dist"
28
28
  },
29
29
  "types": "index.d.ts",
30
- "version": "1.9.12",
30
+ "version": "1.9.14",
31
31
  "scripts": {
32
32
  "build": "rm -rf dist && pnpm tsc && pnpm api-extractor run --local",
33
- "prepublish": "pnpm test && pnpm build && pnpm version patch && cp LICENSE package.json README.md dist",
33
+ "prepublish": "pnpm test && pnpm build && cp LICENSE package.json README.md dist",
34
34
  "test": "vitest run"
35
35
  }
36
36
  }
@@ -1,5 +1,5 @@
1
- import { CallbackQueryBody } from '../definitions/interfaces';
1
+ import type { CallbackQueryBody } from '../definitions/interfaces';
2
2
  export declare class CallbackQueryUtils {
3
3
  static decodeBody<T>(data?: string): CallbackQueryBody<T>;
4
- static encodeBody<T>(data: T, type: string, chatID?: number): string;
4
+ static encodeBody<T>(data: T, type: string, chatID?: bigint): string;
5
5
  }
@@ -1,6 +1,5 @@
1
- /// <reference types="node" />
2
- import { Context } from 'vm';
3
- import { UpdateType } from '../definitions/enums';
1
+ import type { Context } from 'vm';
2
+ import type { UpdateType } from '../definitions/enums';
4
3
  export declare class CommandUtils {
5
4
  static getByContext<T extends UpdateType>(context: Context[T]): string;
6
5
  static get(string?: string): string;
@@ -1,11 +1,11 @@
1
- import { Chat, User } from '@aracna/telegram-bot-types';
2
- import { UpdateType } from '../definitions/enums';
3
- import { Context } from '../definitions/interfaces';
1
+ import type { Chat, User } from '@aracna/telegram-bot-types';
2
+ import type { UpdateType } from '../definitions/enums';
3
+ import type { Context } from '../definitions/interfaces';
4
4
  export declare class ContextUtils {
5
- static getChatID<T extends UpdateType>(context: Context[T]): number;
5
+ static getChatID<T extends UpdateType>(context: Context[T]): bigint;
6
6
  static getChatType<T extends UpdateType>(context: Context[T]): string;
7
7
  static getChat<T extends UpdateType>(context: Context[T]): Chat;
8
- static getUserID<T extends UpdateType>(context: Context[T]): number;
8
+ static getUserID<T extends UpdateType>(context: Context[T]): bigint;
9
9
  static getUserFirstName<T extends UpdateType>(context: Context[T]): string;
10
10
  static getUserLastName<T extends UpdateType>(context: Context[T]): string;
11
11
  static getUserUsername<T extends UpdateType>(context: Context[T]): string;
@@ -12,11 +12,11 @@ class ContextUtils {
12
12
  static getChat(context) {
13
13
  switch (true) {
14
14
  case (0, core_1.hasObjectProperty)(context, 'chat'):
15
- return (0, core_1.getObjectProperty)(context, 'chat', { id: 0, type: '' });
15
+ return (0, core_1.getObjectProperty)(context, 'chat', { id: 0n, type: '' });
16
16
  case (0, core_1.hasObjectProperty)(context, 'message.chat'):
17
- return (0, core_1.getObjectProperty)(context, 'chat', { id: 0, type: '' });
17
+ return (0, core_1.getObjectProperty)(context, 'chat', { id: 0n, type: '' });
18
18
  default:
19
- return { id: 0, type: '' };
19
+ return { id: 0n, type: '' };
20
20
  }
21
21
  }
22
22
  static getUserID(context) {
@@ -33,9 +33,9 @@ class ContextUtils {
33
33
  }
34
34
  static getUser(context) {
35
35
  if ((0, core_1.hasObjectProperty)(context, 'from')) {
36
- return (0, core_1.getObjectProperty)(context, 'from', { first_name: '', id: 0, is_bot: false, username: '' });
36
+ return (0, core_1.getObjectProperty)(context, 'from', { first_name: '', id: 0n, is_bot: false, username: '' });
37
37
  }
38
- return { first_name: '', id: 0, is_bot: false, username: '' };
38
+ return { first_name: '', id: 0n, is_bot: false, username: '' };
39
39
  }
40
40
  }
41
41
  exports.ContextUtils = ContextUtils;
@@ -1,4 +1,4 @@
1
- import { InlineKeyboardButton } from '@aracna/telegram-bot-types';
1
+ import type { InlineKeyboardButton } from '@aracna/telegram-bot-types';
2
2
  export declare class InlineKeyboardUtils {
3
3
  static getButtonsType(buttons: InlineKeyboardButton[]): string;
4
4
  }
@@ -1,6 +1,6 @@
1
- import { MessageEntity } from '@aracna/telegram-bot-types';
2
- import { MessageBody } from '../definitions/interfaces';
1
+ import type { MessageEntity } from '@aracna/telegram-bot-types';
2
+ import type { MessageBody } from '../definitions/interfaces';
3
3
  export declare class ReplyToMessageUtils {
4
4
  static decodeBody<T>(entities: MessageEntity[]): MessageBody<T>;
5
- static encodeBody<T>(data: T, type: string, chatID?: number): string;
5
+ static encodeBody<T>(data: T, type: string, chatID?: bigint): string;
6
6
  }
@@ -1,7 +1,7 @@
1
- import { MessageBody } from '../definitions/interfaces';
1
+ import type { MessageBody } from '../definitions/interfaces';
2
2
  export declare class StartUtils {
3
3
  static decodeBody<T>(text?: string): MessageBody<T>;
4
- static encodeBody<T>(data: T, type: string, chatID?: number): string;
5
- static encodeBodyToHREF<T>(username: string, data: T, type: string, chatID?: number): string;
6
- static encodeBodyToAnchorTag<T>(username: string, data: T, type: string, children: string, chatID?: number): string;
4
+ static encodeBody<T>(data: T, type: string, chatID?: bigint): string;
5
+ static encodeBodyToHREF<T>(username: string, data: T, type: string, chatID?: bigint): string;
6
+ static encodeBodyToAnchorTag<T>(username: string, data: T, type: string, children: string, chatID?: bigint): string;
7
7
  }