Forwarding messages through a telegram bot

43 views Asked by At

I need to implement a task in which I have a certain system that operates according to a script:

  1. user 1 sends a question to the bot

  2. the bot forwards this question to the group, which consists of several managers

  3. one of the managers answers the question sent by the bot

  4. the bot forwards the manager’s answer to the user who asked the question. In fact, the bot acts as an intermediary; there is no way to arrange this transfer.

    @bot.message_handler(func=lambda message: message.chat.id not in waiting_for_manager) def handle_user_question(message): waiting_for_manager[message.chat.id] = { 'user_message': message.text, 'manager_chat_id': 1111111 } bot.send_message(111111, f"Question {message.chat.id}:\n{message.text}")

    @bot.message_handler(func=lambda message: message.chat.id in waiting_for_manager) def handle_manager_response(message): chat_info = waiting_for_manager[message.chat.id] user_message = chat_info['user_message'] manager_chat_id = chat_info['manager_chat_id']

     bot.send_message(chat_info['manager_chat_id'], f"Answer:\n{message.text}")
     bot.send_message(message.chat.id, f"Answer:\n{message.text}")
    
     del waiting_for_manager[message.chat.id]
    

this is my block of code, which implements this transfer. Only 1 stage works correct, when user write a question to bot, he transfer question to chat with manager, but when manager write an answer, bot doesn't transfer it to chat with user

0

There are 0 answers