key_id = data.get_charter() # Получаю словарь
char1 = list(key_id.values())[0] # Получаю значения
char2 = list(key_id.values())[1] # из словаря по номеру
char3 = list(key_id.values())[2] # ключа
char4 = list(key_id.values())[3]
char5 = list(key_id.values())[4]
char6 = list(key_id.values())[5]
char7 = list(key_id.values())[6]
char8 = list(key_id.values())[7]
然后需要将这8个值输入到按钮的文本中,InlineKeyboardButton(text="")
得到8个按钮。
编辑:
from aiogram import Bot, Dispatcher, MagicFilter, Router
from aiogram import F
from aiogram.filters import CommandStart, Command
from aiogram.types import Message, CallbackQuery
from aiogram.types import FSInputFile, URLInputFile, BufferedInputFile, ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardButton, InlineKeyboardMarkup
from aiogram.utils.keyboard import ReplyKeyboardBuilder, InlineKeyboardBuilder
from datetime import datetime
from aiogram.fsm.state import StatesGroup, State
from aiogram.fsm.context import FSMContext
from aiogram.filters import StateFilter
from aiogram.enums import ChatAction
from starrailcard.src.api import enka
from starrailcard.src.showcase import error
from starrailcard.src.api.error import StarRailCardError
import asyncio
import logging
import starrailcard
import starrailcard.src.showcase.error
import enka
from text import get_some_kb
from settings import tok
TYPING = "typing"
class Reg(StatesGroup):
name = State()
name1 = State()
router = Router()
@router.message(Command('character'),
StateFilter(None)
)
async def enkanet(message: Message, state: FSMContext):
await state.set_state(Reg.name)
await message.answer('Напиши свой ID')
print("card request")
@router.message(
StateFilter(Reg.name)
)
async def character_card(message: Message,
state: FSMContext,
) -> None: # noqa: C901, D103
await state.update_data(name=message.text)
await state.set_state(None)
data = await state.get_data()
await message.bot.send_chat_action(
chat_id=message.chat.id,
action=ChatAction.TYPING
)
await message.answer("ЖДИ\n\n\nСекунд 15~20")
async with starrailcard.Card(save=True, remove_logo=True) as card: #Модуль генерации картинки
try:
await card.set_lang("ru") #Из модуля
data = await card.create(data["name"], style=2, force_update=True) #Из модуля
key_id = data.get_charter() #Из модуля
get_some_kb(key_id)
await message.answer("", reply_markup=kb)
except enka.errors.PlayerDoesNotExistError:
print("card is not ok")
return message.answer("АШЫПКА")
except KeyError:
print("card is not ok")
return message.answer("АШЫПКА")
except enka.errors.GameMaintenanceError:
print("card is not ok")
return message.answer("АШЫПКА")
except ValueError:
print("card is not ok")
return message.answer("Введите свой ID ЦИФРАМИ")
except StarRailCardError:
print("card is not ok")
return message.answer("АШЫПКА")
except starrailcard.src.showcase.error.ApiError:
print("card is not ok")
return message.answer("АШЫПКА")
async def main():
bot = Bot(token=tok)
dp = Dispatcher()
dp.include_router(router)
await dp.start_polling(bot)
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
try:
asyncio.run(main())
except KeyboardInterrupt:
print('exit')
key_id = data.get_charter()
data228 = get_some_kb(key_id)
print(data228) #Принт в терминал выдает
# По идее всё должно нормально работать, если подставить data228 в markup=InlineKeyboardMarkup(data228)
inline_keyboard=[[InlineKeyboardButton(text='������', url=None, callback_data='call_1308', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None), InlineKeyboardButton(text='����� � ��������', url=None, callback_data='call_1112', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None)], [InlineKeyboardButton(text='�������', url=None, callback_data='call_1309', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None), InlineKeyboardButton(text='�����', url=None, callback_data='call_1005', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None)], [InlineKeyboardButton(text='�����', url=None, callback_data='call_1205', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None), InlineKeyboardButton(text='���������� ����', url=None, callback_data='call_1006', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None)], [InlineKeyboardButton(text='���� ������', url=None, callback_data='call_1307', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None), InlineKeyboardButton(text='�������', url=None, callback_data='call_1306', web_app=None, login_url=None, switch_inline_query=None, switch_inline_query_current_chat=None, switch_inline_query_chosen_chat=None, callback_game=None, pay=None)]]