예제 #1
0
        private void PrepareMessage(ISession session, out string text, out InlineKeyboardMarkup inlineKeyboard)
        {
            text = aggregator?.Invoke(mainDict).ToString(session) ?? session.Translate(Name);

            InlineKeyboardButton[,] buttons = new InlineKeyboardButton[mainDict.Count, 4];

            int i = 0;

            foreach (var pair in mainDict)
            {
                string translatedText = pair.Key.ToString(session), elementHash = pair.Key.ToString().GetHashCode().ToString();
                buttons[i, 0] = InlineKeyboardButton.WithCallbackData(translatedText, DefaultStrings.DoNothing);
                buttons[i, 1] = InlineKeyboardButton.WithCallbackData(session.Translate(DefaultStrings.Minus), $"{DefaultStrings.Minus}_{Name}_{elementHash}");
                buttons[i, 2] = InlineKeyboardButton.WithCallbackData(pair.Value.ToString(), DefaultStrings.DoNothing);
                buttons[i, 3] = InlineKeyboardButton.WithCallbackData(session.Translate(DefaultStrings.Plus), $"{DefaultStrings.Plus}_{Name}_{elementHash}");
                i++;
            }

            inlineKeyboard = new InlineKeyboardMarkup(buttons.ToMultiEnumerable());
        }