Files
GmRelayBot/tests/e2e/runner/Program.cs
T
Toutsu f4a61269c2 feat(e2e): #147 group creation and bot invitation scenario
- 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>
2026-06-16 12:17:58 +03:00

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));
}