rubjs 2.6.1 → 2.7.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rubjs",
3
- "version": "2.6.1",
3
+ "version": "2.7.3",
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,3 @@
1
+ import Client from "../..";
2
+ declare function joinVoiceChat(this: Client, chat_guid: string, voice_chat_id: string, sdp_offer_data: string): Promise<any>;
3
+ export default joinVoiceChat;
@@ -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,3 @@
1
+ import Client from "../..";
2
+ declare function sendVoiceChatActivity(this: Client, chat_guid: string, voice_chat_id: string, participant_object_guid: string, activity?: "Speaking"): Promise<any>;
3
+ export default sendVoiceChatActivity;
@@ -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,3 @@
1
+ import Client from "../..";
2
+ declare function setVoiceChatState(this: Client, chat_guid: string, voice_chat_id: string, participant_object_guid?: string, action?: "Mute" | "Unmute"): Promise<any>;
3
+ export default setVoiceChatState;
@@ -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;
@@ -1,3 +1,3 @@
1
1
  import Client from "../..";
2
- declare function createGroupVoiceChat(this: Client, group_guid: string): Promise<any>;
2
+ declare function createGroupVoiceChat(this: Client, chat_guid: string): Promise<any>;
3
3
  export default createGroupVoiceChat;
@@ -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(group_guid) {
12
+ function createGroupVoiceChat(chat_guid) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
- return yield this.builder("createGroupVoiceChat", { group_guid });
14
+ return yield this.builder("createGroupVoiceChat", { chat_guid });
15
15
  });
16
16
  }
17
17
  exports.default = createGroupVoiceChat;
@@ -0,0 +1,3 @@
1
+ import Client from '../..';
2
+ declare function getGroupVoiceChatParticipants(this: Client, chat_guid: string, voice_chat_id: string): Promise<any>;
3
+ export default getGroupVoiceChatParticipants;
@@ -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,3 @@
1
+ import Client from "../..";
2
+ declare function joinGroupVoiceChat(this: Client, chat_guid: string, voice_chat_id: string, sdp_offer_data: string, self_object_guid: string): Promise<any>;
3
+ export default joinGroupVoiceChat;
@@ -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;
@@ -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
  }>;
