rubjs 3.0.0 → 3.0.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/README.md +8 -8
- package/lib/clients/VoiceChatClient.d.ts +4 -3
- package/lib/clients/VoiceChatClient.js +60 -92
- package/lib/clients/loginClient.d.ts +1 -1
- package/lib/clients/loginClient.js +1 -1
- package/lib/{core → clients}/network_login.js +1 -1
- package/lib/core/client.d.ts +10 -19
- package/lib/core/client.js +32 -20
- package/lib/{types → core/context}/activities.type.d.ts +2 -2
- package/lib/{types → core/context}/chat.type.d.ts +2 -2
- package/lib/core/context/contextConstructors.d.ts +10 -0
- package/lib/core/context/contextConstructors.js +16 -0
- package/lib/core/context/index.d.ts +5 -0
- package/lib/core/context/index.js +14 -0
- package/lib/{types → core/context}/message.type.d.ts +2 -2
- package/lib/{types → core/context}/notifications.type.d.ts +2 -2
- package/lib/core/methods/extras/onEditMessages.d.ts +1 -1
- package/lib/core/methods/groups/joinGroup.js +0 -1
- package/lib/core/methods/index.d.ts +4 -3
- package/lib/core/methods/index.js +8 -17
- package/lib/core/methods/utilities/download.d.ts +4 -0
- package/lib/core/methods/utilities/download.js +6 -0
- package/lib/core/methods/utilities/downloadProfilePicture.d.ts +4 -0
- package/lib/core/methods/utilities/downloadProfilePicture.js +28 -0
- package/lib/core/methods/utilities/index.d.ts +3 -3
- package/lib/core/methods/utilities/index.js +5 -5
- package/lib/core/methods/utilities/start.js +0 -1
- package/lib/core/network/api.d.ts +16 -0
- package/lib/core/network/api.js +95 -0
- package/lib/core/network/file.d.ts +3 -0
- package/lib/core/network/file.js +117 -0
- package/lib/core/network/index.d.ts +25 -0
- package/lib/core/network/index.js +31 -0
- package/lib/core/network/utils.d.ts +9 -0
- package/lib/core/network/utils.js +34 -0
- package/lib/core/network/websocket.d.ts +3 -0
- package/lib/core/network/websocket.js +190 -0
- package/lib/index.d.ts +7 -5
- package/lib/index.js +2 -4
- package/lib/types/client.type.d.ts +10 -12
- package/lib/types/index.type.d.ts +1 -3
- package/lib/types/index.type.js +1 -8
- package/package.json +1 -1
- package/lib/core/methods/utilities/runErrorMiddlewares.d.ts +0 -3
- package/lib/core/methods/utilities/runErrorMiddlewares.js +0 -13
- package/lib/core/methods/utilities/useError.d.ts +0 -4
- package/lib/core/methods/utilities/useError.js +0 -6
- package/lib/core/network.d.ts +0 -49
- package/lib/core/network.js +0 -436
- /package/lib/{core → clients}/network_login.d.ts +0 -0
- /package/lib/{types → core/context}/activities.type.js +0 -0
- /package/lib/{types → core/context}/chat.type.js +0 -0
- /package/lib/{types → core/context}/message.type.js +0 -0
- /package/lib/{types → core/context}/notifications.type.js +0 -0
- /package/lib/{core → utils}/utils.d.ts +0 -0
- /package/lib/{core → utils}/utils.js +0 -0
package/README.md
CHANGED
@@ -5,28 +5,28 @@
|
|
5
5
|
|
6
6
|
# RubJS
|
7
7
|
|
8
|
-
> یک فریمورک مدرن، زیبا و کاملاً غیرهمزمان برای تعامل با API رسمی روبیکا
|
8
|
+
> یک فریمورک مدرن، زیبا و کاملاً غیرهمزمان برای تعامل با API رسمی روبیکا
|
9
9
|
|
10
10
|
---
|
11
11
|
|
12
12
|
## 🚀 معرفی
|
13
13
|
|
14
|
-
**RubJS** یک فریمورک سبک و ماژولار برای توسعه سریع رباتهای روبیکایی است. این فریمورک با معماری مبتنی بر
|
14
|
+
**RubJS** یک فریمورک سبک و ماژولار برای توسعه سریع رباتهای روبیکایی است. این فریمورک با معماری مبتنی بر Fileter-Base سیستم فرماندهی، زمانبندی و تایپسیف، به شما این امکان را میدهد که در کمترین زمان، رباتهایی سریع، تمیز و قابل گسترش بسازید.
|
15
15
|
|
16
16
|
---
|
17
17
|
|
18
18
|
## ⚡ نمونه کد اولیه
|
19
19
|
|
20
20
|
```js
|
21
|
-
const { Client, Utils } = require("rubjs");
|
21
|
+
const { Client, Utils, Filters } = require("rubjs");
|
22
22
|
|
23
23
|
const bot = new Client("rubjs");
|
24
24
|
|
25
|
-
bot.command("/admin",
|
25
|
+
bot.command("/admin", [Filters.isPrivate], async (ctx) => {
|
26
26
|
await ctx.reply("شما ادمین هستید ✅");
|
27
27
|
});
|
28
28
|
|
29
|
-
bot.command("message",
|
29
|
+
bot.command("message", [Filters.isGroup], async (ctx) => {
|
30
30
|
await ctx.reply("سلام");
|
31
31
|
});
|
32
32
|
|
@@ -39,14 +39,14 @@ bot.run();
|
|
39
39
|
### پشتیبانی از پلاگینها (Plugin System)
|
40
40
|
امکان افزودن قابلیتهای جدید با پلاگینهای جداگانه
|
41
41
|
|
42
|
-
### طراحی
|
43
|
-
|
42
|
+
### طراحی Filters-based
|
43
|
+
اجرای نوع جدیدی از فیلتر روی پیام ها برای فیلت کردن پیام کاربران
|
44
44
|
|
45
45
|
### تایپسیف کامل (TypeScript Ready)
|
46
46
|
طراحی شده با پشتیبانی کامل از تایپها برای توسعهدهندگان حرفهای.
|
47
47
|
|
48
48
|
### سیستم فرمانها (Commands)
|
49
|
-
استفاده از `bot.command(pattern,
|
49
|
+
استفاده از `bot.command(pattern, handler)` برای مدیریت پیامهای فرمانمحور.
|
50
50
|
|
51
51
|
### ابزارهای داخلی توسعه
|
52
52
|
مثل `Utils.Bold`, `Utils.Italic` و ... برای زیباتر کردن پاسخها به کاربر.
|
@@ -4,7 +4,6 @@ declare class VoiceChatClient {
|
|
4
4
|
private source;
|
5
5
|
private track;
|
6
6
|
private ffmpeg?;
|
7
|
-
private buffer;
|
8
7
|
private frameSize;
|
9
8
|
private playlist;
|
10
9
|
private currentIndex;
|
@@ -13,7 +12,8 @@ declare class VoiceChatClient {
|
|
13
12
|
private client?;
|
14
13
|
private isPaused;
|
15
14
|
private lastPosition;
|
16
|
-
private
|
15
|
+
private audioTimer?;
|
16
|
+
private updateTimers;
|
17
17
|
private isManualSkip;
|
18
18
|
private getMusicUrl?;
|
19
19
|
constructor(getMusicUrl?: () => Promise<string>);
|
@@ -25,6 +25,7 @@ declare class VoiceChatClient {
|
|
25
25
|
addToPlaylist(filePath: string): void;
|
26
26
|
removeFromPlaylist(filePath: string): void;
|
27
27
|
joinVoiceChat(chatGuid: string, voiceChatId: string, client: Client): Promise<void>;
|
28
|
-
private
|
28
|
+
private setTimers;
|
29
|
+
private clearTimers;
|
29
30
|
}
|
30
31
|
export default VoiceChatClient;
|
@@ -5,15 +5,15 @@ const optional_require_1 = require("optional-require");
|
|
5
5
|
const optionalWrtc = (0, optional_require_1.optionalRequire)('wrtc');
|
6
6
|
class VoiceChatClient {
|
7
7
|
constructor(getMusicUrl) {
|
8
|
-
this.
|
9
|
-
this.frameSize = 960;
|
8
|
+
this.frameSize = 960 * 2; // 960 samples * 2 bytes
|
10
9
|
this.playlist = [];
|
11
10
|
this.currentIndex = 0;
|
12
11
|
this.isPaused = false;
|
13
12
|
this.lastPosition = 0;
|
13
|
+
this.updateTimers = [];
|
14
14
|
this.isManualSkip = false;
|
15
15
|
if (!optionalWrtc) {
|
16
|
-
throw new Error('wrtc module is not installed.
|
16
|
+
throw new Error('wrtc module is not installed.');
|
17
17
|
}
|
18
18
|
this.pc = new optionalWrtc.RTCPeerConnection();
|
19
19
|
this.source = new optionalWrtc.nonstandard.RTCAudioSource();
|
@@ -22,123 +22,80 @@ class VoiceChatClient {
|
|
22
22
|
this.getMusicUrl = getMusicUrl;
|
23
23
|
}
|
24
24
|
async play(filePath) {
|
25
|
-
|
26
|
-
this.stop();
|
25
|
+
this.stop(); // clean up previous
|
27
26
|
if (!filePath) {
|
28
|
-
if (this.playlist.length
|
29
|
-
|
30
|
-
this.playlist = [await this.getMusicUrl()];
|
31
|
-
}
|
32
|
-
else
|
33
|
-
return;
|
27
|
+
if (!this.playlist.length && this.getMusicUrl) {
|
28
|
+
this.playlist = [await this.getMusicUrl()];
|
34
29
|
}
|
35
30
|
filePath = this.playlist[this.currentIndex];
|
36
31
|
}
|
37
|
-
if (!this.chatGuid || !this.voiceChatId || !this.client) {
|
38
|
-
throw new Error('Voice chat not initialized.
|
32
|
+
if (!filePath || !this.chatGuid || !this.voiceChatId || !this.client) {
|
33
|
+
throw new Error('Voice chat not initialized.');
|
39
34
|
}
|
40
35
|
this.isPaused = false;
|
41
36
|
this.isManualSkip = false;
|
42
|
-
this.buffer = Buffer.alloc(0);
|
43
37
|
const seekArgs = this.lastPosition > 0 ? ['-ss', this.lastPosition.toString()] : [];
|
44
38
|
this.ffmpeg = (0, child_process_1.spawn)('ffmpeg', [
|
45
|
-
'-loglevel',
|
46
|
-
'quiet',
|
39
|
+
'-loglevel', 'quiet',
|
47
40
|
'-re',
|
48
|
-
'-threads',
|
49
|
-
'
|
50
|
-
'-protocol_whitelist',
|
51
|
-
'file,http,https,tcp,tls',
|
41
|
+
'-threads', '1',
|
42
|
+
'-protocol_whitelist', 'file,http,https,tcp,tls',
|
52
43
|
...seekArgs,
|
53
|
-
'-i',
|
54
|
-
|
55
|
-
'-
|
56
|
-
'
|
57
|
-
'-
|
58
|
-
'48000',
|
59
|
-
'-ac',
|
60
|
-
'1',
|
61
|
-
'-f',
|
62
|
-
's16le',
|
44
|
+
'-i', filePath,
|
45
|
+
'-acodec', 'pcm_s16le',
|
46
|
+
'-ar', '48000',
|
47
|
+
'-ac', '1',
|
48
|
+
'-f', 's16le',
|
63
49
|
'pipe:1',
|
64
50
|
]);
|
65
|
-
|
66
|
-
this.ffmpeg.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
this.ffmpeg.on('close', async (code) => {
|
79
|
-
if (!this.isManualSkip && code !== null && !this.isPaused) {
|
51
|
+
this.audioTimer = setInterval(() => {
|
52
|
+
if (!this.ffmpeg || this.isPaused)
|
53
|
+
return;
|
54
|
+
const chunk = this.ffmpeg.stdout.read(this.frameSize);
|
55
|
+
if (!chunk)
|
56
|
+
return;
|
57
|
+
const samples = new Int16Array(chunk.buffer, chunk.byteOffset, chunk.length / 2);
|
58
|
+
this.source.onData({ samples, sampleRate: 48000 });
|
59
|
+
this.lastPosition += 0.02;
|
60
|
+
}, 20); // 20ms = 960 samples
|
61
|
+
this.ffmpeg.on('close', async () => {
|
62
|
+
clearInterval(this.audioTimer);
|
63
|
+
if (!this.isManualSkip && !this.isPaused) {
|
80
64
|
await this.next();
|
81
65
|
}
|
82
66
|
this.isManualSkip = false;
|
83
67
|
});
|
84
|
-
this.
|
85
|
-
this.intervalId = setInterval(async () => {
|
86
|
-
try {
|
87
|
-
if (!this.client || !this.chatGuid || !this.voiceChatId)
|
88
|
-
return;
|
89
|
-
await this.client.getGroupVoiceChatUpdates(this.chatGuid, this.voiceChatId);
|
90
|
-
}
|
91
|
-
catch { }
|
92
|
-
}, 10 * 1000);
|
93
|
-
this.intervalId = setInterval(async () => {
|
94
|
-
try {
|
95
|
-
if (this.isPaused ||
|
96
|
-
!this.client ||
|
97
|
-
!this.chatGuid ||
|
98
|
-
!this.voiceChatId ||
|
99
|
-
!this.client.userGuid)
|
100
|
-
return;
|
101
|
-
await this.client.sendVoiceChatActivity(this.chatGuid, this.voiceChatId, this.client.userGuid);
|
102
|
-
}
|
103
|
-
catch { }
|
104
|
-
}, 2 * 1000);
|
68
|
+
this.setTimers();
|
105
69
|
}
|
106
70
|
stop() {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
}
|
71
|
+
this.ffmpeg?.kill();
|
72
|
+
this.ffmpeg = undefined;
|
73
|
+
this.isPaused = true;
|
74
|
+
clearInterval(this.audioTimer);
|
75
|
+
this.clearTimers();
|
113
76
|
}
|
114
77
|
resume() {
|
115
78
|
if (this.isPaused)
|
116
|
-
this.play();
|
79
|
+
this.play(this.playlist[this.currentIndex]);
|
117
80
|
}
|
118
81
|
async next() {
|
119
|
-
if (this.
|
82
|
+
if (this.currentIndex + 1 < this.playlist.length) {
|
120
83
|
this.isManualSkip = true;
|
121
|
-
this.
|
122
|
-
this.currentIndex += 1;
|
84
|
+
this.currentIndex++;
|
123
85
|
this.lastPosition = 0;
|
124
|
-
this.isPaused = true;
|
125
86
|
this.play(this.playlist[this.currentIndex]);
|
126
87
|
}
|
127
|
-
else {
|
128
|
-
|
129
|
-
|
130
|
-
await this.next();
|
131
|
-
}
|
88
|
+
else if (this.getMusicUrl) {
|
89
|
+
this.playlist.push(await this.getMusicUrl());
|
90
|
+
await this.next();
|
132
91
|
}
|
133
92
|
}
|
134
93
|
previous() {
|
135
94
|
if (this.currentIndex > 0) {
|
136
95
|
this.isManualSkip = true;
|
137
|
-
this.stop();
|
138
96
|
this.currentIndex--;
|
139
97
|
this.lastPosition = 0;
|
140
|
-
this.
|
141
|
-
this.play();
|
98
|
+
this.play(this.playlist[this.currentIndex]);
|
142
99
|
}
|
143
100
|
}
|
144
101
|
addToPlaylist(filePath) {
|
@@ -162,18 +119,29 @@ class VoiceChatClient {
|
|
162
119
|
return;
|
163
120
|
await this.pc.setLocalDescription(offer);
|
164
121
|
const connect = await client.joinGroupVoiceChat(chatGuid, voiceChatId, offer.sdp, client.userGuid);
|
165
|
-
const sdpAnswer = connect.sdp_answer_data;
|
166
122
|
await this.pc.setRemoteDescription(new optionalWrtc.RTCSessionDescription({
|
167
123
|
type: 'answer',
|
168
|
-
sdp:
|
124
|
+
sdp: connect.sdp_answer_data,
|
169
125
|
}));
|
170
126
|
await client.setVoiceChatState(chatGuid, voiceChatId);
|
171
127
|
}
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
this.
|
176
|
-
|
128
|
+
setTimers() {
|
129
|
+
this.clearTimers();
|
130
|
+
this.updateTimers.push(setInterval(async () => {
|
131
|
+
if (this.client && this.chatGuid && this.voiceChatId) {
|
132
|
+
await this.client.getGroupVoiceChatUpdates(this.chatGuid, this.voiceChatId);
|
133
|
+
}
|
134
|
+
}, 10 * 1000));
|
135
|
+
this.updateTimers.push(setInterval(async () => {
|
136
|
+
if (this.client && this.chatGuid && this.voiceChatId &&
|
137
|
+
this.client.userGuid && !this.isPaused) {
|
138
|
+
await this.client.sendVoiceChatActivity(this.chatGuid, this.voiceChatId, this.client.userGuid);
|
139
|
+
}
|
140
|
+
}, 2 * 1000));
|
141
|
+
}
|
142
|
+
clearTimers() {
|
143
|
+
this.updateTimers.forEach(clearInterval);
|
144
|
+
this.updateTimers = [];
|
177
145
|
}
|
178
146
|
}
|
179
147
|
exports.default = VoiceChatClient;
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const crypto_1 = __importDefault(require("../core/crypto"));
|
7
|
-
const network_login_1 = __importDefault(require("
|
7
|
+
const network_login_1 = __importDefault(require("./network_login"));
|
8
8
|
const session_1 = __importDefault(require("../core/session"));
|
9
9
|
class LoginClient {
|
10
10
|
static async sendCode(phone_number, pass_key) {
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const undici_1 = require("undici");
|
7
|
-
const crypto_1 = __importDefault(require("
|
7
|
+
const crypto_1 = __importDefault(require("../core/crypto"));
|
8
8
|
class Network {
|
9
9
|
constructor() {
|
10
10
|
this.apiUrl = null;
|
package/lib/core/client.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import Network from './network';
|
2
|
-
import { ClientTypes } from '../types/index.type';
|
3
|
-
import SessionManager from './session';
|
4
2
|
import Methods from './methods';
|
5
|
-
|
6
|
-
|
3
|
+
import SessionManager from './session';
|
4
|
+
import Message from './context/message.type';
|
5
|
+
import { ClientTypes } from '../types/index.type';
|
6
|
+
import { ContextMap, Handler } from '../types/client.type';
|
7
7
|
export default class Client extends Methods {
|
8
8
|
private session;
|
9
9
|
platform: ClientTypes.PlatformType;
|
@@ -17,22 +17,13 @@ export default class Client extends Methods {
|
|
17
17
|
network: Network;
|
18
18
|
plugins: ClientTypes.RubPlugin[];
|
19
19
|
errorMiddlewares: ClientTypes.ErrorMiddleware[];
|
20
|
-
|
21
|
-
pattern: string | RegExp;
|
22
|
-
middlewares: ClientTypes.MiddlewareChain<ClientTypes.ContextMap['message']>;
|
23
|
-
}[];
|
20
|
+
userGuid?: string;
|
24
21
|
handlers: {
|
25
|
-
[K in
|
22
|
+
[K in keyof ContextMap]: Handler<ContextMap[K]>[];
|
26
23
|
};
|
27
|
-
userGuid?: string;
|
28
24
|
constructor(session: ClientTypes.SessionType, platform?: ClientTypes.PlatformType, timeout?: number);
|
29
|
-
on<
|
30
|
-
on<
|
31
|
-
|
32
|
-
|
33
|
-
command(pattern: string | RegExp, handler: H): void;
|
34
|
-
command(pattern: string | RegExp, m1: M, handler: H): void;
|
35
|
-
command(pattern: string | RegExp, m1: M, m2: M, handler: H): void;
|
36
|
-
command(pattern: string | RegExp, m1: M, m2: M, m3: M, handler: H): void;
|
25
|
+
on<T extends keyof typeof this.handlers>(type: T, handler: (ctx: ContextMap[T]) => Promise<void>): void;
|
26
|
+
on<T extends keyof typeof this.handlers>(type: T, filters: Array<(ctx: ContextMap[T]) => boolean | Promise<boolean>>, handler: (ctx: ContextMap[T]) => Promise<void>): void;
|
27
|
+
command(prefix: string | RegExp, handler: (ctx: Message) => Promise<void>): void;
|
28
|
+
command(prefix: string | RegExp, filters: Array<(ctx: Message) => boolean | Promise<boolean>>, handler: (ctx: Message) => Promise<void>): void;
|
37
29
|
}
|
38
|
-
export {};
|
package/lib/core/client.js
CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
const network_1 = __importDefault(require("./network"));
|
7
|
-
const session_1 = __importDefault(require("./session"));
|
8
7
|
const methods_1 = __importDefault(require("./methods"));
|
8
|
+
const session_1 = __importDefault(require("./session"));
|
9
9
|
class Client extends methods_1.default {
|
10
10
|
constructor(session, platform = 'Web', timeout = 5000) {
|
11
11
|
super();
|
@@ -15,39 +15,51 @@ class Client extends methods_1.default {
|
|
15
15
|
this.initialize = false;
|
16
16
|
this.plugins = [];
|
17
17
|
this.errorMiddlewares = [];
|
18
|
-
this.cmd = [];
|
19
18
|
this.handlers = {
|
20
19
|
chat: [],
|
21
20
|
message: [],
|
22
21
|
activities: [],
|
23
22
|
notifications: [],
|
24
23
|
};
|
25
|
-
this.sessionDb = new session_1.default(session);
|
24
|
+
this.sessionDb = new session_1.default(this.session);
|
26
25
|
this.network = new network_1.default(this);
|
27
26
|
this.start();
|
28
27
|
}
|
29
|
-
on(
|
30
|
-
if (
|
31
|
-
|
28
|
+
on(type, filtersOrHandler, maybeHandler) {
|
29
|
+
if (typeof filtersOrHandler === 'function') {
|
30
|
+
this.handlers[type].push({
|
31
|
+
filters: [],
|
32
|
+
handler: filtersOrHandler,
|
33
|
+
});
|
32
34
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
else if (Array.isArray(filtersOrHandler) && maybeHandler) {
|
36
|
+
this.handlers[type].push({
|
37
|
+
filters: filtersOrHandler,
|
38
|
+
handler: maybeHandler,
|
39
|
+
});
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
throw new Error('Invalid arguments for on()');
|
36
43
|
}
|
37
|
-
this.handlers[updateType].push(funcs);
|
38
44
|
}
|
39
|
-
command(
|
40
|
-
if (
|
41
|
-
|
45
|
+
command(prefix, filtersOrHandler, maybeHandler) {
|
46
|
+
if (typeof filtersOrHandler === 'function') {
|
47
|
+
this.handlers['message'].push({
|
48
|
+
filters: [],
|
49
|
+
handler: filtersOrHandler,
|
50
|
+
prefix,
|
51
|
+
});
|
52
|
+
}
|
53
|
+
else if (Array.isArray(filtersOrHandler) && maybeHandler) {
|
54
|
+
this.handlers['message'].push({
|
55
|
+
filters: filtersOrHandler,
|
56
|
+
handler: maybeHandler,
|
57
|
+
prefix,
|
58
|
+
});
|
42
59
|
}
|
43
|
-
|
44
|
-
|
45
|
-
throw new Error('Last handler must be of type (ctx) => Promise<void>');
|
60
|
+
else {
|
61
|
+
throw new Error('Invalid arguments for command()');
|
46
62
|
}
|
47
|
-
this.cmd.push({
|
48
|
-
pattern,
|
49
|
-
middlewares: handlers,
|
50
|
-
});
|
51
63
|
}
|
52
64
|
}
|
53
65
|
exports.default = Client;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Client } from '
|
2
|
-
import { DecoratorsTypes } from '
|
1
|
+
import { Client } from '../..';
|
2
|
+
import { DecoratorsTypes } from '../../types/index.type';
|
3
3
|
declare class Activities implements DecoratorsTypes.ShowActivities {
|
4
4
|
type: string;
|
5
5
|
object_guid: string;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Client } from '
|
2
|
-
import { DecoratorsTypes } from '
|
1
|
+
import { Client } from '../..';
|
2
|
+
import { DecoratorsTypes } from '../../types/index.type';
|
3
3
|
declare class Chat implements DecoratorsTypes.ChatUpdates {
|
4
4
|
object_guid: string;
|
5
5
|
action: string;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import Activities from './activities.type';
|
2
|
+
import Chat from './chat.type';
|
3
|
+
import Message from './message.type';
|
4
|
+
import Notifications from './notifications.type';
|
5
|
+
export declare const ContextConstructors: {
|
6
|
+
message: typeof Message;
|
7
|
+
chat: typeof Chat;
|
8
|
+
activities: typeof Activities;
|
9
|
+
notifications: typeof Notifications;
|
10
|
+
};
|
@@ -0,0 +1,16 @@
|
|
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.ContextConstructors = void 0;
|
7
|
+
const activities_type_1 = __importDefault(require("./activities.type"));
|
8
|
+
const chat_type_1 = __importDefault(require("./chat.type"));
|
9
|
+
const message_type_1 = __importDefault(require("./message.type"));
|
10
|
+
const notifications_type_1 = __importDefault(require("./notifications.type"));
|
11
|
+
exports.ContextConstructors = {
|
12
|
+
message: message_type_1.default,
|
13
|
+
chat: chat_type_1.default,
|
14
|
+
activities: activities_type_1.default,
|
15
|
+
notifications: notifications_type_1.default,
|
16
|
+
};
|
@@ -0,0 +1,14 @@
|
|
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.Notifications = exports.Message = exports.Chat = exports.Activities = void 0;
|
7
|
+
const activities_type_1 = __importDefault(require("./activities.type"));
|
8
|
+
exports.Activities = activities_type_1.default;
|
9
|
+
const chat_type_1 = __importDefault(require("./chat.type"));
|
10
|
+
exports.Chat = chat_type_1.default;
|
11
|
+
const message_type_1 = __importDefault(require("./message.type"));
|
12
|
+
exports.Message = message_type_1.default;
|
13
|
+
const notifications_type_1 = __importDefault(require("./notifications.type"));
|
14
|
+
exports.Notifications = notifications_type_1.default;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Client } from '
|
2
|
-
import { DecoratorsTypes } from '
|
1
|
+
import { Client } from '../..';
|
2
|
+
import { DecoratorsTypes } from '../../types/index.type';
|
3
3
|
declare class Message implements DecoratorsTypes.MessageUpdate {
|
4
4
|
message_id: string;
|
5
5
|
action: string;
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Client } from '
|
2
|
-
import { DecoratorsTypes } from '
|
1
|
+
import { Client } from '../..';
|
2
|
+
import { DecoratorsTypes } from '../../types/index.type';
|
3
3
|
declare class Notifications implements DecoratorsTypes.ShowNotifications {
|
4
4
|
notification_id: string;
|
5
5
|
type: string;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import Message from "
|
1
|
+
import Message from "../../context/message.type";
|
2
2
|
import Client from "../../client";
|
3
3
|
declare function onEditMessages(this: Client, object_guid: string, callback: (message: Message) => any): void;
|
4
4
|
export default onEditMessages;
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
async function joinGroup(link) {
|
4
4
|
if (link.includes('/'))
|
5
5
|
link = link.split('/').pop() || '';
|
6
|
-
console.log(link);
|
7
6
|
return await this.builder('joinGroup', { hash_link: link });
|
8
7
|
}
|
9
8
|
exports.default = joinGroup;
|
@@ -4,7 +4,7 @@ import * as Auth from './auth';
|
|
4
4
|
import * as Channels from './channels';
|
5
5
|
import * as Chats from './chats';
|
6
6
|
import * as Contacts from './contacts';
|
7
|
-
import * as Extras from
|
7
|
+
import * as Extras from './extras';
|
8
8
|
import * as Gif from './gif';
|
9
9
|
import * as Groups from './groups';
|
10
10
|
import * as Messages from './messages';
|
@@ -83,6 +83,7 @@ export default class Methods {
|
|
83
83
|
getProfileLinkItems(this: Client, ...args: Parameters<typeof Extras.getProfileLinkItems>): Promise<any>;
|
84
84
|
getRelatedObjects(this: Client, ...args: Parameters<typeof Extras.getRelatedObjects>): Promise<any>;
|
85
85
|
getTranscription(this: Client, ...args: Parameters<typeof Extras.getTranscription>): Promise<any>;
|
86
|
+
onEditMessages(this: Client, ...args: Parameters<typeof Extras.onEditMessages>): Promise<any>;
|
86
87
|
join(this: Client, ...args: Parameters<typeof Extras.join>): Promise<any>;
|
87
88
|
leaveChat(this: Client, ...args: Parameters<typeof Extras.leaveChat>): Promise<any>;
|
88
89
|
reportObject(this: Client, ...args: Parameters<typeof Extras.reportObject>): Promise<any>;
|
@@ -179,9 +180,9 @@ export default class Methods {
|
|
179
180
|
getMe(this: Client, ...args: Parameters<typeof Users.getMe>): Promise<any>;
|
180
181
|
getUserInfo(this: Client, ...args: Parameters<typeof Users.getUserInfo>): Promise<any>;
|
181
182
|
setBlockUser(this: Client, ...args: Parameters<typeof Users.setBlockUser>): Promise<any>;
|
182
|
-
|
183
|
+
download(this: Client, ...args: Parameters<typeof Utilities.download>): Promise<any>;
|
184
|
+
downloadProfilePicture(this: Client, ...args: Parameters<typeof Utilities.downloadProfilePicture>): Promise<any>;
|
183
185
|
usePlugin(this: Client, ...args: Parameters<typeof Utilities.usePlugin>): Promise<any>;
|
184
|
-
useError(this: Client, ...args: Parameters<typeof Utilities.useError>): Promise<any>;
|
185
186
|
run(this: Client, ...args: Parameters<typeof Utilities.run>): Promise<any>;
|
186
187
|
requestSendFile(this: Client, ...args: Parameters<typeof Utilities.requestSendFile>): Promise<any>;
|
187
188
|
start(this: Client, ...args: Parameters<typeof Utilities.start>): Promise<any>;
|
@@ -263,6 +263,9 @@ class Methods {
|
|
263
263
|
async getTranscription(...args) {
|
264
264
|
return Extras.getTranscription.apply(this, args);
|
265
265
|
}
|
266
|
+
async onEditMessages(...args) {
|
267
|
+
return Extras.onEditMessages.apply(this, args);
|
268
|
+
}
|
266
269
|
async join(...args) {
|
267
270
|
return Extras.join.apply(this, args);
|
268
271
|
}
|
@@ -564,27 +567,15 @@ class Methods {
|
|
564
567
|
return Users.setBlockUser.apply(this, args);
|
565
568
|
}
|
566
569
|
// // utilities
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
// }
|
573
|
-
// async downloadProfilePicture(
|
574
|
-
// this: Client,
|
575
|
-
// ...args: Parameters<typeof Utilities.downloadProfilePicture>
|
576
|
-
// ): Promise<any> {
|
577
|
-
// return Utilities.downloadProfilePicture.apply(this, args);
|
578
|
-
// }
|
579
|
-
async runErrorMiddlewares(...args) {
|
580
|
-
return Utilities.runErrorMiddlewares.apply(this, args);
|
570
|
+
async download(...args) {
|
571
|
+
return Utilities.download.apply(this, args);
|
572
|
+
}
|
573
|
+
async downloadProfilePicture(...args) {
|
574
|
+
return Utilities.downloadProfilePicture.apply(this, args);
|
581
575
|
}
|
582
576
|
async usePlugin(...args) {
|
583
577
|
return Utilities.usePlugin.apply(this, args);
|
584
578
|
}
|
585
|
-
async useError(...args) {
|
586
|
-
return Utilities.useError.apply(this, args);
|
587
|
-
}
|
588
579
|
async run(...args) {
|
589
580
|
return Utilities.run.apply(this, args);
|
590
581
|
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
async function download(file_inline, chunk = 1054768) {
|
4
|
+
return await this.network.download(file_inline.dc_id, file_inline.file_id, file_inline.access_hash_rec, file_inline.size, chunk);
|
5
|
+
}
|
6
|
+
exports.default = download;
|