Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

messages.getAllChats always retrun INPUT_METHOD_INVALID_2271179966_* #279

Open
bigbigsir opened this issue Apr 25, 2023 · 21 comments
Open

Comments

@bigbigsir
Copy link

bigbigsir commented Apr 25, 2023

layer: 139

image

image

image

Is there anyone who can help me?

@wind-hx
Copy link

wind-hx commented Apr 25, 2023

I also encounter the same problem

@0xARK
Copy link

0xARK commented Apr 25, 2023

Hello, I also have this problem

@bigbigsir
Copy link
Author

What happened? It didn't change anything, and all of a sudden it didn't work

@bigbigsir
Copy link
Author

@alik0211

@0xARK
Copy link

0xARK commented Apr 26, 2023

I checked the telegram api docs for update or something else, but I saw nothing related to getAllChats...

@destyk
Copy link

destyk commented Apr 28, 2023

This error is true for me too

@alexsanderluisdev
Copy link

same for me, has anyone found any solution?

@alexsanderluisdev
Copy link

Has anyone found any solution?

@destyk
Copy link

destyk commented May 2, 2023

@alik0211

@0xARK
Copy link

0xARK commented May 3, 2023

It seems that this method has been removed from telegram API, and getDialogs must be used instead.

See gram-js/gramjs#522

@alexsanderluisdev
Copy link

alexsanderluisdev commented May 3, 2023

It seems that this method has been removed from telegram API, and getDialogs must be used instead.

See gram-js/gramjs#522

however the getDialogs method gets only recent conversations and not all conversations.

@0xARK
Copy link

0xARK commented May 3, 2023

Oh, didn't noticed that, I just saw this answer... It will be a problem for me too, more digging is necessary :(

@alexsanderluisdev
Copy link

Oh, didn't noticed that, I just saw this answer... It will be a problem for me too, more digging is necessary :(

I don't understand the Telegram have removed this method without any notice, causing a breaking change.

@alexsanderluisdev
Copy link

@0xARK any solution?

@0xARK
Copy link

0xARK commented May 6, 2023

No, I didn't have time to look into it

@0xARK
Copy link

0xARK commented May 8, 2023

@alexsanderluisdev
Copy link

@0xARK this don't work for me. Causes a infinity loop.

@0xARK
Copy link

0xARK commented May 9, 2023

it's working on my side, check the adapted method for mtproto :

const getAllChats = async () => {
            const LIMIT = 100;
            const offsetId = 0;
            const offsetPeer = {
                _: 'inputPeerEmpty'
            };

            let resultCount = LIMIT;
            let offsetDate = 0;
            let chats = [];

            while (resultCount >= LIMIT) {
                const result = await mtproto.call('messages.getDialogs', {
                    offset_id: offsetId,
                    offset_peer: offsetPeer,
                    offset_date: offsetDate,
                    limit: LIMIT
                }).catch(e => {
                    if (e.error_message.includes('FLOOD_WAIT')) {
                        log.warn("Telegram", `API rate limit reached, please wait ${e.error_message.replace('FLOOD_WAIT_', '')} seconds`);
                    } else log.error("Telegram", e.message);
                })

                resultCount = result.dialogs.length;

                if (result.chats && result.chats.length > 0) {
                    chats = [...chats, ...result.chats];
                }

                if (result.messages.length > 0) {
                    offsetDate = result.messages[result.messages.length - 1].date;
                } else {
                    break;
                }
            }

            return chats;
        }

@alexsanderluisdev
Copy link

don't work, this lists even fewer chats, and chats that have no interaction are still not listed

@Endytech
Copy link

Endytech commented May 31, 2023

I used messages.getAllChats to get all chats and then filter chats to get only chats that we need.

To get chats according to a pre-known list I used two method. First try to find by @name. If @name do not exists then find by search and filter by chat.title.

static async getChatsByUsername(username) {
     let resolvedPeer = { chats: [] };
     try {
         resolvedPeer = await api.call('contacts.resolveUsername', {
             username,
         });
     } catch (error) {
         console.warn('Error to get chat', username);
     }
     const chat = resolvedPeer.chats.find((chat) => (chat.id === resolvedPeer.peer.channel_id));
     return chat;
 }

static async searchChatsByTitle(title) {
        const searchResult = await api.call('contacts.search', {
            q: title,
        });
        return searchResult.chats.find((chat) => (chat.title === title));
    }

@joeberetta
Copy link

Oh, didn't noticed that, I just saw this answer... It will be a problem for me too, more digging is necessary :(

I don't understand the Telegram have removed this method without any notice, causing a breaking change.

U're able to check their changelog here https://core.telegram.org/api/layers

They removed support of this method in 158 layer and yes, looks strange cuz older versions have to work (while it's supported by any of telegram server)

teamprotech added a commit to teamprotech/telegram-media-uploader that referenced this issue May 7, 2024
…itself). By using "client.iter_dialogs()" instead of deprecated "GetAllChatsRequest"....

1. As the "GetAllChatsRequest()" has been deprecated by Telegram.
2. Need to use "client.iter_dialogs()" now for the same purpose of getting the chats.

Ref:
    alik0211/mtproto-core#279
    gram-js/gramjs#522
teamprotech added a commit to teamprotech/telegram-media-uploader that referenced this issue May 7, 2024
…t_caption', to cover file-Names having whitespaces in name instead of underscores. & More...

1. new_heading : Moded the code to work with file-Names having whitespaces in name instead of underscores (the earlier case)
2. lect_caption : Also, improved to check the last-Dot from the last/end side so the file-Names can now have multiple dots(.) as part of it.

Ref for THE Prev.Commit::

alik0211/mtproto-core#279
gram-js/gramjs#522
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants