Giter Site home page Giter Site logo

Comments (15)

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024 1

With limit 20 works fine, but with limit 200 returns only 100 chats.
Correct chats order returns by events updateChatOrder. And paging with them works! Thanks!

from phptdlib.

maxvgi avatar maxvgi commented on June 18, 2024 1

with limit 200 returns only 100 chats.

Due to the docs,

For optimal performance the number of returned chats is chosen by the library.

Tdlib will not return more then 100 chats because of it's internal limit.

from phptdlib.

levlam avatar levlam commented on June 18, 2024 1

Getting the list of chats is also covered by https://core.telegram.org/tdlib/getting-started#getting-the-list-of-chats.

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

Seems this and this might help. Can you provide some your code for reproducing? When I try to query getChats it seems works as expected: "{"@type":"chats","chat_ids":[ids],"@extra":1681692777}"

from phptdlib.

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024

I wanna get all my chats, but tdlib returns last 100. It seems i have to pass pair chat.order and chat.id. But chat.order always equals "0"

Request:

{
	"@type": "getChat",
	"chat_id": -1001316515825,
	"@extra": "3a7635623e2144d8421a694c23c8c87c"
}

Response:

{
	"@type": "chat",
	"id": -1001316515825,
	"type": {
		"@type": "chatTypeSupergroup",
		"supergroup_id": 1316515825,
		"is_channel": false
	},
	"title": "ildar_test_group_4",
	"last_message": {
		"@type": "message",
		"id": 46137344,
		"sender_user_id": 205997042,
		"chat_id": -1001316515825,
		"is_outgoing": true,
		"can_be_edited": true,
		"can_be_forwarded": true,
		"can_be_deleted_only_for_self": false,
		"can_be_deleted_for_all_users": true,
		"is_channel_post": false,
		"contains_unread_mention": false,
		"date": 1565181834,
		"edit_date": 0,
		"reply_to_message_id": 0,
		"ttl": 0,
		"ttl_expires_in": 0.000000,
		"via_bot_user_id": 0,
		"author_signature": "",
		"views": 0,
		"media_album_id": "0",
		"content": {
			"@type": "messageText",
			"text": {
				"@type": "formattedText",
				"text": "ddddddddddddddddddddddddd",
				"entities": []
			}
		}
	},
	"order": "0", ------------------------------------------------- ?????---------------------------
	"is_pinned": false,
	"is_marked_as_unread": false,
	"is_sponsored": false,
	"can_be_deleted_only_for_self": false,
	"can_be_deleted_for_all_users": false,
	"can_be_reported": false,
	"default_disable_notification": false,
	"unread_count": 0,
	"last_read_inbox_message_id": 46137344,
	"last_read_outbox_message_id": 19922944,
	"unread_mention_count": 0,
	"notification_settings": {
		"@type": "chatNotificationSettings",
		"use_default_mute_for": true,
		"mute_for": 0,
		"use_default_sound": true,
		"sound": "default",
		"use_default_show_preview": true,
		"show_preview": false,
		"use_default_disable_pinned_message_notifications": true,
		"disable_pinned_message_notifications": false,
		"use_default_disable_mention_notifications": true,
		"disable_mention_notifications": false
	},
	"pinned_message_id": 0,
	"reply_markup_message_id": 0,
	"client_data": "",
	"@extra": "3a7635623e2144d8421a694c23c8c87c"
}

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

Hm, interesting question =)

std::int64_t | order_ Descending parameter by which chats are sorted in the main chat list. If the order number of two chats is the same, they must be sorted in descending order by ID. If 0, the position of the chat in the list is undetermined.

From docs

And if you want to receive more than 100 chats use getChats with limit parameter. Also with offset if needs. Something like: {"@type": "getChats", "limit": 200, "@extra": "1"}
In response you will receive chat_ids, which you can use if need detailed information for each ("@type": "getChat", "chat_id": $id).

from phptdlib.

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024

"limit": 200 - doesn't work, returns only 100 chats

from phptdlib.

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024

And i can't paging it, because last chat order is equal "0"

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

"limit": 200 - doesn't work, returns only 100 chats

try this: {"@type":"getChats","limit":200,"offset_order":9223372036854775807,"offset_chat_id":0}. Same behavior for you? I can't check at this moment because in response I have received empty list =) If yes, you should ask (or find existing) about this in tdlib/td.

And i can't paging it, because last chat order is equal "0"

If the order number of two chats is the same, they must be sorted in descending order by ID

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

