f4a61269c2
- Add GroupSetupScenario: create supergroup, invite GmRelay bot, send /start, wait for reply, then delete the group - Extend TelegramUserClient with DeleteGroupAsync and channel cache - Update Program.cs to run the scenario with cleanup in finally - Update README status table and runner documentation Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using dotenv.net;
|
|
using GmRelay.E2E.Runner;
|
|
|
|
DotEnv.Load(new DotEnvOptions(envFilePaths: [".env"], ignoreExceptions: false));
|
|
|
|
var config = new RunnerConfig
|
|
{
|
|
ApiId = int.Parse(Environment.GetEnvironmentVariable("api_id")!),
|
|
ApiHash = Environment.GetEnvironmentVariable("api_hash")!,
|
|
PhoneNumber = Environment.GetEnvironmentVariable("phone_number")!,
|
|
BotUsername = Environment.GetEnvironmentVariable("TELEGRAM_BOT_USERNAME")!,
|
|
BotToken = Environment.GetEnvironmentVariable("TELEGRAM_BOT_TOKEN")!,
|
|
};
|
|
|
|
using var client = new TelegramUserClient(config);
|
|
await client.ConnectAsync();
|
|
|
|
var scenario = new GroupSetupScenario(client, config);
|
|
ScenarioResult? result = null;
|
|
|
|
try
|
|
{
|
|
result = await scenario.RunAsync();
|
|
Console.WriteLine("Scenario completed successfully.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Scenario failed: {ex.Message}");
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
if (result is not null)
|
|
{
|
|
await scenario.CleanupAsync(result);
|
|
}
|
|
|
|
// Keep the session file written to disk.
|
|
await Task.Delay(TimeSpan.FromSeconds(2));
|
|
}
|