@@ -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* () {
@@ -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 console.log(message);
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,27 @@
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
+ constructor();
18
+ play(filePath?: string): Promise<void>;
19
+ stop(): void;
20
+ resume(): void;
21
+ next(): void;
22
+ previous(): void;
23
+ addToPlaylist(filePath: string): void;
24
+ joinVoiceChat(chatGuid: string, voiceChatId: string, client: Client): Promise<void>;
25
+ private clearIntervals;
26
+ }
27
+ export default VoiceChatClient;
@@ -0,0 +1,133 @@
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.pc = new wrtc_1.RTCPeerConnection();
23
+ this.source = new wrtc_1.nonstandard.RTCAudioSource();
24
+ this.track = this.source.createTrack();
25
+ this.pc.addTrack(this.track);
26
+ }
27
+ play(filePath) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ if (this.ffmpeg)
30
+ this.stop();
31
+ if (!filePath) {
32
+ if (this.playlist.length === 0)
33
+ return;
34
+ filePath = this.playlist[this.currentIndex];
35
+ }
36
+ if (!this.chatGuid || !this.voiceChatId || !this.client) {
37
+ throw new Error("Voice chat not initialized. Call `joinVoiceChat` first.");
38
+ }
39
+ this.isPaused = false;
40
+ this.buffer = Buffer.alloc(0);
41
+ const seekArgs = this.lastPosition > 0 ? ["-ss", this.lastPosition.toString()] : [];
42
+ this.ffmpeg = (0, child_process_1.spawn)("ffmpeg", [
43
+ "-loglevel", "quiet",
44
+ "-re",
45
+ "-threads", "1", // کاهش مصرف رم و پردازش
46
+ ...seekArgs,
47
+ "-i", filePath,
48
+ "-acodec", "pcm_s16le",
49
+ "-ar", "48000",
50
+ "-ac", "1",
51
+ "-f", "s16le",
52
+ "pipe:1",
53
+ ]);
54
+ this.ffmpeg.stdout.on("data", (chunk) => {
55
+ this.buffer = Buffer.concat([this.buffer, chunk]);
56
+ while (this.buffer.length >= this.frameSize) {
57
+ if (this.isPaused)
58
+ return;
59
+ const frame = this.buffer.subarray(0, this.frameSize);
60
+ this.buffer = this.buffer.subarray(this.frameSize);
61
+ const samples = new Int16Array(frame.buffer, frame.byteOffset, this.frameSize / 2);
62
+ const trimmedSamples = samples.slice(0, 960);
63
+ this.source.onData({ samples: trimmedSamples, sampleRate: 48000 });
64
+ this.lastPosition += 0.02;
65
+ }
66
+ });
67
+ this.ffmpeg.on("close", () => this.next());
68
+ this.ffmpeg.on("exit", () => this.next());
69
+ });
70
+ }
71
+ stop() {
72
+ if (this.ffmpeg) {
73
+ this.ffmpeg.kill();
74
+ this.ffmpeg = undefined;
75
+ this.isPaused = true;
76
+ this.buffer = Buffer.alloc(0); // پاک کردن بافر برای کاهش مصرف رم
77
+ }
78
+ }
79
+ resume() {
80
+ if (this.isPaused)
81
+ this.play();
82
+ }
83
+ next() {
84
+ if (this.playlist.length > this.currentIndex + 1) {
85
+ this.currentIndex++;
86
+ this.lastPosition = 0;
87
+ this.play();
88
+ }
89
+ }
90
+ previous() {
91
+ if (this.currentIndex > 0) {
92
+ this.currentIndex--;
93
+ this.lastPosition = 0;
94
+ this.play();
95
+ }
96
+ }
97
+ addToPlaylist(filePath) {
98
+ this.playlist.push(filePath);
99
+ }
100
+ joinVoiceChat(chatGuid, voiceChatId, client) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ this.chatGuid = chatGuid;
103
+ this.voiceChatId = voiceChatId;
104
+ this.client = client;
105
+ const offer = yield this.pc.createOffer();
106
+ yield this.pc.setLocalDescription(offer);
107
+ const connect = yield client.joinGroupVoiceChat(chatGuid, voiceChatId, offer.sdp, client.userGuid);
108
+ const sdpAnswer = connect.sdp_answer_data;
109
+ yield this.pc.setRemoteDescription(new wrtc_1.RTCSessionDescription({ type: "answer", sdp: sdpAnswer }));
110
+ yield client.setVoiceChatState(chatGuid, voiceChatId);
111
+ this.clearIntervals();
112
+ this.intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
113
+ try {
114
+ yield client.getGroupVoiceChatUpdates(chatGuid, voiceChatId);
115
+ }
116
+ catch (_a) { }
117
+ }), 10 * 1000);
118
+ this.intervalId = setInterval(() => __awaiter(this, void 0, void 0, function* () {
119
+ try {
120
+ yield client.sendVoiceChatActivity(chatGuid, voiceChatId, client.userGuid);
121
+ }
122
+ catch (_a) { }
123
+ }), 2 * 1000);
124
+ });
125
+ }
126
+ clearIntervals() {
127
+ if (this.intervalId) {
128
+ clearInterval(this.intervalId);
129
+ this.intervalId = undefined;
130
+ }
131
+ }
132
+ }
133
+ exports.default = VoiceChatClient;
@@ -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;
@@ -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;
@@ -1,3 +1,4 @@
1
1
  import Filters from "./filters";
2
2
  import Utils from "./utils";
3
- export { Filters, Utils };
3
+ import VoiceChatClient from "./VoiceChatClient";
4
+ export { Filters, Utils, VoiceChatClient };
@@ -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;