groups.py 文件源码

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

项目:bicingbot 作者: marivipelaez 项目源码 文件源码
def remove_group_command(chat_id, text):
    """
    Sends a keyboard to the user with the name of all her groups to choose the one to remove

    :param chat_id: Telegram chat id
    :param text: remove group command
    """
    db_connection = DatabaseConnection()
    logger.info('COMMAND {}: chat_id={}'.format(text, chat_id))
    groups = grouper(db_connection.get_groups_names(chat_id))
    buttons_lines = []
    for groups_line in groups:
        buttons_lines.append(
            [InlineKeyboardButton(group_name, callback_data='{}_{}'.format(REMOVE_GROUP_CALLBACK, group_name))
             for group_name in groups_line if group_name])
    buttons_lines.append([InlineKeyboardButton(tr('removegroup_cancel', chat_id),
                                               callback_data='{}_unused'.format(REMOVE_CANCEL_CALLBACK))])
    keyboard = InlineKeyboardMarkup(buttons_lines)
    get_bot().send_message(chat_id=chat_id, text=tr('removegroup_name', chat_id), reply_markup=keyboard)
    db_connection.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号