private void _botClient_OnCallbackQuery(object sender, CallbackQueryEventArgs e) { try { if (!ConnectedClients.TryGetValue(e.CallbackQuery.Message.From.Id, out TelegramClientInfo clientInfo)) { clientInfo = new TelegramClientInfo(_serverBase) { ConnectedDateTime = DateTime.Now, ClientId = Guid.NewGuid().ToString(), Message = e.CallbackQuery.Message, SignalGoBotManager = this }; _serverBase.Clients.TryAdd(clientInfo.ClientId, clientInfo); ConnectedClients.TryAdd(e.CallbackQuery.Message.From.Id, clientInfo); CurrentBotStructureInfo.OnClientConnected(clientInfo, this); } if (CustomInlineButtons.TryGetValue(e.CallbackQuery.Data, out Action <TelegramClientInfo> action)) { action?.Invoke(clientInfo); } } catch (Exception ex) { Console.WriteLine(ex); } }
internal IEnumerable <IEnumerable <InlineKeyboardButton> > BotButtonsToKeyboardButtons(List <List <BotButtonInfo> > botButtonInfos) { List <List <InlineKeyboardButton> > keyboardButtons = new List <List <InlineKeyboardButton> >(); foreach (List <BotButtonInfo> columns in botButtonInfos) { List <InlineKeyboardButton> rows = new List <InlineKeyboardButton>(); foreach (BotButtonInfo row in columns) { CustomInlineButtons.Add(row.Key, row.Click); rows.Add(new InlineKeyboardButton() { Text = row.Caption, CallbackData = row.Key }); } keyboardButtons.Add(rows); } return(keyboardButtons); }