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>
This commit is contained in:
+23
-10
@@ -12,16 +12,29 @@ var config = new RunnerConfig
|
||||
BotToken = Environment.GetEnvironmentVariable("TELEGRAM_BOT_TOKEN")!,
|
||||
};
|
||||
|
||||
using var runner = new TelegramUserClient(config);
|
||||
await runner.ConnectAsync();
|
||||
using var client = new TelegramUserClient(config);
|
||||
await client.ConnectAsync();
|
||||
|
||||
Console.WriteLine("Connected as Telegram user. Creating test group...");
|
||||
var group = await runner.CreateGroupAsync("GmRelay E2E Test Group");
|
||||
Console.WriteLine($"Created group id={group.Id} title='{group.Title}'");
|
||||
var scenario = new GroupSetupScenario(client, config);
|
||||
ScenarioResult? result = null;
|
||||
|
||||
await runner.InviteBotToGroupAsync(group, config.BotUsername);
|
||||
Console.WriteLine($"Invited @{config.BotUsername} to the group");
|
||||
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 process alive briefly so the session is persisted.
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
Console.WriteLine("Done.");
|
||||
// Keep the session file written to disk.
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user