def gen_category(categories, buttonfield,
callbackfield, callbackheader, url=""):
cat_names = []
for item in categories:
print(item)
cat_names.append(item[buttonfield])
logger.info("generated a list from the name of categories; {}"
.format(cat_names))
button_list = [InlineKeyboardButton(s, url=url.format(str(categories[cat_names.index(s)][callbackfield])),
callback_data=callbackheader + str(categories[cat_names.index(s)][callbackfield]))
for s in cat_names]
return cat_names, button_list
评论列表
文章目录