If I correctly understood what you want to achieve, than you need use offset_chat_id. For example, collected first 100. Store last chat_id. For next page you should pass just offset_chat_id. But I don't know if this is correct way. Actually this question more likely related to tdlib/td, not the extension. And I would be happy to help, but that’s all I can say. Please let me know how the problem was solved and whether it was solved at all.

from phptdlib.

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024

Request:

{
	"@type": "getChats",
	"limit": 200,
	"offset_order": 9223372036854775807,
	"offset_chat_id": 0,
	"@extra": "f5c93e3b26c383ca2e775cb54b808509"
}

Response:

{
	"@type": "chats",
	"chat_ids": [========100 items ===========],
	"@extra": "f5c93e3b26c383ca2e775cb54b808509"
}

from phptdlib.

ildarsaitkulov avatar ildarsaitkulov commented on June 18, 2024

Thanks! It seems bug in tdlib

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

ping @levlam
Is that bug, or something wrong in this extension? Or we doing something wrong?

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024
"{"@type":"getChats","limit":200,"offset_order":9223372036854775807,"offset_chat_id":0}"
[ 3][t 4][1565260465.402750969][Td.cpp:3285][#1][!Td][&td_requests]     Receive request 3: getChats {
  offset_order = 9223372036854775807
  offset_chat_id = 0
  limit = 200
}
[ 3][t 4][1565260465.403002262][MessagesManager.cpp:11455][#1][!GetChatsRequest]        Get chats with offset [9223372036854775807, 0] and limit 200. Know about order of 0 chat(s). last_dialog_date_ = [9223372036854775807, 0], last_server_dialog_date_ = [9223372036854775807, 0], last_loaded_database_dialog_date_ = [9223372036854775807, 0]
[ 3][t 4][1565260465.403044224][MessagesManager.cpp:11487][#1][!GetChatsRequest]        Load dialog list with limit 100
[ 3][t 4][1565260465.403148174][MessagesManager.cpp:11521][#1][!GetChatsRequest]        Load 100 dialogs from database from [9223372036854775807, 0], last database server dialog date = [0, 0]
[ 3][t 1][1565260465.403553724][DialogDb.cpp:208][#1][!DialogDbActor]   Load chat 777000 with order 6721688753850548233
[ 3][t 4][1565260465.404390335][MessagesManager.cpp:11537][#1][!MessagesManager]        Receive 1 from expected 100 dialogs in result of GetDialogsFromDatabase
[ 3][t 4][1565260465.404471397][MessagesManager.cpp:24587][#1][!MessagesManager]        Loaded chat 777000 of size 624 from database
[ 3][t 4][1565260465.404742002][MessagesManager.cpp:4065][#1][!MessagesManager] Set unread mention message count in chat 777000 to -1
[ 3][t 4][1565260465.405164719][ContactsManager.cpp:5478][#1][!MessagesManager] Trying to load user 777000 from database
[ 3][t 4][1565260465.405285120][ContactsManager.cpp:5385][#1][!MessagesManager] Successfully loaded user 777000 of size 64 from database
[ 4][t 4][1565260465.405455828][ContactsManager.cpp:6203][#1][!MessagesManager] Cancel online timeout for user 777000

...

[ 3][t 4][1565260465.407611609][MessagesManager.cpp:8459][#1][!MessagesManager] Recalculate unread counts
[ 4][t 4][1565260465.407623529][MessagesManager.cpp:8482][#1][!MessagesManager] Have 9 messages in chat 777000
[ 3][t 4][1565260465.407636404][MessagesManager.cpp:11583][#1][!MessagesManager]        Schedule chat list preload
[ 3][t 4][1565260465.407859564][MessagesManager.cpp:11455][#1][!GetChatsRequest]        Get chats with offset [9223372036854775807, 0] and limit 200. Know about order of 1 chat(s). last_dialog_date_ = [0, 0], last_server_dialog_date_ = [0, 0], last_loaded_database_dialog_date_ = [0, 0]
[ 3][t 4][1565260465.407997608][Td.cpp:4395][#1][!Td][&td_requests]     Sending result for request 3: chats {
  chat_ids = vector[1] {
    777000
  }
}

from phptdlib.

yaroslavche avatar yaroslavche commented on June 18, 2024

I have just tested with limit 20. Works fine. @ildarsaitkulov can you check please? I can't test with limit 200, cause I have just 40 channels =) Seems that not a bug in tdlib/td.

from phptdlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.