def remove_exchange(bot, update, args): """Remove exchange to exchanges list by which the bot will notify the user""" msg = update.message try: exchange = args[0].replace('-', '_').lower() user_exchanges = mq.get_user_settings( msg.chat_id)[base_config.EXCHANGES] if exchange not in user_exchanges: user_exchanges = exchange_convert(user_exchanges) msg.reply_text(messages.ALREADY_DISABLED_EXCHANGE_TEXT.format( '`' + '`, `'.join(user_exchanges) + '`'), reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU mq.remove_from_list(msg.chat_id, list=base_config.EXCHANGES, value=exchange) new_user_exchanges = '`' + '`, `'.join( exchange_convert(set(user_exchanges) - {exchange})) + '`' msg.reply_text( messages.REMOVE_EXCHANGE_SUCC_TEXT.format(new_user_exchanges), reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU except (IndexError, ValueError): msg.reply_text(messages.REMOVE_EXCHANGE_HELP_TEXT, reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU
def remove_coin(bot, update, args): """Remove coin from coins list by which the bot will notify the user""" msg = update.message try: coin = args[0].upper() user_coins = mq.get_user_settings(msg.chat_id)[base_config.COINS] if coin not in user_coins: msg.reply_text( messages.ALREADY_DISABLED_COIN.format('`' + '`, `'.join(user_coins) + '`'), reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU mq.remove_from_list(msg.chat_id, list=base_config.COINS, value=coin) new_user_coins = '`' + '`, `'.join(set(user_coins) - {coin}) + '`' msg.reply_text(messages.REMOVE_COIN_SUCC_TEXT.format(new_user_coins), reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU except (IndexError, ValueError): msg.reply_text(messages.REMOVE_COIN_HELP_TEXT, reply_markup=kb_main, parse_mode=messages.MARKDOWN) return MAIN_MENU
def remove_coin_dialog(bot, update): """Remove coin from user's list and send message to user about operation's result""" msg = update.message coin = msg.text[3:].strip(' \t\n\r').upper() user_coins = mq.get_user_settings(msg.chat_id)[base_config.COINS] if coin not in user_coins: msg.reply_text( messages.ALREADY_DISABLED_COIN.format('`' + '`, `'.join(user_coins) + '`'), parse_mode=messages.MARKDOWN) return ADD_RM_COINS mq.remove_from_list(msg.chat_id, list=base_config.COINS, value=coin) new_user_coins = '`' + '`, `'.join(set(user_coins) - {coin}) + '`' msg.reply_text(messages.REMOVE_COIN_SUCC_TEXT.format(new_user_coins), parse_mode=messages.MARKDOWN) return ADD_RM_COINS
def remove_exchange_dialog(bot, update): """Remove exchange from user's list and send message to user about operation's result""" msg = update.message exchange = msg.text[3:].strip(' \t\n\r').replace('-', '_').lower() user_exchanges = mq.get_user_settings(msg.chat_id)[base_config.EXCHANGES] if exchange not in user_exchanges: user_exchanges = exchange_convert(user_exchanges) msg.reply_text(messages.ALREADY_DISABLED_EXCHANGE_TEXT.format( '`' + '`, `'.join(user_exchanges) + '`'), parse_mode=messages.MARKDOWN) return ADD_RM_EX mq.remove_from_list(msg.chat_id, list=base_config.EXCHANGES, value=exchange) new_user_exchanges = '`' + '`, `'.join( exchange_convert(set(user_exchanges) - {exchange})) + '`' msg.reply_text( messages.REMOVE_EXCHANGE_SUCC_TEXT.format(new_user_exchanges), parse_mode=messages.MARKDOWN) return ADD_RM_EX