diff --git a/src/TelegramPanel.Core/Services/Telegram/TdataSessionBridge.cs b/src/TelegramPanel.Core/Services/Telegram/TdataSessionBridge.cs index 4311a74..70683a1 100644 --- a/src/TelegramPanel.Core/Services/Telegram/TdataSessionBridge.cs +++ b/src/TelegramPanel.Core/Services/Telegram/TdataSessionBridge.cs @@ -43,11 +43,21 @@ try { private const string NodeScriptTelethonToTdata = """ import { convertFromTelethonSession, convertToTdata } from '@mtcute/convert'; -const telethonSession = process.argv[process.argv.length - 2]; +const telethonSession = process.argv[process.argv.length - 3]; +const userIdRaw = process.argv[process.argv.length - 2]; const outputDir = process.argv[process.argv.length - 1]; try { const session = convertFromTelethonSession(telethonSession); + const userId = Number.parseInt(userIdRaw, 10); + if (Number.isFinite(userId) && userId > 0) { + session.self = { + userId, + isBot: false, + isPremium: false, + usernames: [], + }; + } await convertToTdata(session, { path: outputDir }); console.log(JSON.stringify({ ok: true })); } catch (error) { @@ -141,6 +151,7 @@ try { public static async Task TryConvertTelethonStringSessionToTdataAsync( string telethonSessionString, + long? userId, string outputTdataDirectory, ILogger logger, CancellationToken cancellationToken = default) @@ -164,7 +175,7 @@ try { var run = await RunProcessAsync( fileName: "node", - arguments: new[] { "--input-type=module", "-e", NodeScriptTelethonToTdata, "--", normalizedSession, absoluteOutputDir }, + arguments: new[] { "--input-type=module", "-e", NodeScriptTelethonToTdata, "--", normalizedSession, (userId ?? 0).ToString(), absoluteOutputDir }, workingDirectory: RuntimeDir, timeoutMs: ConvertTimeoutMs, cancellationToken: cancellationToken); diff --git a/src/TelegramPanel.Web/Services/AccountExportService.cs b/src/TelegramPanel.Web/Services/AccountExportService.cs index 867c9d6..73e6fb6 100644 --- a/src/TelegramPanel.Web/Services/AccountExportService.cs +++ b/src/TelegramPanel.Web/Services/AccountExportService.cs @@ -177,6 +177,7 @@ public class AccountExportService var tdataResult = await TdataSessionBridge.TryConvertTelethonStringSessionToTdataAsync( telethonSessionString: telethonResult.SessionString, + userId: account.UserId > 0 ? account.UserId : null, outputTdataDirectory: tempTdataDir, logger: _logger, cancellationToken: cancellationToken);