rubika 1.2.4 → 1.2.5

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.
package/README.md CHANGED
@@ -48,7 +48,7 @@ bot.run();
48
48
  ## › نمونه کد ساده سلف (self)
49
49
 
50
50
  ```ts
51
- import Client from "rubika/bot";
51
+ import Client from "rubika/client";
52
52
 
53
53
  const shad_client = new Client("shad", "Shad");
54
54
  const rubika_client = new Client("rubika", "Rubika");
@@ -11,15 +11,13 @@ async function start(this: Bot, token?: string) {
11
11
  }
12
12
  }
13
13
 
14
- try {
15
- const res = await this.getMe();
16
- this.bot = res.bot;
17
-
18
- } catch (err) {
19
- await this.logger.error(`[start] error in token maby:${await err}`, "warn");
20
- return
14
+ const res = await this.getMe();
15
+
16
+ if (res.status_message === "INVALID_TOKEN") {
17
+ throw new Error("[start] parse invalid token");
21
18
  }
22
19
 
20
+ this.bot = res.bot;
23
21
  this.initialize = true;
24
22
  }
25
23
 
@@ -36,7 +36,7 @@ async function getBrowser(
36
36
  .match(/(opera|chrome|safari|firefox|msie|trident)\/(\d+)/);
37
37
 
38
38
  if (!deviceModelMatch) {
39
- throw logger.error(`Cannot parse user-agent (${userAgent})`, "error");
39
+ throw new Error(`Cannot parse user-agent (${userAgent})`);
40
40
  }
41
41
 
42
42
  const deviceModel = `${deviceModelMatch[1]} ${deviceModelMatch[2]}`;
@@ -21,11 +21,13 @@ async function start(this: Client): Promise<void> {
21
21
  this.key = Buffer.from(Crypto.passphrase(this.auth), "utf8");
22
22
  this.decode_auth = Crypto.decode_auth(this.auth);
23
23
  const result = await this.getUserInfo();
24
+ console.log(result);
25
+
24
26
  this.userGuid = result.user.user_guid;
25
27
  this.initialize = true;
26
28
  } catch {
27
29
  let phone_number: string = await prompt(
28
- "Phone Number ex -> (989123456789):: ",
30
+ "Phone Number ex -> (989123456789): ",
29
31
  );
30
32
  let is_phone_number_true = true;
31
33
 
@@ -57,7 +59,7 @@ async function start(this: Client): Promise<void> {
57
59
  this.privateKey = privateKey;
58
60
 
59
61
  while (true) {
60
- let phone_code = await prompt("Code: ");
62
+ let phone_code = await prompt(`Code [ ${result.send_type} ]: `);
61
63
 
62
64
  let response = await this.signIn(
63
65
  phone_code,
@@ -80,7 +82,10 @@ async function start(this: Client): Promise<void> {
80
82
  private_key: this.privateKey,
81
83
  });
82
84
 
83
- await this.registerDevice();
85
+ const res = await this.registerDevice();
86
+
87
+ console.log(res);
88
+
84
89
  break;
85
90
  }
86
91
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rubika",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "author": "Hadi Rostami",
5
5
  "main": "index.ts",
6
6
  "description": "A modern library for Rubika built with Bun.",
package/utils/index.ts CHANGED
@@ -3,6 +3,5 @@ import Markdown from "./parser";
3
3
  import Utils from "./formater";
4
4
  import Logger from "./logger";
5
5
  import prompt from "./prompt";
6
- export * from "./errors";
7
6
 
8
7
  export { checkFilters, Logger, Utils, Markdown, prompt };
package/utils/logger.ts CHANGED
@@ -20,8 +20,6 @@ class Logger<T> {
20
20
  await handler(error as any);
21
21
  }
22
22
  }
23
-
24
- return error;
25
23
  }
26
24
  }
27
25