@mtkruto/node 0.76.0 → 0.76.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.
Files changed (47) hide show
  1. package/esm/client/0_params.d.ts +4 -0
  2. package/esm/client/0_params.d.ts.map +1 -1
  3. package/esm/client/1_types.d.ts +4 -4
  4. package/esm/client/1_types.d.ts.map +1 -1
  5. package/esm/client/2_update_manager.d.ts +2 -1
  6. package/esm/client/2_update_manager.d.ts.map +1 -1
  7. package/esm/client/2_update_manager.js +11 -7
  8. package/esm/client/3_message_manager.d.ts.map +1 -1
  9. package/esm/client/3_message_manager.js +4 -9
  10. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  11. package/esm/client/4_callback_query_manager.js +2 -1
  12. package/esm/client/4_inline_query_manager.js +2 -2
  13. package/esm/client/5_client.d.ts +4 -4
  14. package/esm/client/5_client.d.ts.map +1 -1
  15. package/esm/client/5_client.js +5 -5
  16. package/esm/connection/1_connection_tcp.node.d.ts +1 -1
  17. package/esm/connection/1_connection_tcp.node.d.ts.map +1 -1
  18. package/esm/connection/1_connection_tcp.node.js +4 -1
  19. package/esm/connection/1_connection_web_socket.d.ts.map +1 -1
  20. package/esm/connection/1_connection_web_socket.js +3 -6
  21. package/esm/session/2_session_encrypted.js +4 -4
  22. package/esm/session/2_session_plain.js +2 -2
  23. package/esm/types/1_inline_keyboard_button.js +1 -1
  24. package/package.json +1 -1
  25. package/script/client/0_params.d.ts +4 -0
  26. package/script/client/0_params.d.ts.map +1 -1
  27. package/script/client/1_types.d.ts +4 -4
  28. package/script/client/1_types.d.ts.map +1 -1
  29. package/script/client/2_update_manager.d.ts +2 -1
  30. package/script/client/2_update_manager.d.ts.map +1 -1
  31. package/script/client/2_update_manager.js +11 -7
  32. package/script/client/3_message_manager.d.ts.map +1 -1
  33. package/script/client/3_message_manager.js +4 -9
  34. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  35. package/script/client/4_callback_query_manager.js +2 -1
  36. package/script/client/4_inline_query_manager.js +1 -1
  37. package/script/client/5_client.d.ts +4 -4
  38. package/script/client/5_client.d.ts.map +1 -1
  39. package/script/client/5_client.js +5 -5
  40. package/script/connection/1_connection_tcp.node.d.ts +1 -1
  41. package/script/connection/1_connection_tcp.node.d.ts.map +1 -1
  42. package/script/connection/1_connection_tcp.node.js +4 -1
  43. package/script/connection/1_connection_web_socket.d.ts.map +1 -1
  44. package/script/connection/1_connection_web_socket.js +3 -6
  45. package/script/session/2_session_encrypted.js +4 -4
  46. package/script/session/2_session_plain.js +2 -2
  47. package/script/types/1_inline_keyboard_button.js +1 -1
@@ -186,7 +186,7 @@ class Client extends Composer {
186
186
  this.systemLangCode = params?.systemLangCode ?? _4_constants_js_1.SYSTEM_LANG_CODE;
187
187
  this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
188
188
  this.#publicKeys = params?.publicKeys;
189
- this.#outgoingMessages = params?.outgoingMessages ?? null;
189
+ this.#outgoingMessages = params?.outgoingMessages ?? false;
190
190
  if (params?.prefixes) {
191
191
  this.prefixes = params?.prefixes;
192
192
  }
@@ -1223,7 +1223,7 @@ class Client extends Composer {
1223
1223
  }
1224
1224
  async #invoke(function_, params) {
1225
1225
  if (!this.#client) {
1226
- throw new _0_errors_js_1.ConnectionError("Not connected.");
1226
+ throw new _0_errors_js_1.ConnectionError("The connection is not open.");
1227
1227
  }
1228
1228
  let n = 1;
1229
1229
  let client;
@@ -1329,7 +1329,7 @@ class Client extends Composer {
1329
1329
  }
1330
1330
  }
1331
1331
  if ((_2_tl_js_1.Api.is("inputPeerUser", inputPeer) || _2_tl_js_1.Api.is("inputPeerChannel", inputPeer)) && inputPeer.access_hash === 0n) {
1332
- throw new _0_errors_js_1.AccessError(`Cannot access the chat ${id} because there is no access hash for it.`);
1332
+ throw new _0_errors_js_1.AccessError(`The chat ${id} cannot be accessed.`);
1333
1333
  }
