F
F
FEFF142021-12-21 06:47:26
Python
FEFF14, 2021-12-21 06:47:26

How can I make it possible for customers to respond via chat?

The person in the bot creates a request, this message comes to the chat and in the chat it was possible to answer him

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
desaki, 2021-12-21
@desaki

from aiogram.dispatcher import filters

# Отвечает за отправку сообщения юзеру
async def send_message(message, msg, user_id):
  await message.bot.send_message(user_id, msg)

@bot.message_handler(filters.Text(startswith="send", ignore_case=False))
async def _send(message):
  if len(message.text.split(" ")) >= 2:
    user_id = message.text.split(" ")[1] # Айдишник юзера
    msg = message.text.split(" ")[2] # Ваше сообщение
    print(user_id, msg)
    await send_message(message, msg, user_id)
  else:
    await message.answer("send <user_id> <message>")

spoiler
61c16ddbd68d1899905369.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question