rubjs 2.6.1 → 2.7.4
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 +2 -1
- package/rubjs/client.d.ts +2 -0
- package/rubjs/index.d.ts +2 -2
- package/rubjs/index.js +2 -1
- package/rubjs/methods/extras/index.d.ts +4 -1
- package/rubjs/methods/extras/index.js +7 -1
- package/rubjs/methods/extras/joinVoiceChat.d.ts +3 -0
- package/rubjs/methods/extras/joinVoiceChat.js +22 -0
- package/rubjs/methods/extras/sendVoiceChatActivity.d.ts +3 -0
- package/rubjs/methods/extras/sendVoiceChatActivity.js +24 -0
- package/rubjs/methods/extras/setVoiceChatState.d.ts +3 -0
- package/rubjs/methods/extras/setVoiceChatState.js +25 -0
- package/rubjs/methods/groups/createGroupVoiceChat.d.ts +1 -1
- package/rubjs/methods/groups/createGroupVoiceChat.js +2 -2
- package/rubjs/methods/groups/getGroupVoiceChatParticipants.d.ts +3 -0
- package/rubjs/methods/groups/getGroupVoiceChatParticipants.js +18 -0
- package/rubjs/methods/groups/index.d.ts +3 -1
- package/rubjs/methods/groups/index.js +5 -1
- package/rubjs/methods/groups/joinGroupVoiceChat.d.ts +3 -0
- package/rubjs/methods/groups/joinGroupVoiceChat.js +22 -0
- package/rubjs/methods/index.d.ts +5 -0
- package/rubjs/methods/index.js +25 -0
- package/rubjs/types/message.js +2 -3
- package/rubjs/utils/VoiceChatClient.d.ts +29 -0
- package/rubjs/utils/VoiceChatClient.js +163 -0
- package/rubjs/utils/filters.d.ts +2 -0
- package/rubjs/utils/filters.js +24 -0
- package/rubjs/utils/index.d.ts +2 -1
- package/rubjs/utils/index.js +3 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "rubjs",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.7.4",
|
4
4
|
"main": "rubjs/index.js",
|
5
5
|
"types": "rubjs/index.d.ts",
|
6
6
|
"keywords": [
|
@@ -30,6 +30,7 @@
|
|
30
30
|
"music-metadata": "^10.9.0",
|
31
31
|
"node-rsa": "^1.1.1",
|
32
32
|
"sharp": "^0.33.5",
|
33
|
+
"wrtc": "^0.4.7",
|
33
34
|
"ws": "^8.18.0"
|
34
35
|
},
|
35
36
|
"devDependencies": {
|
package/rubjs/client.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import Methods from "./methods";
|
2
2
|
import Network from "./network";
|
3
3
|
import SQLiteSession from "./session";
|
4
|
+
import { VoiceChatClient } from "./utils";
|
4
5
|
interface Platform {
|
5
6
|
app_name: string;
|
6
7
|
app_version: string;
|
@@ -30,6 +31,7 @@ declare class Client extends Methods {
|
|
30
31
|
filters: ((msg: any) => boolean)[] | ((msg: any) => boolean)[][];
|
31
32
|
updateType: TypeUpdate;
|
32
33
|
}[];
|
34
|
+
voiceChatClient: VoiceChatClient;
|
33
35
|
constructor(sessionFile: string, timeout?: number, platform?: PlatformType);
|
34
36
|
}
|
35
37
|
export default Client;
|
package/rubjs/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import Client from "./client";
|
2
2
|
import Crypto from "./crypto";
|
3
3
|
import * as Types from "./types";
|
4
|
-
import { Filters, Utils } from "./utils";
|
4
|
+
import { Filters, Utils, VoiceChatClient } from "./utils";
|
5
5
|
export default Client;
|
6
|
-
export { Client, Crypto, Utils, Filters, Types };
|
6
|
+
export { Client, Crypto, Utils, VoiceChatClient, Filters, Types };
|
package/rubjs/index.js
CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
37
37
|
};
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.Types = exports.Filters = exports.Utils = exports.Crypto = exports.Client = void 0;
|
39
|
+
exports.Types = exports.Filters = exports.VoiceChatClient = exports.Utils = exports.Crypto = exports.Client = void 0;
|
40
40
|
const client_1 = __importDefault(require("./client"));
|
41
41
|
exports.Client = client_1.default;
|
42
42
|
const crypto_1 = __importDefault(require("./crypto"));
|
@@ -46,4 +46,5 @@ exports.Types = Types;
|
|
46
46
|
const utils_1 = require("./utils");
|
47
47
|
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return utils_1.Filters; } });
|
48
48
|
Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return utils_1.Utils; } });
|
49
|
+
Object.defineProperty(exports, "VoiceChatClient", { enumerable: true, get: function () { return utils_1.VoiceChatClient; } });
|
49
50
|
exports.default = client_1.default;
|
@@ -6,10 +6,13 @@ import getProfileLinkItems from "./getProfileLinkItems";
|
|
6
6
|
import getRelatedObjects from "./getRelatedObjects";
|
7
7
|
import getTranscription from "./getTranscription";
|
8
8
|
import join from "./join";
|
9
|
+
import joinVoiceChat from "./joinVoiceChat";
|
9
10
|
import leaveChat from "./leaveChat";
|
10
11
|
import onEditMessages from "./onEditMessages";
|
11
12
|
import reportObject from "./reportObject";
|
12
13
|
import searchGlobalObjects from "./searchGlobalObjects";
|
14
|
+
import sendVoiceChatActivity from "./sendVoiceChatActivity";
|
15
|
+
import setVoiceChatState from "./setVoiceChatState";
|
13
16
|
import transcribeVoice from "./transcribeVoice";
|
14
17
|
import userIsAdmin from "./userIsAdmin";
|
15
|
-
export { banMember, getInfo, getObjectByUsername, getProfileLinkItems, getRelatedObjects, getTranscription, join, leaveChat, onEditMessages, reportObject, searchGlobalObjects, transcribeVoice, userIsAdmin, deleteMessagebyCount };
|
18
|
+
export { banMember, getInfo, getObjectByUsername, getProfileLinkItems, getRelatedObjects, getTranscription, join, leaveChat, onEditMessages, reportObject, searchGlobalObjects, transcribeVoice, userIsAdmin, deleteMessagebyCount, joinVoiceChat, setVoiceChatState, sendVoiceChatActivity };
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.deleteMessagebyCount = exports.userIsAdmin = exports.transcribeVoice = exports.searchGlobalObjects = exports.reportObject = exports.onEditMessages = exports.leaveChat = exports.join = exports.getTranscription = exports.getRelatedObjects = exports.getProfileLinkItems = exports.getObjectByUsername = exports.getInfo = exports.banMember = void 0;
|
6
|
+
exports.sendVoiceChatActivity = exports.setVoiceChatState = exports.joinVoiceChat = exports.deleteMessagebyCount = exports.userIsAdmin = exports.transcribeVoice = exports.searchGlobalObjects = exports.reportObject = exports.onEditMessages = exports.leaveChat = exports.join = exports.getTranscription = exports.getRelatedObjects = exports.getProfileLinkItems = exports.getObjectByUsername = exports.getInfo = exports.banMember = void 0;
|
7
7
|
const banMember_1 = __importDefault(require("./banMember"));
|
8
8
|
exports.banMember = banMember_1.default;
|
9
9
|
const deleteMessagebyCount_1 = __importDefault(require("./deleteMessagebyCount"));
|
@@ -20,6 +20,8 @@ const getTranscription_1 = __importDefault(require("./getTranscription"));
|
|
20
20
|
exports.getTranscription = getTranscription_1.default;
|
21
21
|
const join_1 = __importDefault(require("./join"));
|
22
22
|
exports.join = join_1.default;
|
23
|
+
const joinVoiceChat_1 = __importDefault(require("./joinVoiceChat"));
|
24
|
+
exports.joinVoiceChat = joinVoiceChat_1.default;
|
23
25
|
const leaveChat_1 = __importDefault(require("./leaveChat"));
|
24
26
|
exports.leaveChat = leaveChat_1.default;
|
25
27
|
const onEditMessages_1 = __importDefault(require("./onEditMessages"));
|
@@ -28,6 +30,10 @@ const reportObject_1 = __importDefault(require("./reportObject"));
|
|
28
30
|
exports.reportObject = reportObject_1.default;
|
29
31
|
const searchGlobalObjects_1 = __importDefault(require("./searchGlobalObjects"));
|
30
32
|
exports.searchGlobalObjects = searchGlobalObjects_1.default;
|
33
|
+
const sendVoiceChatActivity_1 = __importDefault(require("./sendVoiceChatActivity"));
|
34
|
+
exports.sendVoiceChatActivity = sendVoiceChatActivity_1.default;
|
35
|
+
const setVoiceChatState_1 = __importDefault(require("./setVoiceChatState"));
|
36
|
+
exports.setVoiceChatState = setVoiceChatState_1.default;
|
31
37
|
const transcribeVoice_1 = __importDefault(require("./transcribeVoice"));
|
32
38
|
exports.transcribeVoice = transcribeVoice_1.default;
|
33
39
|
const userIsAdmin_1 = __importDefault(require("./userIsAdmin"));
|
@@ -0,0 +1,22 @@
|
|
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
|
+
function joinVoiceChat(chat_guid, voice_chat_id, sdp_offer_data) {
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
14
|
+
return yield this.builder(chat_guid.startsWith("g0") ? "joinGroupVoiceChat" : "joinChannelVoiceChat", {
|
15
|
+
chat_guid,
|
16
|
+
voice_chat_id,
|
17
|
+
sdp_offer_data,
|
18
|
+
self_object_guid: this.userGuid,
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
22
|
+
exports.default = joinVoiceChat;
|
@@ -0,0 +1,24 @@
|
|
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
|
+
function sendVoiceChatActivity(chat_guid_1, voice_chat_id_1, participant_object_guid_1) {
|
13
|
+
return __awaiter(this, arguments, void 0, function* (chat_guid, voice_chat_id, participant_object_guid, activity = "Speaking") {
|
14
|
+
return yield this.builder(chat_guid.startsWith("g0")
|
15
|
+
? "sendGroupVoiceChatActivity"
|
16
|
+
: "sendChannelVoiceChatActivity", {
|
17
|
+
chat_guid,
|
18
|
+
voice_chat_id,
|
19
|
+
activity,
|
20
|
+
participant_object_guid: participant_object_guid || this.userGuid,
|
21
|
+
});
|
22
|
+
});
|
23
|
+
}
|
24
|
+
exports.default = sendVoiceChatActivity;
|
@@ -0,0 +1,25 @@
|
|
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
|
+
function setVoiceChatState(chat_guid_1, voice_chat_id_1, participant_object_guid_1) {
|
13
|
+
return __awaiter(this, arguments, void 0, function* (chat_guid, voice_chat_id, participant_object_guid, action = "Unmute") {
|
14
|
+
const method = chat_guid.startsWith("g0")
|
15
|
+
? "setGroupVoiceChatState"
|
16
|
+
: "setChannelVoiceChatState";
|
17
|
+
return yield this.builder(method, {
|
18
|
+
chat_guid,
|
19
|
+
voice_chat_id,
|
20
|
+
participant_object_guid,
|
21
|
+
action,
|
22
|
+
});
|
23
|
+
});
|
24
|
+
}
|
25
|
+
exports.default = setVoiceChatState;
|
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
function createGroupVoiceChat(
|
12
|
+
function createGroupVoiceChat(chat_guid) {
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
14
|
-
return yield this.builder("createGroupVoiceChat", {
|
14
|
+
return yield this.builder("createGroupVoiceChat", { chat_guid });
|
15
15
|
});
|
16
16
|
}
|
17
17
|
exports.default = createGroupVoiceChat;
|
@@ -0,0 +1,18 @@
|
|
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
|
+
function getGroupVoiceChatParticipants(chat_guid, voice_chat_id) {
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
14
|
+
return yield this.builder('getGroupVoiceChatParticipants', { chat_guid, voice_chat_id });
|
15
|
+
});
|
16
|
+
}
|
17
|
+
;
|
18
|
+
exports.default = getGroupVoiceChatParticipants;
|
@@ -14,9 +14,11 @@ import getGroupInfo from "./getGroupInfo";
|
|
14
14
|
import getGroupLink from "./getGroupLink";
|
15
15
|
import getGroupMentionList from "./getGroupMentionList";
|
16
16
|
import getGroupOnlineCount from "./getGroupOnlineCount";
|
17
|
+
import getGroupVoiceChatParticipants from "./getGroupVoiceChatParticipants";
|
17
18
|
import getGroupVoiceChatUpdates from "./getGroupVoiceChatUpdates";
|
18
19
|
import groupPreviewByJoinLink from "./groupPreviewByJoinLink";
|
19
20
|
import joinGroup from "./joinGroup";
|
21
|
+
import joinGroupVoiceChat from "./joinGroupVoiceChat";
|
20
22
|
import leaveGroup from "./leaveGroup";
|
21
23
|
import leaveGroupVoiceChat from "./leaveGroupVoiceChat";
|
22
24
|
import removeGroup from "./removeGroup";
|
@@ -25,4 +27,4 @@ import setGroupAdmin from "./setGroupAdmin";
|
|
25
27
|
import setGroupDefaultAccess from "./setGroupDefaultAccess";
|
26
28
|
import setGroupLink from "./setGroupLink";
|
27
29
|
import setGroupVoiceChatSetting from "./setGroupVoiceChatSetting";
|
28
|
-
export { addGroup, addGroupMembers, banGroupMember, seenGroupMessages, discardGroupVoiceChat, createGroupVoiceChat, deleteNoAccessGroupChat, editGroupInfo, getBannedGroupMembers, getGroupAdminAccessList, getGroupAdminMembers, getGroupAllMembers, getGroupDefaultAccess, getGroupInfo, getGroupLink, getGroupOnlineCount, getGroupMentionList, getGroupVoiceChatUpdates, groupPreviewByJoinLink, joinGroup, leaveGroup, leaveGroupVoiceChat, removeGroup, setGroupAdmin, setGroupDefaultAccess, setGroupLink, setGroupVoiceChatSetting, };
|
30
|
+
export { addGroup, addGroupMembers, banGroupMember, seenGroupMessages, discardGroupVoiceChat, createGroupVoiceChat, deleteNoAccessGroupChat, editGroupInfo, getBannedGroupMembers, getGroupAdminAccessList, getGroupAdminMembers, getGroupAllMembers, getGroupDefaultAccess, getGroupInfo, getGroupLink, getGroupOnlineCount, getGroupMentionList, getGroupVoiceChatUpdates, groupPreviewByJoinLink, joinGroup, leaveGroup, leaveGroupVoiceChat, removeGroup, setGroupAdmin, setGroupDefaultAccess, setGroupLink, setGroupVoiceChatSetting, joinGroupVoiceChat, getGroupVoiceChatParticipants, };
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.setGroupVoiceChatSetting = exports.setGroupLink = exports.setGroupDefaultAccess = exports.setGroupAdmin = exports.removeGroup = exports.leaveGroupVoiceChat = exports.leaveGroup = exports.joinGroup = exports.groupPreviewByJoinLink = exports.getGroupVoiceChatUpdates = exports.getGroupMentionList = exports.getGroupOnlineCount = exports.getGroupLink = exports.getGroupInfo = exports.getGroupDefaultAccess = exports.getGroupAllMembers = exports.getGroupAdminMembers = exports.getGroupAdminAccessList = exports.getBannedGroupMembers = exports.editGroupInfo = exports.deleteNoAccessGroupChat = exports.createGroupVoiceChat = exports.discardGroupVoiceChat = exports.seenGroupMessages = exports.banGroupMember = exports.addGroupMembers = exports.addGroup = void 0;
|
6
|
+
exports.getGroupVoiceChatParticipants = exports.joinGroupVoiceChat = exports.setGroupVoiceChatSetting = exports.setGroupLink = exports.setGroupDefaultAccess = exports.setGroupAdmin = exports.removeGroup = exports.leaveGroupVoiceChat = exports.leaveGroup = exports.joinGroup = exports.groupPreviewByJoinLink = exports.getGroupVoiceChatUpdates = exports.getGroupMentionList = exports.getGroupOnlineCount = exports.getGroupLink = exports.getGroupInfo = exports.getGroupDefaultAccess = exports.getGroupAllMembers = exports.getGroupAdminMembers = exports.getGroupAdminAccessList = exports.getBannedGroupMembers = exports.editGroupInfo = exports.deleteNoAccessGroupChat = exports.createGroupVoiceChat = exports.discardGroupVoiceChat = exports.seenGroupMessages = exports.banGroupMember = exports.addGroupMembers = exports.addGroup = void 0;
|
7
7
|
const addGroup_1 = __importDefault(require("./addGroup"));
|
8
8
|
exports.addGroup = addGroup_1.default;
|
9
9
|
const addGroupMembers_1 = __importDefault(require("./addGroupMembers"));
|
@@ -36,12 +36,16 @@ const getGroupMentionList_1 = __importDefault(require("./getGroupMentionList"));
|
|
36
36
|
exports.getGroupMentionList = getGroupMentionList_1.default;
|
37
37
|
const getGroupOnlineCount_1 = __importDefault(require("./getGroupOnlineCount"));
|
38
38
|
exports.getGroupOnlineCount = getGroupOnlineCount_1.default;
|
39
|
+
const getGroupVoiceChatParticipants_1 = __importDefault(require("./getGroupVoiceChatParticipants"));
|
40
|
+
exports.getGroupVoiceChatParticipants = getGroupVoiceChatParticipants_1.default;
|
39
41
|
const getGroupVoiceChatUpdates_1 = __importDefault(require("./getGroupVoiceChatUpdates"));
|
40
42
|
exports.getGroupVoiceChatUpdates = getGroupVoiceChatUpdates_1.default;
|
41
43
|
const groupPreviewByJoinLink_1 = __importDefault(require("./groupPreviewByJoinLink"));
|
42
44
|
exports.groupPreviewByJoinLink = groupPreviewByJoinLink_1.default;
|
43
45
|
const joinGroup_1 = __importDefault(require("./joinGroup"));
|
44
46
|
exports.joinGroup = joinGroup_1.default;
|
47
|
+
const joinGroupVoiceChat_1 = __importDefault(require("./joinGroupVoiceChat"));
|
48
|
+
exports.joinGroupVoiceChat = joinGroupVoiceChat_1.default;
|
45
49
|
const leaveGroup_1 = __importDefault(require("./leaveGroup"));
|
46
50
|
exports.leaveGroup = leaveGroup_1.default;
|
47
51
|
const leaveGroupVoiceChat_1 = __importDefault(require("./leaveGroupVoiceChat"));
|
@@ -0,0 +1,22 @@
|
|
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
|
+
function joinGroupVoiceChat(chat_guid, voice_chat_id, sdp_offer_data, self_object_guid) {
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
14
|
+
return yield this.builder("joinGroupVoiceChat", {
|
15
|
+
chat_guid,
|
16
|
+
voice_chat_id,
|
17
|
+
sdp_offer_data,
|
18
|
+
self_object_guid,
|
19
|
+
});
|
20
|
+
});
|
21
|
+
}
|
22
|
+
exports.default = joinGroupVoiceChat;
|
package/rubjs/methods/index.d.ts
CHANGED
@@ -101,6 +101,9 @@ declare class Methods {
|
|
101
101
|
transcribeVoice(this: Client, ...args: Parameters<typeof Extras.transcribeVoice>): Promise<any>;
|
102
102
|
userIsAdmin(this: Client, ...args: Parameters<typeof Extras.userIsAdmin>): Promise<any>;
|
103
103
|
deleteMessagebyCount(this: Client, ...args: Parameters<typeof Extras.deleteMessagebyCount>): Promise<any>;
|
104
|
+
joinVoiceChat(this: Client, ...args: Parameters<typeof Extras.joinVoiceChat>): Promise<any>;
|
105
|
+
setVoiceChatState(this: Client, ...args: Parameters<typeof Extras.setVoiceChatState>): Promise<any>;
|
106
|
+
sendVoiceChatActivity(this: Client, ...args: Parameters<typeof Extras.sendVoiceChatActivity>): Promise<any>;
|
104
107
|
addToMyGifSet(this: Client, ...args: Parameters<typeof Gif.addToMyGifSet>): Promise<any>;
|
105
108
|
getMyGifSet(this: Client, ...args: Parameters<typeof Gif.getMyGifSet>): Promise<any>;
|
106
109
|
removeFromMyGifSet(this: Client, ...args: Parameters<typeof Gif.removeFromMyGifSet>): Promise<any>;
|
@@ -131,6 +134,8 @@ declare class Methods {
|
|
131
134
|
seenGroupMessages(this: Client, ...args: Parameters<typeof Groups.seenGroupMessages>): Promise<any>;
|
132
135
|
setGroupLink(this: Client, ...args: Parameters<typeof Groups.setGroupLink>): Promise<any>;
|
133
136
|
setGroupVoiceChatSetting(this: Client, ...args: Parameters<typeof Groups.setGroupVoiceChatSetting>): Promise<any>;
|
137
|
+
joinGroupVoiceChat(this: Client, ...args: Parameters<typeof Groups.joinGroupVoiceChat>): Promise<any>;
|
138
|
+
getGroupVoiceChatParticipants(this: Client, ...args: Parameters<typeof Groups.getGroupVoiceChatParticipants>): Promise<any>;
|
134
139
|
actionOnMessageReaction(this: Client, ...args: Parameters<typeof Messages.actionOnMessageReaction>): Promise<{
|
135
140
|
reactions: MessagesTypes.Reaction[];
|
136
141
|
}>;
|
package/rubjs/methods/index.js
CHANGED
@@ -470,6 +470,21 @@ class Methods {
|
|
470
470
|
return Extras.deleteMessagebyCount.apply(this, args);
|
471
471
|
});
|
472
472
|
}
|
473
|
+
joinVoiceChat(...args) {
|
474
|
+
return __awaiter(this, void 0, void 0, function* () {
|
475
|
+
return Extras.joinVoiceChat.apply(this, args);
|
476
|
+
});
|
477
|
+
}
|
478
|
+
setVoiceChatState(...args) {
|
479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
480
|
+
return Extras.setVoiceChatState.apply(this, args);
|
481
|
+
});
|
482
|
+
}
|
483
|
+
sendVoiceChatActivity(...args) {
|
484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
485
|
+
return Extras.sendVoiceChatActivity.apply(this, args);
|
486
|
+
});
|
487
|
+
}
|
473
488
|
// gif
|
474
489
|
addToMyGifSet(...args) {
|
475
490
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -622,6 +637,16 @@ class Methods {
|
|
622
637
|
return Groups.setGroupVoiceChatSetting.apply(this, args);
|
623
638
|
});
|
624
639
|
}
|
640
|
+
joinGroupVoiceChat(...args) {
|
641
|
+
return __awaiter(this, void 0, void 0, function* () {
|
642
|
+
return Groups.joinGroupVoiceChat.apply(this, args);
|
643
|
+
});
|
644
|
+
}
|
645
|
+
getGroupVoiceChatParticipants(...args) {
|
646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
647
|
+
return Groups.getGroupVoiceChatParticipants.apply(this, args);
|
648
|
+
});
|
649
|
+
}
|
625
650
|
// messages
|
626
651
|
actionOnMessageReaction(...args) {
|
627
652
|
return __awaiter(this, void 0, void 0, function* () {
|
package/rubjs/types/message.js
CHANGED
@@ -11,9 +11,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
const getOriginalType = (message) => {
|
13
13
|
var _a;
|
14
|
-
if (!((_a = message === null || message === void 0 ? void 0 : message.message) === null || _a === void 0 ? void 0 : _a.type))
|
15
|
-
return
|
16
|
-
}
|
14
|
+
if (!((_a = message === null || message === void 0 ? void 0 : message.message) === null || _a === void 0 ? void 0 : _a.type))
|
15
|
+
return "Delete";
|
17
16
|
if (message.message.type.includes("FileInline")) {
|
18
17
|
return message.message.file_inline.type;
|
19
18
|
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import Client from "..";
|
2
|
+
declare class VoiceChatClient {
|
3
|
+
private pc;
|
4
|
+
private source;
|
5
|
+
private track;
|
6
|
+
private ffmpeg?;
|
7
|
+
private buffer;
|
8
|
+
private frameSize;
|
9
|
+
private playlist;
|
10
|
+
private currentIndex;
|
11
|
+
private chatGuid?;
|
12
|
+
private voiceChatId?;
|
13
|
+
private client?;
|
14
|
+
private isPaused;
|
15
|
+
private lastPosition;
|
16
|
+
private intervalId?;
|
17
|
+
private isManualSkip;
|
18
|
+
constructor();
|
19
|
+
play(filePath?: string): Promise<void>;
|
20
|
+
stop(): void;
|
21
|
+
resume(): void;
|
22
|
+
next(): void;
|
23
|
+
previous(): void;
|
24
|
+
addToPlaylist(filePath: string): void;
|
25
|
+
removeFromPlaylist(filePath: string): void;
|
26
|
+
joinVoiceChat(chatGuid: string, voiceChatId: string, client: Client): Promise<void>;
|
27
|
+
private clearIntervals;
|
28
|
+
}
|
29
|
+
export default VoiceChatClient;
|
@@ -0,0 +1,163 @@
|
|
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 child_process_1 = require("child_process");
|
13
|
+
const wrtc_1 = require("wrtc");
|
14
|
+
class VoiceChatClient {
|
15
|
+
constructor() {
|
16
|
+
this.buffer = Buffer.alloc(0);
|
17
|
+
this.frameSize = 960;
|
18
|
+
this.playlist = [];
|
19
|
+
this.currentIndex = 0;
|
20
|
+
this.isPaused = false;
|
21
|
+
this.lastPosition = 0;
|
22
|
+
this.isManualSkip = false;
|
23
|
+
this.pc = new wrtc_1.RTCPeerConnection();
|
24
|
+
this.source = new wrtc_1.nonstandard.RTCAudioSource();
|
25
|
+
this.track = this.source.createTrack();
|
26
|
+
this.pc.addTrack(this.track);
|
27
|
+
}
|
28
|
+
play(filePath) {
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
30
|
+
if (this.ffmpeg)
|
31
|
+
this.stop();
|
32
|
+
if (!filePath) {
|
33
|
+
if (this.playlist.length === 0)
|
34
|
+
return;
|
35
|
+
filePath = this.playlist[this.currentIndex];
|
36
|
+
}
|
37
|
+
if (!this.chatGuid || !this.voiceChatId || !this.client) {
|
38
|
+
throw new Error("Voice chat not initialized. Call `joinVoiceChat` first.");
|
39
|
+
}
|
40
|
+
this.isPaused = false;
|
41
|
+
this.isManualSkip = false;
|
42
|
+
this.buffer = Buffer.alloc(0);
|
43
|
+
const seekArgs = this.lastPosition > 0 ? ["-ss", this.lastPosition.toString()] : [];
|
44
|
+
this.ffmpeg = (0, child_process_1.spawn)("ffmpeg", [
|
45
|
+
"-loglevel",
|
46
|
+
"quiet",
|
47
|
+
"-re",
|
48
|
+
"-threads",
|
49
|
+
"1",
|
50
|
+
"-protocol_whitelist",
|
51
|
+
"file,http,https,tcp,tls",
|
52
|
+
...seekArgs,
|
53
|
+
"-i",
|
54
|
+
filePath,
|
55
|
+
"-acodec",
|
56
|
+
"pcm_s16le",
|
57
|
+
"-ar",
|
58
|
+
"48000",
|
59
|
+
"-ac",
|
60
|
+
"1",
|
61
|
+
"-f",
|
62
|
+
"s16le",
|
63
|
+
"pipe:1",
|
64
|
+
]);
|
65
|
+
this.ffmpeg.stdout.on("data", (chunk) => {
|
66
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
67
|
+
while (this.buffer.length >= this.frameSize) {
|
68
|
+
if (this.isPaused)
|
69
|
+
return;
|
70
|
+
const frame = this.buffer.subarray(0, this.frameSize);
|
71
|
+
this.buffer = this.buffer.subarray(this.frameSize);
|
72
|
+
const samples = new Int16Array(frame.buffer, frame.byteOffset, this.frameSize / 2);
|
73
|
+
const trimmedSamples = samples.slice(0, 960);
|
74
|
+
this.source.onData({ samples: trimmedSamples, sampleRate: 48000 });
|
75
|
+
this.lastPosition += 0.02;
|
76
|
+
}
|
77
|
+
});
|
78
|
+
this.ffmpeg.on("close", (code) => {
|
79
|
+
if (!this.isManualSkip && code !== null && !this.isPaused) {
|
80
|
+
this.next();
|
81
|
+
}
|
82
|
+
this.isManualSkip = false;
|
83
|
+
});
|
84
|
+
});
|
85
|
+
}
|
86
|
+
stop() {
|
87
|
+
if (this.ffmpeg) {
|
88
|
+
this.ffmpeg.kill();
|
89
|
+
this.ffmpeg = undefined;
|
90
|
+
this.isPaused = true;
|
91
|
+
this.buffer = Buffer.alloc(0);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
resume() {
|
95
|
+
if (this.isPaused)
|
96
|
+
this.play();
|
97
|
+
}
|
98
|
+
next() {
|
99
|
+
if (this.playlist.length > this.currentIndex + 1) {
|
100
|
+
this.isManualSkip = true;
|
101
|
+
this.stop();
|
102
|
+
this.currentIndex += 1;
|
103
|
+
this.lastPosition = 0;
|
104
|
+
this.isPaused = true;
|
105
|
+
this.play(this.playlist[this.currentIndex]);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
previous() {
|
109
|
+
if (this.currentIndex > 0) {
|
110
|
+
this.isManualSkip = true;
|
111
|
+
this.stop();
|
112
|
+
this.currentIndex--;
|
113
|
+
this.lastPosition = 0;
|
114
|
+
this.isPaused = true;
|
115
|
+
this.play();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
addToPlaylist(filePath) {
|
119
|
+
this.playlist.push(filePath);
|
120
|
+
}
|
121
|
+
removeFromPlaylist(filePath) {
|
122
|
+
const index = this.playlist.indexOf(filePath);
|
123
|
+
if (index !== -1) {
|
124
|
+
this.playlist.splice(index, 1);
|
125
|
+
if (index <= this.currentIndex && this.currentIndex > 0) {
|
126
|
+
this.currentIndex--;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
joinVoiceChat(chatGuid, voiceChatId, client) {
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
132
|
+
this.chatGuid = chatGuid;
|
133
|
+
this.voiceChatId = voiceChatId;
|
134
|
+
this.client = client;
|
135
|
+
const offer = yield this.pc.createOffer();
|
136
|
+
yield this.pc.setLocalDescription(offer);
|
137
|
+
const connect = yield client.joinGroupVoiceChat(chatGuid, voiceChatId, offer.sdp, client.userGuid);
|
138
|
+
const sdpAnswer = connect.sdp_answer_data;
|
139
|
+
yield this.pc.setRemoteDescription(new wrtc_1.RTCSessionDescription({ type: "answer", sdp: sdpAnswer }));
|
140
|
+
yield client.setVoiceChatState(chatGuid, voiceChatId);
|
141
|
+
this.clearIntervals();
|
142
|
+
this.intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
143
|
+
try {
|
144
|
+
yield client.getGroupVoiceChatUpdates(chatGuid, voiceChatId);
|
145
|
+
}
|
146
|
+
catch (_a) { }
|
147
|
+
}), 10 * 1000);
|
148
|
+
this.intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
149
|
+
try {
|
150
|
+
yield client.sendVoiceChatActivity(chatGuid, voiceChatId, client.userGuid);
|
151
|
+
}
|
152
|
+
catch (_a) { }
|
153
|
+
}), 2 * 1000);
|
154
|
+
});
|
155
|
+
}
|
156
|
+
clearIntervals() {
|
157
|
+
if (this.intervalId) {
|
158
|
+
clearInterval(this.intervalId);
|
159
|
+
this.intervalId = undefined;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
exports.default = VoiceChatClient;
|
package/rubjs/utils/filters.d.ts
CHANGED
@@ -26,5 +26,7 @@ declare class Filters {
|
|
26
26
|
static isPoll(message: MessageUpdate): boolean;
|
27
27
|
static isLive(message: MessageUpdate): boolean;
|
28
28
|
static isEvent(message: MessageUpdate): boolean;
|
29
|
+
static startsWithCommand(text: string, object_guid?: string): (message: MessageUpdate) => boolean;
|
30
|
+
static equalCommand(text: string, object_guid?: string): (message: MessageUpdate) => boolean;
|
29
31
|
}
|
30
32
|
export default Filters;
|
package/rubjs/utils/filters.js
CHANGED
@@ -122,5 +122,29 @@ class Filters {
|
|
122
122
|
static isEvent(message) {
|
123
123
|
return !!Filters.findKey(message, "event_data");
|
124
124
|
}
|
125
|
+
static startsWithCommand(text, object_guid) {
|
126
|
+
return (message) => {
|
127
|
+
var _a;
|
128
|
+
if (object_guid) {
|
129
|
+
if (object_guid !== message.object_guid)
|
130
|
+
return false;
|
131
|
+
}
|
132
|
+
if ((_a = message === null || message === void 0 ? void 0 : message.message) === null || _a === void 0 ? void 0 : _a.text) {
|
133
|
+
return message.message.text.startsWith(text);
|
134
|
+
}
|
135
|
+
};
|
136
|
+
}
|
137
|
+
static equalCommand(text, object_guid) {
|
138
|
+
return (message) => {
|
139
|
+
var _a;
|
140
|
+
if (object_guid) {
|
141
|
+
if (object_guid !== message.object_guid)
|
142
|
+
return false;
|
143
|
+
}
|
144
|
+
if ((_a = message === null || message === void 0 ? void 0 : message.message) === null || _a === void 0 ? void 0 : _a.text) {
|
145
|
+
return message.message.text === text;
|
146
|
+
}
|
147
|
+
};
|
148
|
+
}
|
125
149
|
}
|
126
150
|
exports.default = Filters;
|
package/rubjs/utils/index.d.ts
CHANGED
package/rubjs/utils/index.js
CHANGED
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.Utils = exports.Filters = void 0;
|
6
|
+
exports.VoiceChatClient = exports.Utils = exports.Filters = void 0;
|
7
7
|
const filters_1 = __importDefault(require("./filters"));
|
8
8
|
exports.Filters = filters_1.default;
|
9
9
|
const utils_1 = __importDefault(require("./utils"));
|
10
10
|
exports.Utils = utils_1.default;
|
11
|
+
const VoiceChatClient_1 = __importDefault(require("./VoiceChatClient"));
|
12
|
+
exports.VoiceChatClient = VoiceChatClient_1.default;
|