fix: Allow UpdateBotTokenAsync to start bot when not previously running
When TeleBot starts without a token configured, the TelegramBotService returns early from StartAsync without creating a bot client. Previously, UpdateBotTokenAsync only worked when _botClient was already initialized. This fix changes the condition to also start the bot if _botClient is null, enabling remote configuration via the discovery API to properly start Telegram polling. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f367a98c53
commit
a975a9e914
@ -229,12 +229,16 @@ namespace TeleBot
|
||||
|
||||
public async Task UpdateBotTokenAsync(string newToken)
|
||||
{
|
||||
if (_botClient != null && _currentBotToken != newToken)
|
||||
// If bot wasn't started or token changed, start/restart
|
||||
if (_currentBotToken != newToken || _botClient == null)
|
||||
{
|
||||
_logger.LogInformation("Updating bot token and restarting bot...");
|
||||
_logger.LogInformation("Starting/updating bot with new token...");
|
||||
|
||||
// Stop current bot
|
||||
// Stop current bot if running
|
||||
if (_botClient != null)
|
||||
{
|
||||
_cancellationTokenSource?.Cancel();
|
||||
}
|
||||
|
||||
// Create new bot client with new token and TOR support
|
||||
_currentBotToken = newToken;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user