public async Task StartPolling()
{
Console.WriteLine("Polling...");
try
{
while (true)
{
var longPollResponse = await _botApi.Groups.GetLongPollServerAsync(_groupId);
var updates = await _botApi.Groups.GetBotsLongPollHistoryAsync(new BotsLongPollHistoryParams
{
Ts = longPollResponse.Ts,
Key = longPollResponse.Key,
Server = longPollResponse.Server,
Wait = 25
});
if (updates.Updates is null) continue;
if (updates.Updates.Count < 1) continue;
await Task.Run(async () =>
{
foreach (var update in updates.Updates)
await HandleUpdateAsync(update);
});
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}
public async Task StartPolling()
{
Console.WriteLine("Polling...");
try
{
while (true)
{
var longPollResponse = await _botApi.Groups.GetLongPollServerAsync(_groupId);
var updates = await _botApi.Groups.GetBotsLongPollHistoryAsync(new BotsLongPollHistoryParams
{
Ts = longPollResponse.Ts,
Key = longPollResponse.Key,
Server = longPollResponse.Server,
Wait = 25
});
if (updates.Updates is null) continue;
if (updates.Updates.Count < 1) continue;
await Task.Run(async () =>
{
foreach (var update in updates.Updates)
await HandleUpdateAsync(update);
});
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}