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.
- package/README.md +0 -0
- package/package.json +40 -0
- package/rubjs/client.d.ts +34 -0
- package/rubjs/client.js +47 -0
- package/rubjs/crypto/index.d.ts +12 -0
- package/rubjs/crypto/index.js +95 -0
- package/rubjs/index.d.ts +4 -0
- package/rubjs/index.js +11 -0
- package/rubjs/methods/advanced/builder.d.ts +3 -0
- package/rubjs/methods/advanced/builder.js +41 -0
- package/rubjs/methods/advanced/index.d.ts +2 -0
- package/rubjs/methods/advanced/index.js +8 -0
- package/rubjs/methods/auth/index.d.ts +4 -0
- package/rubjs/methods/auth/index.js +12 -0
- package/rubjs/methods/auth/register_device.d.ts +3 -0
- package/rubjs/methods/auth/register_device.js +61 -0
- package/rubjs/methods/auth/send_code.d.ts +4 -0
- package/rubjs/methods/auth/send_code.js +25 -0
- package/rubjs/methods/auth/sign_in.d.ts +4 -0
- package/rubjs/methods/auth/sign_in.js +24 -0
- package/rubjs/methods/index.d.ts +21 -0
- package/rubjs/methods/index.js +40 -0
- package/rubjs/methods/users/get_user_info.d.ts +4 -0
- package/rubjs/methods/users/get_user_info.js +18 -0
- package/rubjs/methods/users/index.d.ts +2 -0
- package/rubjs/methods/users/index.js +8 -0
- package/rubjs/methods/utilities/index.d.ts +3 -0
- package/rubjs/methods/utilities/index.js +10 -0
- package/rubjs/methods/utilities/on_chat_updates.d.ts +4 -0
- package/rubjs/methods/utilities/on_chat_updates.js +17 -0
- package/rubjs/methods/utilities/on_message_updates.d.ts +4 -0
- package/rubjs/methods/utilities/on_message_updates.js +17 -0
- package/rubjs/methods/utilities/on_show_activities.d.ts +4 -0
- package/rubjs/methods/utilities/on_show_activities.js +17 -0
- package/rubjs/methods/utilities/on_show_notifications.d.ts +4 -0
- package/rubjs/methods/utilities/on_show_notifications.js +21 -0
- package/rubjs/methods/utilities/run.d.ts +3 -0
- package/rubjs/methods/utilities/run.js +17 -0
- package/rubjs/methods/utilities/start.d.ts +3 -0
- package/rubjs/methods/utilities/start.js +68 -0
- package/rubjs/network/index.d.ts +29 -0
- package/rubjs/network/index.js +172 -0
- package/rubjs/session/index.d.ts +18 -0
- package/rubjs/session/index.js +57 -0
- package/rubjs/types/chat_updates.d.ts +26 -0
- package/rubjs/types/chat_updates.js +2 -0
- package/rubjs/types/filters_optiom.d.ts +10 -0
- package/rubjs/types/filters_optiom.js +2 -0
- package/rubjs/types/get_user_info.d.ts +63 -0
- package/rubjs/types/get_user_info.js +2 -0
- package/rubjs/types/index.d.ts +9 -0
- package/rubjs/types/index.js +2 -0
- package/rubjs/types/message_update.d.ts +112 -0
- package/rubjs/types/message_update.js +2 -0
- package/rubjs/types/send_code.d.ts +10 -0
- package/rubjs/types/send_code.js +2 -0
- package/rubjs/types/show_activities.d.ts +7 -0
- package/rubjs/types/show_activities.js +2 -0
- package/rubjs/types/show_notifications.d.ts +14 -0
- package/rubjs/types/show_notifications.js +2 -0
- package/rubjs/types/sign_in.d.ts +30 -0
- package/rubjs/types/sign_in.js +2 -0
- package/rubjs/utils/filters.d.ts +26 -0
- package/rubjs/utils/filters.js +72 -0
- package/rubjs/utils/index.d.ts +2 -0
- package/rubjs/utils/index.js +8 -0
@@ -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,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,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,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;
|