wbstream support
This commit is contained in:
1 parent
b48b0cb927
commit
3b3ffed0b3
49 files changed
+3060
-151
No files matched your search
@@ -163,7 +163,10 @@ export class BotManager {
|
||||
if (payload?.cmd) {
|
||||
const handled = await this.handlePayloadCommand(payload, peerId);
|
||||
if (handled) return;
|
||||
const cmdPrefix = payload.cmd === BotCommand.VK ? '/vk' : payload.cmd === BotCommand.TM ? '/tm' : null;
|
||||
let cmdPrefix: string | null = null;
|
||||
if (payload.cmd === BotCommand.VK) cmdPrefix = '/vk';
|
||||
else if (payload.cmd === BotCommand.TM) cmdPrefix = '/tm';
|
||||
else if (payload.cmd === BotCommand.WB) cmdPrefix = '/wb';
|
||||
if (cmdPrefix && payload.mode) {
|
||||
text = `${cmdPrefix} ${payload.mode}`;
|
||||
}
|
||||
@@ -195,6 +198,7 @@ export class BotManager {
|
||||
}
|
||||
|
||||
private parseTunnelMode(text: string, platform: Platform): TunnelMode {
|
||||
if (platform === Platform.WBStream) return TunnelMode.HeadlessWBStream;
|
||||
if (text.includes('headless')) {
|
||||
return platform === Platform.VK ? TunnelMode.HeadlessVK : TunnelMode.HeadlessTelemost;
|
||||
}
|
||||
@@ -206,6 +210,7 @@ export class BotManager {
|
||||
switch (mode) {
|
||||
case TunnelMode.HeadlessVK:
|
||||
case TunnelMode.HeadlessTelemost:
|
||||
case TunnelMode.HeadlessWBStream:
|
||||
return 'Headless';
|
||||
case TunnelMode.PionVideo:
|
||||
return 'Video';
|
||||
@@ -225,6 +230,11 @@ export class BotManager {
|
||||
console.log('[BOT] Creating Telemost tab with mode:', mode);
|
||||
this.onCreateTab({ mode, peerId, platform: Platform.Telemost });
|
||||
await this.sendMessage(peerId, `Creating Telemost call (${this.tunnelModeLabel(mode)})`, createMainKeyboard());
|
||||
} else if (text.startsWith('/wb')) {
|
||||
const mode = this.parseTunnelMode(text, Platform.WBStream);
|
||||
console.log('[BOT] Creating WB Stream tab with mode:', mode);
|
||||
this.onCreateTab({ mode, peerId, platform: Platform.WBStream });
|
||||
await this.sendMessage(peerId, `Creating WB Stream room (${this.tunnelModeLabel(mode)})`, createMainKeyboard());
|
||||
} else if (text === '/list') {
|
||||
await this.showList(peerId);
|
||||
} else if (text.startsWith('/close ')) {
|
||||
|
||||
@@ -34,6 +34,9 @@ export function createMainKeyboard() {
|
||||
{ action: { type: 'text', label: '📹 TM Video', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'video' }) } },
|
||||
{ action: { type: 'text', label: '👻 TM Headless', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'headless' }) } },
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: '👻 WB Headless', payload: JSON.stringify({ cmd: BotCommand.WB, mode: 'headless' }) } },
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: '📋 Active Tabs', payload: JSON.stringify({ cmd: BotCommand.List }) } },
|
||||
],
|
||||
|
||||
@@ -37,6 +37,7 @@ export class TabManager {
|
||||
private relayPath: string;
|
||||
private headlessVKPath: string;
|
||||
private headlessTelemostPath: string;
|
||||
private headlessWBStreamPath: string;
|
||||
private hooksDir: string;
|
||||
|
||||
constructor() {
|
||||
@@ -52,6 +53,10 @@ export class TabManager {
|
||||
path.join('headless', 'telemost', binaryName('headless-telemost-creator')),
|
||||
binaryName('headless-telemost-creator'),
|
||||
);
|
||||
this.headlessWBStreamPath = resolveResourcePath(
|
||||
path.join('headless', 'wbstream', binaryName('headless-wbstream-creator')),
|
||||
binaryName('headless-wbstream-creator'),
|
||||
);
|
||||
this.hooksDir = app.isPackaged
|
||||
? path.join(process.resourcesPath!, 'hooks')
|
||||
: path.join(__dirname, '..', '..', '..', 'hooks');
|
||||
@@ -217,9 +222,24 @@ export class TabManager {
|
||||
|
||||
async startHeadless(tabId: string, platform: Platform): Promise<void> {
|
||||
const tab = await this.getOrCreateTab(tabId);
|
||||
tab.platform = platform;
|
||||
|
||||
if (platform === Platform.WBStream) {
|
||||
tab.tunnelMode = TunnelMode.HeadlessWBStream;
|
||||
this.killRelay(tabId, tab);
|
||||
const proc = spawn(this.headlessWBStreamPath, ['--resources', 'default'], {
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
});
|
||||
tab.relay = proc;
|
||||
this.attachProcessOutput(proc, tabId);
|
||||
proc.on('close', (code) => {
|
||||
this.sendLog(tabId, `Headless exited with code ${code}`);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const isTelemost = platform === Platform.Telemost;
|
||||
tab.tunnelMode = isTelemost ? TunnelMode.HeadlessTelemost : TunnelMode.HeadlessVK;
|
||||
tab.platform = platform;
|
||||
const cookies = isTelemost
|
||||
? await this.getYandexCookies()
|
||||
: await this.getVKCookies();
|
||||
|
||||
@@ -45,28 +45,33 @@ export function renderContent(tm: RendererTabManager): void {
|
||||
if (activeTab.headless) {
|
||||
toolbar.style.display = 'none';
|
||||
headlessInfo.style.display = 'block';
|
||||
const title = activeTab.platform === Platform.Telemost ? 'Headless Telemost' : 'Headless VK';
|
||||
let title = 'Headless VK';
|
||||
if (activeTab.platform === Platform.Telemost) title = 'Headless Telemost';
|
||||
else if (activeTab.platform === Platform.WBStream) title = 'Headless WB Stream';
|
||||
document.getElementById('headlessTitle')!.textContent = title;
|
||||
document.getElementById('headlessStatus')!.textContent = activeTab.headlessStatus || 'Starting...';
|
||||
const callInfo = activeTab.callInfo;
|
||||
const isTelemost = activeTab.platform === Platform.Telemost;
|
||||
const callInfoVK = document.getElementById('headlessCallInfo')!;
|
||||
const callInfoTM = document.getElementById('headlessCallInfoTM')!;
|
||||
if (callInfo && isTelemost) {
|
||||
callInfoVK.style.display = 'none';
|
||||
callInfoTM.style.display = 'block';
|
||||
document.getElementById('headlessTMJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
document.getElementById('headlessTMProtocol')!.textContent = callInfo.protocol || '';
|
||||
} else if (callInfo) {
|
||||
callInfoTM.style.display = 'none';
|
||||
callInfoVK.style.display = 'block';
|
||||
document.getElementById('headlessJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
document.getElementById('headlessShortLink')!.textContent = callInfo.shortLink || '';
|
||||
document.getElementById('headlessTurn')!.textContent = callInfo.turn || '';
|
||||
document.getElementById('headlessProtocol')!.textContent = callInfo.protocol || '';
|
||||
} else {
|
||||
callInfoVK.style.display = 'none';
|
||||
callInfoTM.style.display = 'none';
|
||||
const callInfoWB = document.getElementById('headlessCallInfoWB')!;
|
||||
callInfoVK.style.display = 'none';
|
||||
callInfoTM.style.display = 'none';
|
||||
callInfoWB.style.display = 'none';
|
||||
if (callInfo) {
|
||||
if (activeTab.platform === Platform.WBStream) {
|
||||
callInfoWB.style.display = 'block';
|
||||
document.getElementById('headlessWBJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
} else if (activeTab.platform === Platform.Telemost) {
|
||||
callInfoTM.style.display = 'block';
|
||||
document.getElementById('headlessTMJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
document.getElementById('headlessTMProtocol')!.textContent = callInfo.protocol || '';
|
||||
} else {
|
||||
callInfoVK.style.display = 'block';
|
||||
document.getElementById('headlessJoinLink')!.textContent = callInfo.joinLink || '';
|
||||
document.getElementById('headlessShortLink')!.textContent = callInfo.shortLink || '';
|
||||
document.getElementById('headlessTurn')!.textContent = callInfo.turn || '';
|
||||
document.getElementById('headlessProtocol')!.textContent = callInfo.protocol || '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toolbar.style.display = 'flex';
|
||||
|
||||
@@ -55,6 +55,7 @@ function bindToolbarEvents(): void {
|
||||
document.getElementById('btnTelemost')!.addEventListener('click', () => loadURL(tm, TELEMOST_URL));
|
||||
document.getElementById('btnHeadlessVK')!.addEventListener('click', () => tm.switchToHeadless(Platform.VK));
|
||||
document.getElementById('btnHeadlessTM')!.addEventListener('click', () => tm.switchToHeadless(Platform.Telemost));
|
||||
document.getElementById('btnHeadlessWB')!.addEventListener('click', () => tm.switchToHeadless(Platform.WBStream));
|
||||
document.getElementById('modeSelect')!.addEventListener('change', (event) => {
|
||||
tm.setTunnelMode((event.target as HTMLSelectElement).value);
|
||||
});
|
||||
@@ -159,6 +160,8 @@ function init(): void {
|
||||
tm.switchToHeadless(Platform.VK);
|
||||
} else if (data.mode === TunnelMode.HeadlessTelemost) {
|
||||
tm.switchToHeadless(Platform.Telemost);
|
||||
} else if (data.mode === TunnelMode.HeadlessWBStream) {
|
||||
tm.switchToHeadless(Platform.WBStream);
|
||||
} else {
|
||||
const url = data.platform === Platform.Telemost ? TELEMOST_URL : VK_IM_URL;
|
||||
loadURL(tm, url);
|
||||
|
||||
@@ -38,11 +38,21 @@ export class RendererTabManager {
|
||||
if (!this.activeTabId) return;
|
||||
const tab = this.tabs[this.activeTabId];
|
||||
if (tab.wv) tab.wv.remove();
|
||||
const isTelemost = platform === Platform.Telemost;
|
||||
tab.wv = null;
|
||||
tab.url = '';
|
||||
tab.mode = isTelemost ? TunnelMode.HeadlessTelemost : TunnelMode.HeadlessVK;
|
||||
tab.name = isTelemost ? 'Headless TM' : 'Headless VK';
|
||||
switch (platform) {
|
||||
case Platform.Telemost:
|
||||
tab.mode = TunnelMode.HeadlessTelemost;
|
||||
tab.name = 'Headless TM';
|
||||
break;
|
||||
case Platform.WBStream:
|
||||
tab.mode = TunnelMode.HeadlessWBStream;
|
||||
tab.name = 'Headless WB';
|
||||
break;
|
||||
default:
|
||||
tab.mode = TunnelMode.HeadlessVK;
|
||||
tab.name = 'Headless VK';
|
||||
}
|
||||
tab.headless = true;
|
||||
tab.platform = platform;
|
||||
tab.callInfo = undefined;
|
||||
|
||||
@@ -5,11 +5,13 @@ export enum TunnelMode {
|
||||
PionVideo = 'pion-video',
|
||||
HeadlessVK = 'headless-vk',
|
||||
HeadlessTelemost = 'headless-telemost',
|
||||
HeadlessWBStream = 'headless-wbstream',
|
||||
}
|
||||
|
||||
export enum Platform {
|
||||
VK = 'vk',
|
||||
Telemost = 'telemost',
|
||||
WBStream = 'wbstream',
|
||||
}
|
||||
|
||||
export enum RelayMode {
|
||||
@@ -26,6 +28,7 @@ export enum CallStatus {
|
||||
export enum BotCommand {
|
||||
VK = 'vk',
|
||||
TM = 'tm',
|
||||
WB = 'wb',
|
||||
List = 'list',
|
||||
Menu = 'menu',
|
||||
Close = 'close',
|
||||
|
||||
Reference in new issue
Block a user