M
M
Maxim Rybka2021-04-18 23:34:19
Python
Maxim Rybka, 2021-04-18 23:34:19

How do I list steam inventory items?

There is a function that returns a list of items from the steam inventory for a given steamid:

def getInventory(steamid):
    data = urllib.request.urlopen('http://steamcommunity.com/profiles/'+steamid+'/inventory/json/730/2')
    json_data = json.loads(data.read())
    descriptions = json_data['rgDescriptions']
    print([descriptions[v]['name'] for v in descriptions])
    return

It works fine through print, but I need to display this list through the telegram bot:
@dp.message_handler(commands=['inventory'])
async def process_inventory_command(message: types.Message):
    tired = inventory.getInventory('76561198928902730')
    await message.reply('Содержимое инвентаря: ' +str(tired))

However, only "None" is displayed in the bot's chat, tell me why?
PS I don't really know python

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MinTnt, 2021-04-18
@Uchiha_Obito

return in the function, set it up normally so that it returns something other than None (nothing), as an example:

return '\n'.join([descriptions[v]['name'] for v in descriptions])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question