rubjs 2.8.0 → 2.8.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.
- package/package.json +1 -1
- package/rubjs/network/index.js +2 -1
- package/rubjs/session/index.js +0 -107
package/package.json
CHANGED
package/rubjs/network/index.js
CHANGED
@@ -236,8 +236,9 @@ class Network {
|
|
236
236
|
}
|
237
237
|
return false;
|
238
238
|
});
|
239
|
-
if (isMUp)
|
239
|
+
if (isMUp && (messageData === null || messageData === void 0 ? void 0 : messageData.message)) {
|
240
240
|
messageData.message.author_title = username;
|
241
|
+
}
|
241
242
|
if (isValid)
|
242
243
|
yield callback(new types_1.Message(this.client, messageData));
|
243
244
|
}
|
package/rubjs/session/index.js
CHANGED
@@ -1,100 +1,8 @@
|
|
1
1
|
"use strict";
|
2
|
-
// import sqlite3 from "sqlite3";
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
4
|
};
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
-
// interface SessionData {
|
8
|
-
// phone: string;
|
9
|
-
// auth: string;
|
10
|
-
// guid: string;
|
11
|
-
// agent: string;
|
12
|
-
// private_key: string;
|
13
|
-
// }
|
14
|
-
// class SQLiteSession {
|
15
|
-
// private dbFile: string;
|
16
|
-
// private db: sqlite3.Database;
|
17
|
-
// constructor(sessionName: string) {
|
18
|
-
// this.dbFile = sessionName.endsWith(".rp") ? sessionName : `${sessionName}.rp`;
|
19
|
-
// this.db = new sqlite3.Database(this.dbFile, (err) => {
|
20
|
-
// if (err) {
|
21
|
-
// console.error("Error opening database:", err);
|
22
|
-
// } else {
|
23
|
-
// this.initializeDB();
|
24
|
-
// }
|
25
|
-
// });
|
26
|
-
// }
|
27
|
-
// private handleError<T>(operation: string, callback: () => T): T | null {
|
28
|
-
// try {
|
29
|
-
// return callback();
|
30
|
-
// } catch (error) {
|
31
|
-
// console.error(`Error in ${operation}:`, error);
|
32
|
-
// console.warn(`Failed to execute ${operation}`);
|
33
|
-
// return null;
|
34
|
-
// }
|
35
|
-
// }
|
36
|
-
// private initializeDB(): void {
|
37
|
-
// this.handleError("initializeDB", () => {
|
38
|
-
// this.db.exec("PRAGMA journal_mode = DELETE");
|
39
|
-
// this.db.get(
|
40
|
-
// "SELECT name FROM sqlite_master WHERE type=? AND name=?",
|
41
|
-
// ["table", "session"],
|
42
|
-
// (err, row) => {
|
43
|
-
// if (!row) {
|
44
|
-
// this.db.run(
|
45
|
-
// `CREATE TABLE session (
|
46
|
-
// phone TEXT PRIMARY KEY,
|
47
|
-
// auth TEXT,
|
48
|
-
// guid TEXT,
|
49
|
-
// agent TEXT,
|
50
|
-
// private_key TEXT
|
51
|
-
// )`
|
52
|
-
// );
|
53
|
-
// }
|
54
|
-
// }
|
55
|
-
// );
|
56
|
-
// });
|
57
|
-
// }
|
58
|
-
// getSession(): SessionData | null {
|
59
|
-
// return this.handleError("getSession", () => {
|
60
|
-
// return new Promise<SessionData | null>((resolve) => {
|
61
|
-
// this.db.get("SELECT * FROM session", (err, row) => {
|
62
|
-
// if (err) {
|
63
|
-
// console.error("Error fetching session:", err);
|
64
|
-
// resolve(null);
|
65
|
-
// } else {
|
66
|
-
// resolve(row as SessionData || null);
|
67
|
-
// }
|
68
|
-
// });
|
69
|
-
// }) as unknown as SessionData | null;
|
70
|
-
// }) as SessionData | null;
|
71
|
-
// }
|
72
|
-
// saveSession(
|
73
|
-
// phone: string,
|
74
|
-
// auth: string,
|
75
|
-
// guid: string,
|
76
|
-
// agent: string,
|
77
|
-
// privateKey: string
|
78
|
-
// ): void {
|
79
|
-
// this.handleError("saveSession", () => {
|
80
|
-
// this.db.run(
|
81
|
-
// `INSERT OR REPLACE INTO session (phone, auth, guid, agent, private_key)
|
82
|
-
// VALUES (?, ?, ?, ?, ?)`,
|
83
|
-
// [phone, auth, guid, agent, privateKey]
|
84
|
-
// );
|
85
|
-
// });
|
86
|
-
// }
|
87
|
-
// closeDB(): void {
|
88
|
-
// this.handleError("closeDB", () => {
|
89
|
-
// this.db.close((err) => {
|
90
|
-
// if (err) {
|
91
|
-
// console.error("Error closing database:", err);
|
92
|
-
// }
|
93
|
-
// });
|
94
|
-
// });
|
95
|
-
// }
|
96
|
-
// }
|
97
|
-
// export default SQLiteSession;
|
98
6
|
const fs_1 = __importDefault(require("fs"));
|
99
7
|
const crypto_1 = __importDefault(require("crypto"));
|
100
8
|
class SessionManager {
|
@@ -147,18 +55,3 @@ class SessionManager {
|
|
147
55
|
}
|
148
56
|
}
|
149
57
|
exports.default = SessionManager;
|
150
|
-
// // مثال استفاده از کلاس
|
151
|
-
// const secretKey = '12345678901234567890123456789012'; // کلید رمزنگاری 32 بایتی
|
152
|
-
// const sessionManager = new SessionManager(secretKey, 'session.json');
|
153
|
-
// const sessionData: SessionData = {
|
154
|
-
// phone: '1234567890',
|
155
|
-
// auth: 'auth-token',
|
156
|
-
// guid: 'unique-guid',
|
157
|
-
// agent: 'user-agent',
|
158
|
-
// private_key: 'private-key-example'
|
159
|
-
// };
|
160
|
-
// // ذخیره دادهها در فایل
|
161
|
-
// sessionManager.saveSession(sessionData);
|
162
|
-
// // خواندن دادهها از فایل
|
163
|
-
// const sessionFromFile = sessionManager.getSession();
|
164
|
-
// console.log('Decrypted session data:', sessionFromFile);
|