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

Unknown class "messageReplyToMessage"" #2786

Closed tofers closed 8 months ago

tofers commented 8 months ago

@type: sendMessage chat_id: chatId (-100123456789) message_thread_id: MessageThreadId (123456) reply_to: {@type: messageReplyToMessage chat_id: chatId (-100123456789) message_id: ReplyToMessageId (1234567)}

"Failed to parse JSON object as TDLib request: Unknown class "messageReplyToMessage""

"Failed to parse JSON object as TDLib request: Unknown class "messageReplyTo""

tdlib 1.8.24

levlam commented 8 months ago

Class "messageReplyTo" doesn't exist, but "messageReplyToMessage" is a valid class name for TDLib 1.8.24. Check response of getOption("version") to ensure that you use TDLib 1.8.24.

tofers commented 8 months ago
{
  chatId: 321111,
  messageThreadId: 0,
  inputMessageContent: {
    @type: 'inputMessageText',
    text: { @type: 'formattedText', text: 'ff', entities: [] },
  },
  replyTo: {
    @type: 'messageReplyToMessage',
    chatId: 321111,
    messageId: 7675576321
  }
}

[ 3][t 0][1707995871.894760370][Client.cpp:293][&tdrequests] End to wait for updates, returning object 7 0x7f55d8088a00 version: { airgram: [Getter], getState: [Function: getState], setState: [Function: setState], : 'getOption', options: {}, request: { method: 'getOption', params: { name: 'version' } }, response: { _: 'optionValueString', value: '1.8.24' } }

[ 3][t 4][1707995871.925956964][Td.cpp:3034][#1][!Td][&td_requests] Receive static request: testReturnError { error = error { code = 400 message = "Failed to parse JSON object as TDLib request: Unknown class "messageReplyToMessage"" } }

tofers commented 8 months ago

messageReplyToMessage

Yes, it worked in December. But it's not working today

levlam commented 8 months ago

The parameter reply_to has type InputMessageReplyTo, so you must use either inputMessageReplyToMessage or inputMessageReplyToStory.

Also, as chat_id documentation states, you must "pass 0 if the message to be replied is in the same chat".

tofers commented 8 months ago

Thanks for your help, I was close.

ZdGram commented 7 months ago

protected content and can't be forwarded is printed

ZdGram commented 7 months ago

@levlam If the bot reply to a message in a content_protector group, the res will be "protected content and can't be forwarded is printed"

levlam commented 7 months ago

@ZdGram Check documentation of inputMessageReplyToMessage.chat_id, for which you pass a wrong value:

The identifier of the chat to which the message to be replied belongs; pass 0 if the message to be replied is in the same chat. Must always be 0 for replies in secret chats. A message can be replied in another chat or topic only if message.can_be_replied_in_another_chat

kubsite1 commented 6 months ago

Sorry, guys! @tofers @levlam I have a similar problem and I did not understand the solution from the messages. Could you tell me more precisely?

previously, replies to messages were sent like this, on version 1.8.25 it does not send replies, but regular messages

$r = $this->cli->query(json_encode([
                '@type'=>'sendMessage',
                'chat_id'   =>  $tgid,
                'reply_to_message_id'   =>  ($refId?$refId:0),
                'from_background'       =>  true,
                'input_message_content' =>  [
                    '@type' =>  'inputMessageText',
                    'text'  =>  [
                        '@type' =>  'formattedText',
                        'text'  =>  urldecode($text),
                        'entities'  =>  []
                    ],
                    'disable_web_page_preview'  =>  false,
                    'clear_draft'   =>  false
                ]
            ]));

reply_to_message_id is no longer used? has reply_to appeared? But how exactly do I specify the values?

the following version of the code gives an error: "Failed to parse JSON object as TDLib request: Unknown class "messageReplyToMessage"

$r = $this->cli->query(json_encode([
                '@type'=>'sendMessage',
                'chat_id'   =>  $tgid,
                //'reply_to_message_id' =>  ($refId?(int)$refId:0),
                'reply_to'  =>  [   '@type'=>'messageReplyToMessage', 
                                'chat_id'=> 0, 
                                'message_id'=>$refId
                    ],
                'from_background'       =>  true,
                'input_message_content' =>  [
                    '@type' =>  'inputMessageText',
                    'text'  =>  [
                        '@type' =>  'formattedText',
                        'text'  =>  urldecode($text),
                        'entities'  =>  []
                    ],
                    'disable_web_page_preview'  =>  false,
                    'clear_draft'   =>  false
                ]
            ]));
tofers commented 6 months ago

messageReplyToMessage

messageReplyToMessage -> inputMessageReplyToMessage

{
  chatId: 321111,
  messageThreadId: 0,
  inputMessageContent: {
    @type: 'inputMessageText',
    text: { @type: 'formattedText', text: 'ff', entities: [] },
  },
  replyTo: {
    @type: 'inputMessageReplyToMessage',
    messageId: 7675576321
  }
}
kubsite1 commented 6 months ago

@tofers thank you very much! 🤝