N
N
newbie632021-07-23 17:24:59
Python
newbie63, 2021-07-23 17:24:59

How can a bot send a message to a user, knowing his id?

I am writing a bot on aiogram, and when I write the /number (user id) (number) command, the bot should answer me ready and write a message to the user whose id I entered in the /number command.
Everything works except sending a message to another user

@dp.message_handler(commands=['number'], user_id=my_chat_id)
async def number(message: types.Message):
    conn = sqlite3.connect('db.db')
    cur = conn.cursor()
    currency, amount = message.text.split()[1:]
    result = cur.execute("SELECT * FROM users WHERE user_id = ?", (currency, )).fetchone()
    number = result[12]
    cur.execute("UPDATE users SET number = number + ? WHERE user_id = ?", (amount, currency))
    conn.commit()
    await message.reply('Готово')
    await message.answer(f'Вы получили {amount} монет', user_id=currency) #не работает

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-07-23
@newbie63

bot.send_message(), oddly enough
https://docs.aiogram.dev/en/latest/telegram/bot.ht... ps
why the user id is in the "currency" variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question