Td: Don't know what to do

Created on 12 Sep 2019  路  16Comments  路  Source: tdlib/td

Hi, i am using php extension yaroslav-che. Trying to print 'new message' when i send new message to my bot, but it does not working.
Code: https://pastebin.com/fi6MCeNk
code print authorization is complete and then this one: https://pastebin.com/9Gc3UY4R
When i send message to bot, nothing changes

All 16 comments

In the provided log TDLib is closed almost eventually, before it is able to send anything.
The code does exactly this, because it exits main loop whenever the client is authorized and is ready to send messages and receiving updates by setting $ready_for_send variable to 1.

Yeah, right. And here's another question: I have UpdateNewMessage it reacts to incoming and outgoing messages how to remove it

You can check is_outgoing field of a Message.

I added this one:
if($update['last_message']['is_outgoing'] == false)
{
$text_entity_type = ['@type' => 'textEntityTypeBotCommand'];
$entities = [['offset' => '0', 'length' => '2', 'TextEntityType' => $text_entity_type]];
$formatted_text = ['text' => 'hi', 'entities' => $entities];
$input_message = ['@type' => 'inputMessageText', 'text' => $formatted_text, 'disable_web_page_preview' => false, 'clear_draft' => false];
$query = json_encode(['@type' => 'sendMessage', 'chat_id' =>'', 'reply_to_message_id' => '0', 'disable_notification' => false, 'from_background' => false, 'reply_markup' => null, 'input_message_content' => $input_message]);
td_json_client_send($client, $query);
}
but nothing change

updateNewMessage has no field last_message.

There is

I meaned ChatLastMessage

Don't use updateChatLastMessage, you need updateNewMessage. Also see https://core.telegram.org/tdlib/getting-started.

make this one:
if($update['message']['is_outgoing'] == false)
{
$text_entity_type = ['@type' => 'textEntityTypeBotCommand'];
$entities = [['offset' => '0', 'length' => '2', 'TextEntityType' => $text_entity_type]];
$formatted_text = ['text' => 'hi', 'entities' => $entities];
$input_message = ['@type' => 'inputMessageText', 'text' => $formatted_text, 'disable_web_page_preview' => false, 'clear_draft' => false];
$query = json_encode(['@type' => 'sendMessage', 'chat_id' => '', 'reply_to_message_id' => '0', 'disable_notification' => false, 'from_background' => false, 'reply_markup' => null, 'input_message_content' => $input_message]);
td_json_client_send($client, $query);
}
but nothing changes

You don't specified chat_id: 'chat_id' => ''.

Between you should always receive an error which tells, what was done wrong. You can also find sent request in the TDLib's log.

I deleted it before posting here

I cant understand why messages are sending? I put 'is_outgoing' == false, not true

I run code and after some time messages start sending automatically, without my messages. And the compiler shows no errors

You can log all incoming updates to clearly see the reason.

There was error in my code. This is the solution: put 'is_outgoing' == fallse

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isopen picture isopen  路  5Comments

L11R picture L11R  路  4Comments

sh-a-v picture sh-a-v  路  3Comments

pishnok picture pishnok  路  3Comments

Losses picture Losses  路  3Comments