tdlib / td

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

SendDocument Message Pending #2886

Open Mashi-91 opened 4 months ago

Mashi-91 commented 4 months ago

Text Message going fine. But on document or photo etc showing pending state

Screenshot 2024-05-16 112233 Screenshot 2024-05-16 112252

{chat_id: 774194172, last_message: {id: 7933526113, sender_id: {user_id: 774194172, @type: messageSenderUser}, chat_id: 774194172, sending_state: {sending_id: 0, @type: messageSendingStatePending}, scheduling_state: null, is_outgoing: true, is_pinned: false, is_from_offline: false, can_be_edited: false, can_be_forwarded: true, can_be_replied_in_another_chat: false, can_be_saved: true, can_be_deleted_only_for_self: true, can_be_deleted_for_all_users: false, can_get_added_reactions: false, can_get_statistics: false, can_get_message_thread: false, can_get_read_date: false, can_get_viewers: false, can_get_media_timestamp_links: false, can_report_reactions: false, has_timestamped_media: true, is_channel_post: false, is_topic_message: false, contains_unread_mention: false, date: 1715838604, edit_date: 0, forward_info: null, import_info: null, interaction_info: null, unread_reactions: [], reply_to: null, message_thread_id: 0, saved_messages_topic_id: 774194172, self_destruct_type: null, self_destruct_in: 0.0, auto_delete_in: 0.0, via_bot_user_id: 0, sender_business_bot_user_id: 0, sender_boost_count: 0, author_signature: , media_album_id: 0, restriction_reason: , content: {document: {file_name: Taska.png, mime_type: image/png, minithumbnail: null, thumbnail: null, document: {id: 39, size: 2173544, expected_size: 2173544, local: {path: C:\Users\aadil\OneDrive\Pictures\Freelance\Taska.png, can_be_downloaded: false, can_be_deleted: false, is_downloading_active: false, is_downloading_completed: true, download_offset: 0, downloaded_prefix_size: 2173544, downloaded_size: 2173544, @type: localFile}, remote: {id: , unique_id: , is_uploading_active: true, is_uploading_completed: false, uploaded_size: 2173544, @type: remoteFile}, @type: file}, @type: document}, caption: {text: -u-t-s- 1715838604389 e-n-d- 1861186925 --lbl--, entities: [{offset: 8, length: 13, type: {@type: textEntityTypeBankCardNumber}, @type: textEntity}], @type: formattedText}, @type: messageDocument}, reply_markup: null, @type: message}, positions: [], @type: updateChatLastMessage}

levlam commented 4 months ago

All outgoing messages need some time to be send and have state messageSendingStatePending until that. You can send full TDLib log with verbosity 4 since app launch to https://t.me/tdlib_bot if the message isn't sent for a long time.

Mashi-91 commented 4 months ago

can i just sent log file? But text msg just go fine

levlam commented 4 months ago

Log contains private data, so it must not be sent publicly.

Mashi-91 commented 4 months ago

i just send full log to bot. now wht?

Here's the thing text msg just going fine. others goes in pending. Why's that?

Here take a look at this. this wht i am getting when loading chats this when i upload file. only caption get not file and also nothing in telegram app. even though i deleted all msg.

flutter: β”‚ πŸ’‘ { flutter: β”‚ πŸ’‘ "text": "-u-t-s- 1715854240315 e-n-d- 531090172 --lbl--", flutter: β”‚ πŸ’‘ "entities": [], flutter: β”‚ πŸ’‘ "@type": "formattedText" flutter: β”‚ πŸ’‘ } flutter: └──────

Mashi-91 commented 4 months ago

Showing this is_uploading_completed true like 50 times and then show nothing. Then show another log

flutter: └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── flutter: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ flutter: β”‚ #0 HomeScreen.build.. (package:CloudInfinity/screens/widgets/home_screen.dart:51:22) flutter: β”‚ #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10) flutter: β”œβ”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„ flutter: β”‚ πŸ’‘ Update: {file: {id: 1257, size: 1819735, expected_size: 1819735, local: {path: C:\Users\aadil\OneDrive\Pictures\Wallpaper\sunset standing alone mountains scenery.jpg, can_be_downloaded: false, can_be_deleted: false, is_downloading_active: false, is_downloading_completed: true, download_offset: 0, downloaded_prefix_size: 1819735, downloaded_size: 1819735, @type: localFile}, remote: {id: , unique_id: , is_uploading_active: true, is_uploading_completed: false, uploaded_size: 1819735, @type: remoteFile}, @type: file}, @type: updateFile} flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Then show this log

