Search results now show less info on shops to avoid spam
parent
9a20e0155e
commit
fc95d3d986
|
@ -130,8 +130,7 @@ class DatabaseInterface:
|
|||
|
||||
shops = []
|
||||
for listing in listings:
|
||||
shops.append(listing.shop)
|
||||
shops.append(listing.__str__())
|
||||
shops.append(listing.selling_info())
|
||||
|
||||
return shops
|
||||
|
||||
|
@ -296,6 +295,7 @@ class TunnelDirection(enum.Enum):
|
|||
else:
|
||||
raise ValueError
|
||||
|
||||
|
||||
class Dimension(enum.Enum):
|
||||
overworld = 'overworld'
|
||||
nether = 'nether'
|
||||
|
@ -350,6 +350,7 @@ class Tunnel(SQL_Base):
|
|||
def __str__(self):
|
||||
return '{} {}'.format(self.tunnel_direction.value.title(), self.tunnel_number)
|
||||
|
||||
|
||||
class Location(SQL_Base):
|
||||
__tablename__ = 'Locations'
|
||||
|
||||
|
@ -393,6 +394,9 @@ class Location(SQL_Base):
|
|||
def info_str(self):
|
||||
return "Name: **{}**, Type: **{}** Position: **{}**".format(self.name, self.type, self.pos_to_str())
|
||||
|
||||
def full_str(self):
|
||||
return self.__str__()
|
||||
|
||||
def __str__(self):
|
||||
if self.tunnel is not None:
|
||||
return "{}, Tunnel: **{}**".format(self.info_str(), self.tunnel)
|
||||
|
@ -413,7 +417,7 @@ class Shop(Location):
|
|||
def inv_to_str(self):
|
||||
|
||||
if len(self.inventory.all()) != 0:
|
||||
inv = '\n\t*Inventory*'
|
||||
inv = '\n\t*Inventory:*'
|
||||
str_format = '{}\n\t\t{}'
|
||||
|
||||
for item in self.inventory:
|
||||
|
@ -423,8 +427,11 @@ class Shop(Location):
|
|||
else:
|
||||
return ''
|
||||
|
||||
def full_str(self):
|
||||
return Location.full_str(self) + self.inv_to_str()
|
||||
|
||||
def __str__(self):
|
||||
return Location.__str__(self) + self.inv_to_str()
|
||||
return Location.__str__(self)
|
||||
|
||||
def __init__(self, name, x, y, z, owner, dimension=None):
|
||||
Location.__init__(self, name, x, y, z, owner, dimension)
|
||||
|
@ -447,5 +454,8 @@ class ItemListing(SQL_Base):
|
|||
self.amount = amount
|
||||
self.shop = shop
|
||||
|
||||
def selling_info(self):
|
||||
return 'Shop: **{}**, {}'.format(self.shop.name, self.__str__())
|
||||
|
||||
def __str__(self):
|
||||
return "Item: {}, Price: {} for {}D".format(self.name, self.amount, self.price)
|
||||
return "Item: **{}**, Price: **{}** for **{}**D".format(self.name, self.amount, self.price)
|
||||
|
|
|
@ -253,7 +253,7 @@ async def additem(ctx, shop_name: str, item_name: str, quantity: int, diamond_pr
|
|||
|
||||
|
||||
@bot.command(pass_context=True)
|
||||
async def selling(item_name: str):
|
||||
async def selling(ctx, item_name: str):
|
||||
'''
|
||||
Lists all the shops selling an item
|
||||
|
||||
|
@ -262,7 +262,8 @@ async def selling(item_name: str):
|
|||
shop_list = database_interface.find_shop_selling_item(item_name)
|
||||
|
||||
shop_list_str = loc_list_to_string(shop_list)
|
||||
await bot.say('The following shops sell **{}**: \n {}'.format(item_name, shop_list_str))
|
||||
await bot.say('{}, the following shops sell **{}**: \n{}'.format(ctx.message.author.mention, item_name,
|
||||
shop_list_str))
|
||||
|
||||
|
||||
@bot.command(pass_context=True)
|
||||
|
@ -280,7 +281,7 @@ async def info(ctx, name: str):
|
|||
await bot.say('{}, no locations in the database match {}.'.format(ctx.message.author.mention, name))
|
||||
return
|
||||
|
||||
await bot.say('{}'.format(loc))
|
||||
await bot.say('{}'.format(loc.full_str()))
|
||||
|
||||
# Helper Functions ************************************************************
|
||||
|
||||
|
|
Loading…
Reference in New Issue