79133612

Date: 2024-10-28 13:36:09
Score: 3
Natty:
Report link

message.entities only contains metadata right? Not the actual user data ?

@dp.message(Command("buy"))
    @UsOper.public
    async def buy_item(message: Message, bot: Bot):  # Add bot parameter
        try:
            text_words = message.text.split()
            
            if len(text_words) == 3:
                username = text_words[1].replace("@", "")
                chat_member = await bot.get_chat_member(message.chat.id, username)
                user_id = chat_member.user.id
                item_title = text_words[2]
            elif len(text_words) == 2:
                item_title = text_words[1]
                user_id = message.from_user.id
                
            await AssortOper.buy_item(item_title, user_id, message.chat.id)
            await message.reply(f"Item {item_title} purchased!")
        except Exception as ex:
            print(ex, "__buy_item")
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Looks like a comment (1):
  • Low reputation (1):
Posted by: Big Fudge 1337