add bx to bot api
This commit is contained in:
1 parent
97c4d4b617
commit
9e5357eaa8
11 files changed
+80
-21
No files matched your search
@@ -174,6 +174,7 @@ export class BotManager {
|
||||
else if (payload.cmd === BotCommand.TM) cmdPrefix = '/tm';
|
||||
else if (payload.cmd === BotCommand.WB) cmdPrefix = '/wb';
|
||||
else if (payload.cmd === BotCommand.Dion) cmdPrefix = '/dion';
|
||||
else if (payload.cmd === BotCommand.Bitrix) cmdPrefix = '/bitrix';
|
||||
if (cmdPrefix && payload.mode) {
|
||||
text = `${cmdPrefix} ${payload.mode}`;
|
||||
}
|
||||
@@ -197,7 +198,7 @@ export class BotManager {
|
||||
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.",
|
||||
"Couldn't detect a VK / Telemost / WBStream / DION / Bitrix link in that message. Paste a join link or press Back.",
|
||||
createWaitingKeyboard(),
|
||||
);
|
||||
return;
|
||||
@@ -219,6 +220,9 @@ export class BotManager {
|
||||
if (lower.startsWith('dion://') || lower.includes('dion.vc')) {
|
||||
return { platform: Platform.Dion, target: trimmed };
|
||||
}
|
||||
if (lower.includes('bitrix24') && lower.includes('/video/')) {
|
||||
return { platform: Platform.Bitrix, target: trimmed };
|
||||
}
|
||||
if (lower.includes('vk.ru/call/join')) {
|
||||
return { platform: Platform.VK, target: trimmed };
|
||||
}
|
||||
@@ -230,6 +234,7 @@ export class BotManager {
|
||||
case Platform.Telemost: return TunnelMode.HeadlessTelemost;
|
||||
case Platform.WBStream: return TunnelMode.HeadlessWBStream;
|
||||
case Platform.Dion: return TunnelMode.HeadlessDion;
|
||||
case Platform.Bitrix: return TunnelMode.HeadlessBitrix;
|
||||
default: return TunnelMode.HeadlessVK;
|
||||
}
|
||||
}
|
||||
@@ -239,6 +244,7 @@ export class BotManager {
|
||||
case Platform.Telemost: return 'Telemost';
|
||||
case Platform.WBStream: return 'WB Stream';
|
||||
case Platform.Dion: return 'DION';
|
||||
case Platform.Bitrix: return 'Bitrix';
|
||||
default: return 'VK';
|
||||
}
|
||||
}
|
||||
@@ -277,6 +283,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 (platform === Platform.Bitrix) return TunnelMode.HeadlessBitrix;
|
||||
if (text.includes('headless')) {
|
||||
return platform === Platform.VK ? TunnelMode.HeadlessVK : TunnelMode.HeadlessTelemost;
|
||||
}
|
||||
@@ -290,6 +297,7 @@ export class BotManager {
|
||||
case TunnelMode.HeadlessTelemost:
|
||||
case TunnelMode.HeadlessWBStream:
|
||||
case TunnelMode.HeadlessDion:
|
||||
case TunnelMode.HeadlessBitrix:
|
||||
return 'Headless';
|
||||
case TunnelMode.PionVideo:
|
||||
return 'Video';
|
||||
@@ -319,6 +327,11 @@ export class BotManager {
|
||||
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.startsWith('/bitrix')) {
|
||||
const mode = this.parseTunnelMode(text, Platform.Bitrix);
|
||||
console.log('[BOT] Creating Bitrix tab with mode:', mode);
|
||||
this.onCreateTab({ mode, peerId, platform: Platform.Bitrix });
|
||||
await this.sendMessage(peerId, `Creating Bitrix room (${this.tunnelModeLabel(mode)})`, createMainKeyboard());
|
||||
} else if (text === '/list') {
|
||||
await this.showList(peerId);
|
||||
} else if (text.startsWith('/close ')) {
|
||||
|
||||
@@ -33,6 +33,9 @@ export function createMainKeyboard() {
|
||||
{ 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: '🟧 Bitrix', payload: JSON.stringify({ cmd: BotCommand.Bitrix, mode: 'headless' }) } },
|
||||
],
|
||||
[
|
||||
{ action: { type: 'text', label: '🔗 Join by link', payload: JSON.stringify({ cmd: BotCommand.JoinPrompt }) } },
|
||||
],
|
||||
|
||||
@@ -44,6 +44,15 @@ export class BitrixCookieFile {
|
||||
await fs.writeFile(this.filePath, JSON.stringify(content));
|
||||
}
|
||||
|
||||
async readRaw(): Promise<unknown | null> {
|
||||
try {
|
||||
const raw = await fs.readFile(this.filePath, 'utf8');
|
||||
return JSON.parse(raw);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async read(): Promise<BitrixCredentials | null> {
|
||||
try {
|
||||
const raw = await fs.readFile(this.filePath, 'utf8');
|
||||
|
||||
@@ -237,6 +237,8 @@ export class CookieStore {
|
||||
const content = p.platform === Platform.Dion && dionContent ? dionContent : cookies[i];
|
||||
return { name: p.filename, data: Buffer.from(JSON.stringify(content, null, 2), 'utf8') };
|
||||
});
|
||||
const bitrixContent = await new BitrixCookieFile(this.cookieFilePath(Platform.Bitrix)).readRaw();
|
||||
entries.push({ name: 'cookies-bitrix.json', data: Buffer.from(JSON.stringify(bitrixContent ?? {}, null, 2), 'utf8') });
|
||||
return buildStoredZip(entries);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ export enum BotCommand {
|
||||
TM = 'tm',
|
||||
WB = 'wb',
|
||||
Dion = 'dion',
|
||||
Bitrix = 'bitrix',
|
||||
JoinPrompt = 'join-prompt',
|
||||
List = 'list',
|
||||
Menu = 'menu',
|
||||
|
||||
Reference in new issue
Block a user