vote.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:democracybot 作者: LiaungYip 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号