diff --git a/android-app/app/libs/mobile.aar b/android-app/app/libs/mobile.aar index 6a9a256..1abb53f 100644 Binary files a/android-app/app/libs/mobile.aar and b/android-app/app/libs/mobile.aar differ diff --git a/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so b/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so index fd6a75d..22f23e3 100755 Binary files a/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so and b/android-app/app/src/main/jniLibs/arm64-v8a/librelay.so differ diff --git a/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so b/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so index 5661936..4db9413 100755 Binary files a/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so and b/android-app/app/src/main/jniLibs/armeabi-v7a/librelay.so differ diff --git a/creator-app/src/bot/bot-manager.ts b/creator-app/src/bot/bot-manager.ts index 7d36ca4..bdfc6d6 100644 --- a/creator-app/src/bot/bot-manager.ts +++ b/creator-app/src/bot/bot-manager.ts @@ -4,6 +4,7 @@ import { VK_API_VERSION, VK_API_BASE_URL, BOT_POLL_RETRY_DELAY_MS, BOT_POLL_WAIT import { createMainKeyboard, createListKeyboard, + createWaitingKeyboard, findTabByShortId, generateShortId, padShortId, @@ -52,6 +53,7 @@ export class BotManager { private key: string | null = null; private server: string | null = null; private running = false; + private awaitingJoinLink = new Set(); onError: ((msg: string) => void) | null = null; constructor( @@ -171,15 +173,86 @@ export class BotManager { if (payload.cmd === BotCommand.VK) cmdPrefix = '/vk'; else if (payload.cmd === BotCommand.TM) cmdPrefix = '/tm'; else if (payload.cmd === BotCommand.WB) cmdPrefix = '/wb'; + else if (payload.cmd === BotCommand.Dion) cmdPrefix = '/dion'; if (cmdPrefix && payload.mode) { text = `${cmdPrefix} ${payload.mode}`; } } + const wasAwaiting = this.awaitingJoinLink.has(peerId); + const joinLink = this.detectJoinLink(text); + if (joinLink) { + this.awaitingJoinLink.delete(peerId); + console.log('[BOT] Detected join link for', joinLink.platform, ':', joinLink.target); + this.onCreateTab({ + mode: this.headlessModeFor(joinLink.platform), + peerId, + platform: joinLink.platform, + joinTarget: joinLink.target, + }); + await this.sendMessage(peerId, `Joining ${this.platformLabel(joinLink.platform)} call`, createMainKeyboard()); + return; + } + + if (wasAwaiting) { + await this.sendMessage( + peerId, + "Couldn't detect a VK / Telemost / WBStream / DION link in that message. Paste a join link or press Back.", + createWaitingKeyboard(), + ); + return; + } + await this.handleTextCommand(text, peerId); } + private detectJoinLink(text: string): { platform: Platform; target: string } | null { + const trimmed = text.trim(); + if (!trimmed) return null; + const lower = trimmed.toLowerCase(); + if (lower.startsWith('wbstream://') || lower.includes('stream.wb.ru')) { + return { platform: Platform.WBStream, target: trimmed }; + } + if (lower.includes('telemost.yandex')) { + return { platform: Platform.Telemost, target: trimmed }; + } + if (lower.startsWith('dion://') || lower.includes('dion.vc')) { + return { platform: Platform.Dion, target: trimmed }; + } + if (lower.includes('vk.com/call/join')) { + return { platform: Platform.VK, target: trimmed }; + } + return null; + } + + private headlessModeFor(platform: Platform): TunnelMode { + switch (platform) { + case Platform.Telemost: return TunnelMode.HeadlessTelemost; + case Platform.WBStream: return TunnelMode.HeadlessWBStream; + case Platform.Dion: return TunnelMode.HeadlessDion; + default: return TunnelMode.HeadlessVK; + } + } + + private platformLabel(platform: Platform): string { + switch (platform) { + case Platform.Telemost: return 'Telemost'; + case Platform.WBStream: return 'WB Stream'; + case Platform.Dion: return 'DION'; + default: return 'VK'; + } + } + private async handlePayloadCommand(payload: ButtonPayload, peerId: number): Promise { + if (payload.cmd === BotCommand.Noop) { + return true; + } + if (payload.cmd === BotCommand.JoinPrompt) { + this.awaitingJoinLink.add(peerId); + await this.sendMessage(peerId, 'Paste a join link', createWaitingKeyboard()); + return true; + } + this.awaitingJoinLink.delete(peerId); if (payload.cmd === BotCommand.List) { await this.showList(peerId); return true; @@ -203,6 +276,7 @@ export class BotManager { private parseTunnelMode(text: string, platform: Platform): TunnelMode { if (platform === Platform.WBStream) return TunnelMode.HeadlessWBStream; + if (platform === Platform.Dion) return TunnelMode.HeadlessDion; if (text.includes('headless')) { return platform === Platform.VK ? TunnelMode.HeadlessVK : TunnelMode.HeadlessTelemost; } @@ -215,6 +289,7 @@ export class BotManager { case TunnelMode.HeadlessVK: case TunnelMode.HeadlessTelemost: case TunnelMode.HeadlessWBStream: + case TunnelMode.HeadlessDion: return 'Headless'; case TunnelMode.PionVideo: return 'Video'; @@ -239,6 +314,11 @@ export class BotManager { 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.startsWith('/dion')) { + const mode = this.parseTunnelMode(text, Platform.Dion); + console.log('[BOT] Creating DION tab with mode:', mode); + this.onCreateTab({ mode, peerId, platform: Platform.Dion }); + await this.sendMessage(peerId, `Creating DION room (${this.tunnelModeLabel(mode)})`, createMainKeyboard()); } else if (text === '/list') { await this.showList(peerId); } else if (text.startsWith('/close ')) { diff --git a/creator-app/src/bot/keyboard.ts b/creator-app/src/bot/keyboard.ts index afdc383..1fed993 100644 --- a/creator-app/src/bot/keyboard.ts +++ b/creator-app/src/bot/keyboard.ts @@ -27,19 +27,37 @@ export function createMainKeyboard() { buttons: [ [ { action: { type: 'text', label: 'đŸŸĻ VK', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'headless' }) } }, - { action: { type: 'text', label: 'DC (legacy)', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'dc' }) } }, - { action: { type: 'text', label: 'Video (legacy)', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'video' }) } }, - ], - [ { action: { type: 'text', label: 'đŸŸĨ Telemost', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'headless' }) } }, - { action: { type: 'text', label: 'Video (legacy)', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'video' }) } }, ], [ { action: { type: 'text', label: 'đŸŸĒ WBStream', payload: JSON.stringify({ cmd: BotCommand.WB, mode: 'headless' }) } }, + { action: { type: 'text', label: '🟩 DION', payload: JSON.stringify({ cmd: BotCommand.Dion, mode: 'headless' }) } }, + ], + [ + { action: { type: 'text', label: '🔗 Join by link', payload: JSON.stringify({ cmd: BotCommand.JoinPrompt }) } }, ], [ { action: { type: 'text', label: '📋 Active Tabs', payload: JSON.stringify({ cmd: BotCommand.List }) } }, ], + [ + { action: { type: 'text', label: 'â„šī¸ Buttons below: old webview mode', payload: JSON.stringify({ cmd: BotCommand.Noop }) } }, + ], + [ + { action: { type: 'text', label: 'đŸŸĻ DC (legacy)', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'dc' }) } }, + { action: { type: 'text', label: 'đŸŸĻ Video (legacy)', payload: JSON.stringify({ cmd: BotCommand.VK, mode: 'video' }) } }, + { action: { type: 'text', label: 'đŸŸĨ Video (legacy)', payload: JSON.stringify({ cmd: BotCommand.TM, mode: 'video' }) } }, + ], + ], + }; +} + +export function createWaitingKeyboard() { + return { + one_time: false, + buttons: [ + [ + { action: { type: 'text', label: 'â—€ī¸ Back', payload: JSON.stringify({ cmd: BotCommand.Menu }) } }, + ], ], }; } diff --git a/creator-app/src/main/ipc.ts b/creator-app/src/main/ipc.ts index 66f02a3..a6b197a 100644 --- a/creator-app/src/main/ipc.ts +++ b/creator-app/src/main/ipc.ts @@ -55,6 +55,7 @@ export function registerIpcHandlers(tabManager: TabManager): void { mode: tabConfig.mode, peerId: tabConfig.peerId, platform: tabConfig.platform || Platform.VK, + joinTarget: tabConfig.joinTarget, }); console.log('[BOT] Created tab:', tabId, 'mode:', tabConfig.mode, 'platform:', tabConfig.platform); }, diff --git a/creator-app/src/main/tab-manager.ts b/creator-app/src/main/tab-manager.ts index a654aef..6a5620c 100644 --- a/creator-app/src/main/tab-manager.ts +++ b/creator-app/src/main/tab-manager.ts @@ -315,6 +315,14 @@ export class TabManager { const refreshCookie = platform === Platform.WBStream ? 'wbx-refresh' : config.authCookie; const needsLogin = !cookies.some((c) => c.name === refreshCookie); if (needsLogin) { + if (tab.isBot) { + const reply = `Please log into ${config.platformName} in the creator app first, then try again.`; + this.sendLog(tabId, reply); + if (this._botManager && tab.peerId != null) { + await this._botManager.sendMessage(tab.peerId, reply); + } + return; + } this.sendLog(tabId, `No ${config.platformName} session found, opening login.`); if (this._mainWindow && !this._mainWindow.isDestroyed()) { this._mainWindow.webContents.send(IPC.LOGIN_REQUIRED, { tabId, url: config.loginUrl }); @@ -332,10 +340,10 @@ export class TabManager { cookies = await this.getCookiesForDomains(config.cookieDomains); } this.sendLog(tabId, `${config.platformName} cookies (${cookies.length}): ${cookies.map((c) => c.name).join(', ')}`); - this.killRelay(tabId, tab); const cookiesPath = path.join(app.getPath('userData'), `cookies-${platform}.json`); await fs.writeFile(cookiesPath, JSON.stringify(cookies)); const spawnArgs = ['--resources', 'default', '--cookies', cookiesPath]; + this.killRelay(tabId, tab); if (joinTarget) { const flag = this.joinFlagFor(platform); if (flag) spawnArgs.push(flag, joinTarget); diff --git a/creator-app/src/renderer/dom.ts b/creator-app/src/renderer/dom.ts index e51359b..10d65c5 100644 --- a/creator-app/src/renderer/dom.ts +++ b/creator-app/src/renderer/dom.ts @@ -128,8 +128,6 @@ export function renderContent(tm: RendererTabManager): void { document.getElementById('relayLog')!.textContent = activeTab.relayLogs || ''; document.getElementById('hookLog')!.textContent = activeTab.hookLogs || ''; scrollLogs(); - - renderBotButton(tm); } export function renderBotButton(tm: RendererTabManager): void { diff --git a/creator-app/src/renderer/index.ts b/creator-app/src/renderer/index.ts index af87502..34c755d 100644 --- a/creator-app/src/renderer/index.ts +++ b/creator-app/src/renderer/index.ts @@ -23,6 +23,7 @@ declare const window: Window & { bridge: Bridge }; const tm = new RendererTabManager(() => { renderTabs(tm); renderContent(tm); + renderBotButton(tm); }); function bindTabBarEvents(): void { @@ -183,13 +184,13 @@ function init(): void { tm.createBotTab(data); (document.getElementById('modeSelect') as HTMLSelectElement).value = data.mode; if (data.mode === TunnelMode.HeadlessVK) { - tm.switchToHeadless(Platform.VK); + tm.switchToHeadless(Platform.VK, data.joinTarget); } else if (data.mode === TunnelMode.HeadlessTelemost) { - tm.switchToHeadless(Platform.Telemost); + tm.switchToHeadless(Platform.Telemost, data.joinTarget); } else if (data.mode === TunnelMode.HeadlessWBStream) { - tm.switchToHeadless(Platform.WBStream); + tm.switchToHeadless(Platform.WBStream, data.joinTarget); } else if (data.mode === TunnelMode.HeadlessDion) { - tm.switchToHeadless(Platform.Dion); + tm.switchToHeadless(Platform.Dion, data.joinTarget); } else { const url = data.platform === Platform.Telemost ? TELEMOST_URL : VK_IM_URL; loadURL(tm, url); diff --git a/creator-app/src/renderer/tab-manager.ts b/creator-app/src/renderer/tab-manager.ts index cdc7683..96840d3 100644 --- a/creator-app/src/renderer/tab-manager.ts +++ b/creator-app/src/renderer/tab-manager.ts @@ -43,7 +43,7 @@ export class RendererTabManager { return tabId; } - switchToHeadless(platform: Platform): void { + switchToHeadless(platform: Platform, joinTarget?: string): void { if (!this.activeTabId) return; const tab = this.tabs[this.activeTabId]; if (tab.wv) tab.wv.remove(); @@ -75,7 +75,11 @@ export class RendererTabManager { tab.relayLogs = ''; tab.hookLogs = ''; if (tab.isBot) { - this.startHeadlessCall({ mode: HeadlessMode.Create }); + if (joinTarget) { + this.startHeadlessCall({ mode: HeadlessMode.Join, target: joinTarget }); + } else { + this.startHeadlessCall({ mode: HeadlessMode.Create }); + } } this.onRender(); } @@ -113,6 +117,7 @@ export class RendererTabManager { isBot: true, peerId: data.peerId, platform: data.platform, + joinedByLink: !!data.joinTarget, }; } this.selectTab(data.tabId); @@ -191,7 +196,8 @@ export class RendererTabManager { if (trimmed.includes(HeadlessLogMarker.JOIN_LINK) && tab.callInfo) { tab.callInfo.joinLink = trimmed.split(HeadlessLogMarker.JOIN_LINK)[1].trim(); if (tab.isBot) { - window.bridge.sendBotCallLink(tabId, tab.callInfo.joinLink); + const reply = tab.joinedByLink ? 'Joined successfully' : tab.callInfo.joinLink; + window.bridge.sendBotCallLink(tabId, reply); } changed = true; } diff --git a/creator-app/src/types.ts b/creator-app/src/types.ts index 667911c..8b1fb13 100644 --- a/creator-app/src/types.ts +++ b/creator-app/src/types.ts @@ -31,9 +31,12 @@ export enum BotCommand { VK = 'vk', TM = 'tm', WB = 'wb', + Dion = 'dion', + JoinPrompt = 'join-prompt', List = 'list', Menu = 'menu', Close = 'close', + Noop = 'noop', } export enum LogPanel { @@ -66,6 +69,7 @@ export interface TabConfig { mode: TunnelMode; peerId: number; platform: Platform; + joinTarget?: string; } export interface TabListEntry { @@ -116,6 +120,7 @@ export interface RendererTab { callInfo?: CallInfo; tunnelConnected?: boolean; loginWebview?: Webview; + joinedByLink?: boolean; } export interface BotTabData { @@ -123,6 +128,7 @@ export interface BotTabData { mode: TunnelMode; peerId: number; platform: Platform; + joinTarget?: string; } export interface RelayLogData { diff --git a/headless/wbstream/main.go b/headless/wbstream/main.go index 4cc9630..ad69d6f 100644 --- a/headless/wbstream/main.go +++ b/headless/wbstream/main.go @@ -59,7 +59,7 @@ func main() { rawCookies := common.LoadCookies(*cookiesPath) deviceID := common.CookieValue(rawCookies, "__wb_device_id") if deviceID == "" { - log.Fatalf("[auth] cookies file is missing __wb_device_id; re-export via creator-app's 'WB Cookies' button") + log.Fatalf("[auth] cookies file is missing __wb_device_id; re-export via creator-app's 'Export Cookies' button") } cookieHeader := common.FilterCookies(rawCookies, wbstream.WBStreamCookieAllowlist) bearer, err := wbstream.RefreshAccessToken(nil, cookieHeader, deviceID)