tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

removeMessageReaction method not working #2746

Closed kjlsdlkfio332fsdkla32skjdf closed 9 months ago

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Greetings! I am using the code to remove the reaction to the message (shown below). It turns out that when the reaction deletion function is called (if you set the reaction before starting the program), the ok response is returned, but the reaction is not deleted. However, if the reaction is set during the program session, then the reaction is deleted stably (I tried to put it in a loop and it worked). How can this be fixed? (C++ Using)

` //Считаем message_id с коэффицентом 1048576 message_id = message_id * 1048576;

//Получаем чат
auto get_chat = td_api::make_object<td_api::getChat>();
get_chat->chat_id_ = chat_id;
client_manager->send(client_id, 3, move(get_chat));

//Получаем ответ от запроса
for (int i = 0; i < 10000; i++) {
    auto response = client_manager->receive(0);
    if (response.request_id == 3) {
        break;
    }
    this_thread::sleep_for(100ms);
}

//Получаем сообщение
auto get_message = td_api::make_object<td_api::getMessage>();
get_message->chat_id_ = chat_id;
get_message->message_id_ = message_id;
client_manager->send(client_id, 4, move(get_message));

//Получаем ответ от запроса
for (int i = 0; i < 10000; i++) {
    auto response = client_manager->receive(0);
    if (response.request_id == 4) {
        break;
    }
    this_thread::sleep_for(100ms);
}

//Выбираем реакцию для удаления
auto removing_reaction = td_api::make_object<td_api::reactionTypeEmoji>();
removing_reaction->emoji_ = "❤️";

//Форумируем запрос на удаление реакции
auto remove_reaction = td_api::make_object<td_api::removeMessageReaction>();
remove_reaction->chat_id_ = chat_id;
remove_reaction->message_id_ = message_id;
remove_reaction->reaction_type_ = move(removing_reaction);

//Отправляем запрос
client_manager->send(client_id, 5, move(remove_reaction));
//Получаем ответ
for (int i = 0; i < 10000; i++) {
    auto response = client_manager->receive(0);
    if (response.request_id == 5) {
        if (to_string(response.object).find("ok") == string::npos) {
            log("ERR", "AUTORIZATION_ERR", "Не удалось удалить реакцию : " + path);
            log("", "", to_string(response.object));
            return 1;
        }
        break;
    }
    this_thread::sleep_for(100ms);
}`
levlam commented 9 months ago

You can pass only reaction that is present on the message as received from TDLib. Passing hardcoded data will not work. Reactions are updated on messages when this is appropriate. Usually, user needs to view the message to have reactions on it updated.

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Yes, I know that it is necessary to get a reaction using the appropriate method, but in this example I am testing this functionality and taking this reaction (I also set it on the message). How can I manually update the required information and delete the reaction?

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Да, я знаю, что необходимо получить реакцию соответствующим методом, но в данном примере я тестирую этот функционал и беру эту реакцию (её я тоже устанавливаю на сообщение). Как я могу вручную обновить необходимую информацию и удалить реакцию?

That is, pre-programmed data is used only for testing the functionality, taking into account that this particular reaction is based on the specified message.

levlam commented 9 months ago

Apps are expected to receive the message and reactions to it from TDLib. If the message contains the reaction as provided by TDLib, then removeMessageReaction will work for the message and reaction. If the message received from TDLib doesn't have the reaction known, then removeMessageReaction will do nothing.

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Ожидается, что приложения получат сообщение и реакцию на него от TDLib. Если сообщение содержит реакцию, предоставленную TDLib, то removeMessageReactionэто сообщение и реакция будут работать. Если на сообщение, полученное от TDLib, не известна реакция, removeMessageReactionничего не произойдет.

Okay, I get it, thanks. so still, what method can I use to get information about reactions to a message in order to delete my reaction

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Ожидается, что приложения получат сообщение и реакцию на него от TDLib. Если сообщение содержит реакцию, предоставленную TDLib, то removeMessageReactionэто сообщение и реакция будут работать. Если на сообщение, полученное от TDLib, не известна реакция, removeMessageReactionничего не произойдет.

Okay, I get it, thanks. so still, what method can I use to get information about reactions to a message in order to delete my reaction

updateMessageInteractionInfo it is triggered only when the update occurred during the session (i.e., after the program was launched, all reactions that were before the program was launched are not loaded.)

levlam commented 9 months ago

Reactions are updated on messages when this is appropriate. Usually, user needs to view the message to have reactions on it updated.

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Реакции на сообщения обновляются, когда это необходимо. Обычно пользователю необходимо просмотреть сообщение, чтобы обновить реакцию на него.

How can I do this? the viewmessage method did not help

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

viewmessages*

levlam commented 9 months ago

By calling viewMessages with appropriate source.

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

Позвонив viewMessagesс соответствующим source.

Thank you very much for the reply. I will try to test it, but so far, to be honest, it has not been very successful. I will be very glad if you can share an example of how to implement it, because there is little written in the documentation about working with these methods.

kjlsdlkfio332fsdkla32skjdf commented 9 months ago

I used 4 methods to solve the issue :

  1. getchat
  2. openhat 3.viewmessage 4.getmessage After that, the program worked correctly.