Adding ThrowPendingUpdates option to builder and Message client.
This commit is contained in:
@@ -207,7 +207,7 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
|
||||
#region "Step 4 (Network Settings)"
|
||||
|
||||
public IBotCommandsStage WithProxy(string proxyAddress)
|
||||
public IBotCommandsStage WithProxy(string proxyAddress, bool throwPendingUpdates = false)
|
||||
{
|
||||
var url = new Uri(proxyAddress);
|
||||
_client = new MessageClient(_apiKey, url)
|
||||
@@ -217,11 +217,12 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Timeout = new TimeSpan(0, 1, 0)
|
||||
},
|
||||
};
|
||||
_client.ThrowPendingUpdates = throwPendingUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public IBotCommandsStage NoProxy()
|
||||
public IBotCommandsStage NoProxy(bool throwPendingUpdates = false)
|
||||
{
|
||||
_client = new MessageClient(_apiKey)
|
||||
{
|
||||
@@ -230,11 +231,12 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Timeout = new TimeSpan(0, 1, 0)
|
||||
}
|
||||
};
|
||||
_client.ThrowPendingUpdates = throwPendingUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public IBotCommandsStage WithBotClient(TelegramBotClient tgclient)
|
||||
public IBotCommandsStage WithBotClient(TelegramBotClient tgclient, bool throwPendingUpdates = false)
|
||||
{
|
||||
_client = new MessageClient(_apiKey, tgclient)
|
||||
{
|
||||
@@ -243,11 +245,12 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Timeout = new TimeSpan(0, 1, 0)
|
||||
}
|
||||
};
|
||||
_client.ThrowPendingUpdates = throwPendingUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public IBotCommandsStage WithHostAndPort(string proxyHost, int proxyPort)
|
||||
public IBotCommandsStage WithHostAndPort(string proxyHost, int proxyPort, bool throwPendingUpdates = false)
|
||||
{
|
||||
_client = new MessageClient(_apiKey, proxyHost, proxyPort)
|
||||
{
|
||||
@@ -256,10 +259,11 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Timeout = new TimeSpan(0, 1, 0)
|
||||
}
|
||||
};
|
||||
_client.ThrowPendingUpdates = throwPendingUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IBotCommandsStage WithHttpClient(HttpClient tgclient)
|
||||
public IBotCommandsStage WithHttpClient(HttpClient tgclient, bool throwPendingUpdates = false)
|
||||
{
|
||||
_client = new MessageClient(_apiKey, tgclient)
|
||||
{
|
||||
@@ -268,6 +272,7 @@ public class BotBaseBuilder : IAPIKeySelectionStage, IMessageLoopSelectionStage,
|
||||
Timeout = new TimeSpan(0, 1, 0)
|
||||
}
|
||||
};
|
||||
_client.ThrowPendingUpdates = throwPendingUpdates;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,22 +9,25 @@ public interface INetworkingSelectionStage
|
||||
/// Chooses a proxy as network configuration.
|
||||
/// </summary>
|
||||
/// <param name="proxyAddress"></param>
|
||||
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
|
||||
/// <returns></returns>
|
||||
IBotCommandsStage WithProxy(string proxyAddress);
|
||||
IBotCommandsStage WithProxy(string proxyAddress, bool throwPendingUpdates = false);
|
||||
|
||||
/// <summary>
|
||||
/// Do not choose a proxy as network configuration.
|
||||
/// </summary>
|
||||
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
|
||||
/// <returns></returns>
|
||||
IBotCommandsStage NoProxy();
|
||||
IBotCommandsStage NoProxy(bool throwPendingUpdates = false);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Chooses a custom instance of TelegramBotClient.
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
|
||||
/// <returns></returns>
|
||||
IBotCommandsStage WithBotClient(TelegramBotClient client);
|
||||
IBotCommandsStage WithBotClient(TelegramBotClient client, bool throwPendingUpdates = false);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -32,13 +35,15 @@ public interface INetworkingSelectionStage
|
||||
/// </summary>
|
||||
/// <param name="proxyHost"></param>
|
||||
/// <param name="Port"></param>
|
||||
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
|
||||
/// <returns></returns>
|
||||
IBotCommandsStage WithHostAndPort(string proxyHost, int Port);
|
||||
IBotCommandsStage WithHostAndPort(string proxyHost, int Port, bool throwPendingUpdates = false);
|
||||
|
||||
/// <summary>
|
||||
/// Uses a custom http client.
|
||||
/// </summary>
|
||||
/// <param name="client"></param>
|
||||
/// <param name="throwPendingUpdates">Indicates if all pending Telegram.Bot.Types.Updates should be thrown out before start polling.</param>
|
||||
/// <returns></returns>
|
||||
IBotCommandsStage WithHttpClient(HttpClient client);
|
||||
IBotCommandsStage WithHttpClient(HttpClient client, bool throwPendingUpdates = false);
|
||||
}
|
||||
Reference in New Issue
Block a user