public void Run(Update update) { Task.Run(() => { var chat = update?.Message != null ? update.Message.Chat.Id.ToString() : (update?.CallbackQuery != null ? update.CallbackQuery.Message.Chat.Id.ToString() : null); if (chat != null) { if (!dictionaryState.ContainsKey(chat)) { dictionaryState.Add(chat, "null"); } string param; var comm = update.GetCommandOrNull(out param); var state = dictionaryState[chat]; if (comm != null) { behavior.CommandAction(comm, param, update, ref state); } behavior.Action(update, api, ref state); dictionaryState[chat] = state; } else if (update.PreCheckoutQuery != null) { api.AnswerPreCheckoutQuery(update.PreCheckoutQuery.Id, true); } }); }