1334
1334
  return inputPeer;
1335
1335
  }
@@ -2697,8 +2697,8 @@ class Client extends Composer {
2697
2697
  * @method ch
2698
2698
  * @param chatId The identifier of a chat to open.
2699
2699
  */
2700
- async openChat(chatId) {
2701
- await this.#updateManager.openChat(chatId);
2700
+ async openChat(chatId, params) {
2701
+ await this.#updateManager.openChat(chatId, params);
2702
2702
  }
2703
2703
  /**
2704
2704
  * Close a chat previously opened by openChat.
@@ -22,7 +22,7 @@ export declare class ConnectionTCP implements Connection {
22
22
  #private;
23
23
  stateChangeHandler?: Connection["stateChangeHandler"];
24
24
  constructor(hostname: string, port: number);
25
- open(): Promise<void>;
25
+ open(): Promise<void> | undefined;
26
26
  get connected(): boolean;
27
27
  read(p: Uint8Array): Promise<void>;
28
28
  write(p: Uint8Array): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"1_connection_tcp.node.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,aAAc,YAAW,UAAU;;IAW9C,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAY1C,IAAI;IAuCJ,IAAI,SAAS,YAEZ;IAQK,IAAI,CAAC,CAAC,EAAE,UAAU;IAclB,KAAK,CAAC,CAAC,EAAE,UAAU;IA0BzB,KAAK;CAKN"}
1
+ {"version":3,"file":"1_connection_tcp.node.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,aAAc,YAAW,UAAU;;IAW9C,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAY1C,IAAI;IA2CJ,IAAI,SAAS,YAEZ;IAQK,IAAI,CAAC,CAAC,EAAE,UAAU;IAclB,KAAK,CAAC,CAAC,EAAE,UAAU;IA0BzB,KAAK;CAKN"}
@@ -24,7 +24,7 @@ const node_net_1 = require("node:net");
24
24
  const _0_errors_js_1 = require("../0_errors.js");
25
25
  const _1_utilities_js_1 = require("../1_utilities.js");
26
26
  const L = (0, _1_utilities_js_1.getLogger)("ConnectionTCP");
27
- const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("Connection not open");
27
+ const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("The connection is not open.");
28
28
  class ConnectionTCP {
29
29
  #hostname;
30
30
  #port;
@@ -45,6 +45,9 @@ class ConnectionTCP {
45
45
  }
46
46
  }
47
47
  open() {
48
+ if (this.connected) {
49
+ return;
50
+ }
48
51
  this.#socket = new node_net_1.Socket();
49
52
  this.#socket.on("close", () => {
50
53
  this.#rejectRead();
@@ -1 +1 @@
1
- {"version":3,"file":"1_connection_web_socket.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_web_socket.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,mBAAoB,YAAW,UAAU;;IAOpD,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,GAAG,EAAE,MAAM;IA8CvB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,IAAI;IAuBJ,IAAI,CAAC,CAAC,EAAE,UAAU;IAgBlB,KAAK,CAAC,CAAC,EAAE,UAAU;IAkBzB,KAAK;CAMN"}
1
+ {"version":3,"file":"1_connection_web_socket.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_web_socket.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD,qBAAa,mBAAoB,YAAW,UAAU;;IAOpD,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;gBAE1C,GAAG,EAAE,MAAM;IA8CvB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAGK,IAAI;IAmBJ,IAAI,CAAC,CAAC,EAAE,UAAU;IAgBlB,KAAK,CAAC,CAAC,EAAE,UAAU;IAkBzB,KAAK;CAMN"}
@@ -58,7 +58,7 @@ const _0_deps_js_1 = require("../0_deps.js");
58
58
  const _0_errors_js_1 = require("../0_errors.js");
59
59
  const _1_utilities_js_1 = require("../1_utilities.js");
60
60
  const L = (0, _1_utilities_js_1.getLogger)("ConnectionWebSocket");
61
- const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("Connection not open");
61
+ const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("The connection is not open.");
62
62
  class ConnectionWebSocket {
63
63
  #url;
64
64
  #webSocket;
@@ -98,7 +98,7 @@ class ConnectionWebSocket {
98
98
  });
99
99
  webSocket.addEventListener("error", (err) => {
100
100
  if (this.#isConnecting) {
101
- reject("message" in err ? new _0_errors_js_1.ConnectionError(err.message) : new _0_errors_js_1.ConnectionError("Connection failed"));
101
+ reject("message" in err ? new _0_errors_js_1.ConnectionError(err.message) : new _0_errors_js_1.ConnectionError("Failed to connect."));
102
102
  }
103
103
  if (this.connected) {
104
104
  L.error(err);
@@ -112,12 +112,9 @@ class ConnectionWebSocket {
112
112
  #isConnecting = false;
113
113
  async open() {
114
114
  if (this.#isConnecting) {
115
- throw new _0_errors_js_1.ConnectionError("Already connecting");
115
+ return;
116
116
  }
117
117
  this.#isConnecting = true;
118
- if (this.connected) {
119
- throw new _0_errors_js_1.ConnectionError("Already connected");
120
- }
121
118
  try {
122
119
  this.#webSocket = await this.#initWs();
123
120
  }
@@ -66,7 +66,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
66
66
  }
67
67
  async connect() {
68
68
  if (!this.connected) {
69
- this.#rejectAllPending(new _0_errors_js_1.ConnectionError("Not connected."));
69
+ this.#rejectAllPending(new _0_errors_js_1.ConnectionError("The connection was closed."));
70
70
  }
71
71
  await super.connect();
72
72
  if (!SessionEncrypted.#TGCRYPTO_INITED) {
@@ -84,11 +84,11 @@ class SessionEncrypted extends _1_session_js_1.Session {
84
84
  this.#id = (0, _1_utilities_js_1.getRandomId)();
85
85
  this.#pingLoop.abort();
86
86
  this.#awakeSendLoop?.();
87
- this.#rejectAllPending(new _0_errors_js_1.ConnectionError("Not connected."));
87
+ this.#rejectAllPending(new _0_errors_js_1.ConnectionError("The connection was disconnected."));
88
88
  }
89
89
  #assertNotDisconnected() {
90
90
  if (this.disconnected) {
91
- throw new _0_errors_js_1.ConnectionError("Not connected.");
91
+ throw new _0_errors_js_1.ConnectionError("The connection was disconnected.");
92
92
  }
93
93
  }
94
94
  async #invalidateSession(reason) {
@@ -97,7 +97,7 @@ class SessionEncrypted extends _1_session_js_1.Session {
97
97
  this.state.reset();
98
98
  this.disconnect();
99
99
  await this.connect();
100
- this.#rejectAllPending(new _0_session_error_js_1.SessionError("Session invalidated."));
100
+ this.#rejectAllPending(new _0_session_error_js_1.SessionError("The session was invalidated."));
101
101
  }
102
102
  #rejectAllPending(reason) {
103
103
  for (const id of this.#sentMessages) {
@@ -28,7 +28,7 @@ const _1_session_js_1 = require("./1_session.js");
28
28
  class SessionPlain extends _1_session_js_1.Session {
29
29
  async send(data) {
30
30
  if (!this.connected) {
31
- throw new _0_errors_js_1.ConnectionError("Not connected.");
31
+ throw new _0_errors_js_1.ConnectionError("The connection is not open.");
32
32
  }
33
33
  const messageId = this.state.nextMessageId();
34
34
  const writer = new _1_tl_writer_js_1.TLWriter();
@@ -42,7 +42,7 @@ class SessionPlain extends _1_session_js_1.Session {
42
42
  }
43
43
  async receive() {
44
44
  if (!this.connected) {
45
- throw new _0_errors_js_1.ConnectionError("Not connected.");
45
+ throw new _0_errors_js_1.ConnectionError("The connection is not open.");
46
46
  }
47
47
  const buffer = await this.transport.transport.receive();
48
48
  if (buffer.length === 4) {
@@ -93,7 +93,7 @@ async function inlineKeyboardButtonToTlObject(button, usernameResolver) {
93
93
  const peerTypes = new Array();
94
94
  const { allowUsers, allowBots, allowGroups, allowChannels } = button.switchInlineQueryChosenChats;
95
95
  if (!allowUsers && !allowBots && !allowGroups && !allowChannels) {
96
- throw new _0_errors_js_1.InputError("switchInlineQueryChosenChats: At least one chat type must be allowed");
96
+ throw new _0_errors_js_1.InputError("switchInlineQueryChosenChats: At least one chat type must be allowed.");
97
97
  }
98
98
  if (allowUsers) {
99
99
  peerTypes.push({ _: "inlineQueryPeerTypeBotPM" });