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()
评论列表
文章目录