|
2 | 2 | using System.Text.Json; |
3 | 3 | using Telegram; |
4 | 4 | using Telegram.BotAPI; |
| 5 | +using Telegram.BotAPI.AvailableMethods; |
| 6 | +using Telegram.BotAPI.AvailableTypes; |
5 | 7 | using Telegram.BotAPI.GettingUpdates; |
6 | 8 |
|
7 | 9 | namespace TelegramClient; |
@@ -36,13 +38,36 @@ await botClient.SetWebhookAsync( |
36 | 38 | cancellationToken: ct); |
37 | 39 |
|
38 | 40 | logger.LogInformation("Webhook registered: {Url}", webhookUrl); |
| 41 | + |
| 42 | + await RegisterBotCommandsAsync(ct); |
39 | 43 | } |
40 | 44 | catch (Exception ex) |
41 | 45 | { |
42 | 46 | logger.LogError(ex, "Failed to set webhook at {Url}", webhookUrl); |
43 | 47 | } |
44 | 48 | } |
45 | 49 |
|
| 50 | + private async Task RegisterBotCommandsAsync(CancellationToken ct) |
| 51 | + { |
| 52 | + try |
| 53 | + { |
| 54 | + BotCommand[] commands = |
| 55 | + [ |
| 56 | + new("/start", "Set up topics and get started"), |
| 57 | + new("/newchat", "Start a fresh conversation"), |
| 58 | + new("/clear", "Reset conversation in current topic"), |
| 59 | + new("/status", "Show agent and system status"), |
| 60 | + new("/cleanup", "Clean up old messages"), |
| 61 | + ]; |
| 62 | + await botClient.SetMyCommandsAsync(commands, cancellationToken: ct); |
| 63 | + logger.LogInformation("Registered {Count} bot commands", commands.Length); |
| 64 | + } |
| 65 | + catch (Exception ex) |
| 66 | + { |
| 67 | + logger.LogWarning(ex, "Failed to register bot commands"); |
| 68 | + } |
| 69 | + } |
| 70 | + |
46 | 71 | private async Task<string?> ResolveNgrokUrlAsync(string ngrokApiUrl, CancellationToken ct) |
47 | 72 | { |
48 | 73 | // Ngrok may take a few seconds to start — retry with backoff |
|
0 commit comments