rubjs 1.0.0

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 (66) hide show
  1. package/README.md +0 -0
  2. package/package.json +40 -0
  3. package/rubjs/client.d.ts +34 -0
  4. package/rubjs/client.js +47 -0
  5. package/rubjs/crypto/index.d.ts +12 -0
  6. package/rubjs/crypto/index.js +95 -0
  7. package/rubjs/index.d.ts +4 -0
  8. package/rubjs/index.js +11 -0
  9. package/rubjs/methods/advanced/builder.d.ts +3 -0
  10. package/rubjs/methods/advanced/builder.js +41 -0
  11. package/rubjs/methods/advanced/index.d.ts +2 -0
  12. package/rubjs/methods/advanced/index.js +8 -0
  13. package/rubjs/methods/auth/index.d.ts +4 -0
  14. package/rubjs/methods/auth/index.js +12 -0
  15. package/rubjs/methods/auth/register_device.d.ts +3 -0
  16. package/rubjs/methods/auth/register_device.js +61 -0
  17. package/rubjs/methods/auth/send_code.d.ts +4 -0
  18. package/rubjs/methods/auth/send_code.js +25 -0
  19. package/rubjs/methods/auth/sign_in.d.ts +4 -0
  20. package/rubjs/methods/auth/sign_in.js +24 -0
  21. package/rubjs/methods/index.d.ts +21 -0
  22. package/rubjs/methods/index.js +40 -0
  23. package/rubjs/methods/users/get_user_info.d.ts +4 -0
  24. package/rubjs/methods/users/get_user_info.js +18 -0
  25. package/rubjs/methods/users/index.d.ts +2 -0
  26. package/rubjs/methods/users/index.js +8 -0
  27. package/rubjs/methods/utilities/index.d.ts +3 -0
  28. package/rubjs/methods/utilities/index.js +10 -0
  29. package/rubjs/methods/utilities/on_chat_updates.d.ts +4 -0
  30. package/rubjs/methods/utilities/on_chat_updates.js +17 -0
  31. package/rubjs/methods/utilities/on_message_updates.d.ts +4 -0
  32. package/rubjs/methods/utilities/on_message_updates.js +17 -0
  33. package/rubjs/methods/utilities/on_show_activities.d.ts +4 -0
  34. package/rubjs/methods/utilities/on_show_activities.js +17 -0
  35. package/rubjs/methods/utilities/on_show_notifications.d.ts +4 -0
  36. package/rubjs/methods/utilities/on_show_notifications.js +21 -0
  37. package/rubjs/methods/utilities/run.d.ts +3 -0
  38. package/rubjs/methods/utilities/run.js +17 -0
  39. package/rubjs/methods/utilities/start.d.ts +3 -0
  40. package/rubjs/methods/utilities/start.js +68 -0
  41. package/rubjs/network/index.d.ts +29 -0
  42. package/rubjs/network/index.js +172 -0
  43. package/rubjs/session/index.d.ts +18 -0
  44. package/rubjs/session/index.js +57 -0
  45. package/rubjs/types/chat_updates.d.ts +26 -0
  46. package/rubjs/types/chat_updates.js +2 -0
  47. package/rubjs/types/filters_optiom.d.ts +10 -0
  48. package/rubjs/types/filters_optiom.js +2 -0
  49. package/rubjs/types/get_user_info.d.ts +63 -0
  50. package/rubjs/types/get_user_info.js +2 -0
  51. package/rubjs/types/index.d.ts +9 -0
  52. package/rubjs/types/index.js +2 -0
  53. package/rubjs/types/message_update.d.ts +112 -0
  54. package/rubjs/types/message_update.js +2 -0
  55. package/rubjs/types/send_code.d.ts +10 -0
  56. package/rubjs/types/send_code.js +2 -0
  57. package/rubjs/types/show_activities.d.ts +7 -0
  58. package/rubjs/types/show_activities.js +2 -0
  59. package/rubjs/types/show_notifications.d.ts +14 -0
  60. package/rubjs/types/show_notifications.js +2 -0
  61. package/rubjs/types/sign_in.d.ts +30 -0
  62. package/rubjs/types/sign_in.js +2 -0
  63. package/rubjs/utils/filters.d.ts +26 -0
  64. package/rubjs/utils/filters.js +72 -0
  65. package/rubjs/utils/index.d.ts +2 -0
  66. package/rubjs/utils/index.js +8 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ interface ShowActivities {
2
+ type: string;
3
+ object_guid: string;
4
+ object_type: string;
5
+ user_activity_guid: string;
6
+ }
7
+ export default ShowActivities;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ interface ShowNotifications {
2
+ notification_id: string;
3
+ type: string;
4
+ title: string;
5
+ text: string;
6
+ image_file_id?: number;
7
+ message_data: {
8
+ object_guid: string;
9
+ object_type: string;
10
+ message_id: number;
11
+ sender_guid?: string;
12
+ };
13
+ }
14
+ export default ShowNotifications;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,30 @@
1
+ interface AvatarThumbnail {
2
+ file_id: string;
3
+ mime: string;
4
+ dc_id: string;
5
+ access_hash_rec: string;
6
+ }
7
+ interface OnlineTime {
8
+ type: string;
9
+ exact_time: number;
10
+ }
11
+ interface User {
12
+ user_guid: string;
13
+ first_name: string;
14
+ last_name: string;
15
+ phone: string;
16
+ username: string;
17
+ avatar_thumbnail: AvatarThumbnail;
18
+ last_online: number;
19
+ bio: string | boolean;
20
+ is_deleted: boolean;
21
+ is_verified: boolean;
22
+ online_time: OnlineTime;
23
+ }
24
+ interface SignIn {
25
+ status: string;
26
+ auth: string;
27
+ user: User;
28
+ timestamp: number;
29
+ }
30
+ export default SignIn;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ declare const Filters: {
2
+ findKey: (message: any, key: any) => any;
3
+ guidType: (message: any, startWith: any) => boolean;
4
+ is_reply: (message: any) => Promise<boolean>;
5
+ is_edited: (message: any) => Promise<boolean>;
6
+ is_link: (message: any) => Promise<any>;
7
+ is_text: (message: any) => Promise<boolean>;
8
+ is_group: (message: any) => Promise<boolean>;
9
+ is_channel: (message: any) => Promise<boolean>;
10
+ is_private: (message: any) => Promise<boolean>;
11
+ is_froward: (message: any) => Promise<boolean>;
12
+ is_file_inline: (message: any) => Promise<boolean>;
13
+ is_file: (message: any) => Promise<boolean>;
14
+ is_photo: (message: any) => Promise<boolean>;
15
+ is_sticker: (message: any) => Promise<boolean>;
16
+ is_video: (message: any) => Promise<boolean>;
17
+ is_voice: (message: any) => Promise<boolean>;
18
+ is_gif: (message: any) => Promise<boolean>;
19
+ is_audio: (message: any) => Promise<boolean>;
20
+ is_location: (message: any) => Promise<boolean>;
21
+ is_contact: (message: any) => Promise<boolean>;
22
+ is_poll: (message: any) => Promise<boolean>;
23
+ is_live: (message: any) => Promise<boolean>;
24
+ is_event: (message: any) => Promise<boolean>;
25
+ };
26
+ export default Filters;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const Filters = {
13
+ findKey: (message, key) => {
14
+ const messageKeys = Object.keys(message);
15
+ if (messageKeys.includes(key)) {
16
+ return message[key];
17
+ }
18
+ for (const messageKey of messageKeys) {
19
+ const value = message[messageKey];
20
+ if (Array.isArray(value)) {
21
+ for (const item of value) {
22
+ if (typeof item === "object") {
23
+ const found = Filters.findKey(item, key);
24
+ if (found !== undefined)
25
+ return found;
26
+ }
27
+ }
28
+ }
29
+ if (typeof value === "object") {
30
+ const found = Filters.findKey(value, key);
31
+ if (found !== undefined)
32
+ return found;
33
+ }
34
+ }
35
+ return undefined;
36
+ },
37
+ guidType: (message, startWith) => {
38
+ const result = Filters.findKey(message, "object_guid");
39
+ return result && result.startsWith(startWith);
40
+ },
41
+ is_reply: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "reply_to_message_id"); }),
42
+ is_edited: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "is_edited"); }),
43
+ is_link: (message) => __awaiter(void 0, void 0, void 0, function* () {
44
+ const link = Filters.findKey(message, "text");
45
+ if (!link)
46
+ return false;
47
+ const RUBIKA_LINK_PATTERN = /\brubika\.ir\b/;
48
+ const USERNAME_PATTERN = /@([a-zA-Z0-9_]{3,32})/;
49
+ return (link.includes("http") ||
50
+ RUBIKA_LINK_PATTERN.test(link) ||
51
+ USERNAME_PATTERN.test(link));
52
+ }),
53
+ is_text: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "text"); }),
54
+ is_group: (message) => __awaiter(void 0, void 0, void 0, function* () { return Filters.guidType(message, "g0"); }),
55
+ is_channel: (message) => __awaiter(void 0, void 0, void 0, function* () { return Filters.guidType(message, "c0"); }),
56
+ is_private: (message) => __awaiter(void 0, void 0, void 0, function* () { return Filters.guidType(message, "u0"); }),
57
+ is_froward: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "forwarded_from"); }),
58
+ is_file_inline: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "file_inline"); }),
59
+ is_file: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "File"); }),
60
+ is_photo: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Image"); }),
61
+ is_sticker: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Sticker"); }),
62
+ is_video: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Video"); }),
63
+ is_voice: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Voice"); }),
64
+ is_gif: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Gif"); }),
65
+ is_audio: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Music"); }),
66
+ is_location: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Location"); }),
67
+ is_contact: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "ContactMessage"); }),
68
+ is_poll: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "Poll"); }),
69
+ is_live: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "live_data"); }),
70
+ is_event: (message) => __awaiter(void 0, void 0, void 0, function* () { return !!Filters.findKey(message, "event_data"); }),
71
+ };
72
+ exports.default = Filters;
@@ -0,0 +1,2 @@
1
+ import Filters from "./filters";
2
+ export { Filters };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Filters = void 0;
7
+ const filters_1 = __importDefault(require("./filters"));
8
+ exports.Filters = filters_1.default;