import json from channels import Group as ChannelGroup class NotEnoughFunds(Exception): def __init__(self, owner,house, endowment): channel = ChannelGroup(owner.get_personal_channel_name()) if house == True: house_name = 'B' elif house == False: house_name = 'A' channel.send({'text': json.dumps({'warning': 'You do not have enough funds to make this bid. ' 'You have {} Currency {} '.format(str(endowment),house_name)})}) super().__init__('Not enough money to create a new bid of this amount') class NotEnoughItemsToSell(Exception): def __init__(self, owner,house,units): channel = ChannelGroup(owner.get_personal_channel_name()) if house == True: house_name = 'B' elif house == False: house_name = 'A' channel.send({'text': json.dumps({'warning': 'Your do not have not enough items to make this ask. ' 'You have {} packages in Market {}.'.format(str(units),house_name) })}) super().__init__('Not enough items to sell') class NoEndowment(Exception): def __init__(self, owner,house): channel = ChannelGroup(owner.get_personal_channel_name()) if house == True: house_name = 'Bitcoin' elif house == False: house_name = 'Dollar' channel.send({'text': json.dumps({'warning': 'You have no {} in {} auction house. {} auction house is closed.'.format(house_name,house_name,house_name) })}) super().__init__('No endowment') class NoItems(Exception): def __init__(self, owner,house): channel = ChannelGroup(owner.get_personal_channel_name()) if house == True: house_name = 'Bitcoin' elif house == False: house_name = 'Dollar' channel.send({'text': json.dumps({'warning': 'You have no package remaining in {} auction house. {} auction house is closed.'.format(house_name,house_name) })}) super().__init__('No endowment')