def cmd_vote(bot: telegram.Bot, update: telegram.Update):
cid = update.message.chat_id
uid = update.message.from_user.id
polls = get_polls(uid, bot)
if update.message.chat.type != "private":
bot.sendMessage(cid, text_private_chat_only)
return ConversationHandler.END
if len(polls) == 0:
bot.sendMessage(cid, "You aren't eligible to vote in any polls.")
else:
keyboard_choices = [p["tag"] + ": " + p["title"] for p in polls]
# keyboard array is a list of lists
# because each list represents a new row
# and we want each button on a separate row
keyboard_array = [[k, ] for k in keyboard_choices]
keyboard = ReplyKeyboardMarkup(keyboard_array,
one_time_keyboard=True)
bot.sendMessage(cid,
"Click the button for the poll you would like to vote in.",
reply_markup=keyboard)
return state_vote_1
评论列表
文章目录