public void Worker() { for (;;) { Telegram.Update update = null; lock (_queueLock) { if (_queue.Count == 0) { Monitor.Wait(_queueLock); } if (_queue.Count != 0) { update = _queue.Dequeue(); } } if (update != null) { HandleUserMessage(_api, update); } } }
// ReSharper disable once UseDeconstructionOnParameter public void Post([FromBody] Telegram.Update update) { try { if (update.message.text is { Length : 0 }) { _logger.LogDebug($"Empty message received: {update}"); return; } var(success, data, errorMessage) = _generator.CreateRandomMeme(update.message.text); if (!success) { _logger.LogError(errorMessage); return; } Telegram.SendMessage(_configuration[CFG_BOT_TOKEN], update.message.chat.id, data.url); }