[ 4][t 5][1715855954.160365104][MultiTimeout.cpp:84][#1][!PendingSendDialogActionTimeout] Set timeout of PendingSendDialogActionTimeout in 0.063011 [ 3][t 5][1715855954.160404443][MessagesManager.cpp:31111][#1][!MessagesManager] Receive send_chat_action timeout in chat 774194172 [ 4][t 5][1715855954.160410404][MultiTimeout.cpp:38][#1][!MessagesManager] Add PendingSendDialogActionTimeout for 774194172 in 4.000000 [ 3][t 5][1715855954.160417318][MessagesManager.cpp:31902][#1][!MessagesManager] Search for yet unsent message 7573.1 in chat 774194172 found 000002065CDA0AC0 [ 3][t 5][1715855954.160425424][MessagesManager.cpp:31164][#1][!MessagesManager] Send ChatActionUploadingDocumentAction in chat 774194172 [ 3][t 5][1715855954.160429716][DialogActionManager.cpp:316][#1][!MessagesManager] Skip unneeded ChatActionUploadingDocumentAction in chat 774194172

levlam commented 4 months ago

You don't process updateFileGenerationStart and hence the being generated file blocks message queue.

Mashi-91 commented 4 months ago
  1. then how will it take to work again?
  2. why msg still getting after deleted?
levlam commented 4 months ago
  1. Process updateFileGenerationStart as documented.
  2. Because text messages and some other messages aren't ordered with media messages.
Mashi-91 commented 3 months ago

why showing this

  1. Sending error for request 12: error { code = 400 message = "Chat not found" } after login and after logout. when try to login again showing this
  2. Sending error for request 5: error { code = 401 message = "Unauthorized" }

First solve after login restart the app

levlam commented 3 months ago
  1. You only can use identifiers received from the same TDLib instance.
  2. You aren't logged in yet.
Mashi-91 commented 3 months ago

how i logout completely?

levlam commented 3 months ago

By calling logOut and waiting for authorizationStateClosed.

Mashi-91 commented 3 months ago

That is how i do it bro. Then i got the error.

levlam commented 3 months ago

Which is expected because you have logged out.

Mashi-91 commented 3 months ago

But it is supposed to login instead of showing unauthorised error even though i was login with new phone number.

levlam commented 3 months ago

No. A TDLib instance can't be reused. You must create a new instance for new authorization.

Mashi-91 commented 3 months ago

Web showing Unimplementation Error. Can you tell how i can add web one?

levlam commented 3 months ago

There is no "Unimplementation" error in TDLib.

Mashi-91 commented 3 months ago

On this package i am using there's no implementation of web Screenshot 2024-05-18 155125

levlam commented 3 months ago

TDLib supports Web using WebAssembly: https://github.com/tdlib/td/tree/master/example/web, so it can be used from there. You can check https://github.com/tdlib/td/blob/master/example/web/tdweb/README.md for description of TDLib usage from Web.

Mashi-91 commented 3 months ago

i dont know bro how i do it can guide me?

levlam commented 3 months ago

All available information on the usage is written in the example README.

Mashi-91 commented 3 months ago

I am getting only one message why's that?

which is Latest one but i want all of them.. and run again the function getting all the messages.

Screenshot 2024-05-21 160136

levlam commented 3 months ago

See https://core.telegram.org/tdlib/getting-started#getting-chat-messages.

Mashi-91 commented 3 months ago

final tda.User user = await TelegramClient().client!.send(tda.GetMe());

when i first login then call this function and after that call getChatHistory function show this error chatNotFound until i verify the device from telegram app..

// Send the message await client!.send( tda.SendMessage( chatId: id, messageThreadId: 0, // Specify the message thread ID if applicable inputMessageContent: inputMessageContent, ), );

levlam commented 3 months ago

GetMe() returns a user. You must use CreatePrivateChat to create a private chat with a user.

Mashi-91 commented 3 months ago

But i am not creating any chat i am getting saved chats. And its works after i verify the device on my telegram app with the same code.

levlam commented 3 months ago

You need a chat to send a message. You don't have one after calling getMe, because it returns a user, but not a chat.

Mashi-91 commented 3 months ago

is there any way to create a folder or is there any field in tdlib, i can use for creating folder like somekind of list?

levlam commented 3 months ago

A chat folder can be created using the method createChatFolder.

Mashi-91 commented 3 months ago

is there any field where i can store ids like its not use or like users can't use the field Its Must Be List

levlam commented 3 months ago

You can store some data using setOption starting with "X", or using "setChatClientData".

Mashi-91 commented 3 months ago

but i want to store like list

levlam commented 3 months ago

Then, serialize it.

Mashi-91 commented 3 months ago

i just create lots of folder ids using SetOptions. how i get them all? cauze GetOption only return one. GetOption(name: '')

levlam commented 3 months ago

You receive all up-to-date values of options through getOption updates.

Mashi-91 commented 3 months ago

Sending error for request 11: error { code = 400 message = "Option can't be set" }

await TelegramClient().client!.send( tda.SetOption( name: 'Hello Another', value: tda.OptionValueString(value: "HEy I am here")), );

showing the error after setOptions

levlam commented 3 months ago

Only options starting with 'X' and 'x' are reserverd for app usage.

Mashi-91 commented 3 months ago

i want to create a folder so is there anyway of do it like.?

Mashi-91 commented 3 months ago

can u tell me the name which ( Option ) is best for storing ids?

levlam commented 3 months ago

Telegram has only chat folders, that can be created using createChatFolder.

levlam commented 3 months ago

You can choose arbitrary name for custom options that starts with "x" or "X".

Mashi-91 commented 3 months ago

β”‚ β›” Error fetching file chat: TdFunctionException(function: {chat_id: 774194172, from_message_id: 0, offset: 0, limit: 10, only_local: false, @type: getChatHistory}, error: {code: 400, message: Chat not found, @type: error})|

showing this error. bro even though chat exist which is saved Messages. sometime work sometime didn't.

Screenshot 2024-06-02 114003

levlam commented 3 months ago

You can only pass identifiers received from the same TDLib instance.

If you want to get Saved Messages chat, then you need to call getMe, then createPrivateChat, and the use the received chat.

Mashi-91 commented 3 months ago

I already tried GetMe func before calling GetChatHistory function. And still showing the same thing.

levlam commented 3 months ago

You must pass chat_id to getChatHistory. You have no chat after calling getMe.

Mashi-91 commented 3 months ago

I actually store the chat id in local storage when the app starts for the first time.

levlam commented 3 months ago

You can only pass identifiers received from the same TDLib instance.

Mashi-91 commented 2 months ago

i didn't understand bro can u more specific?

levlam commented 2 months ago

Apps aren't supposed to store anything persistently. Everything needed is stored by TDLib and must be obtained from it.