Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC Error 400: INPUT_METHOD_INVALID_2271179966_804740 caused by messages.GetAllChats #522

Open
angelobl opened this issue Apr 25, 2023 · 7 comments

Comments

@angelobl
Copy link

I'm trying to get all chats with this line of code that was working yesterday

const { chats } = await client.invoke(new Api.messages.GetAllChats({ exceptIds: [] }))

But now I'm suddenly getting this error

RPCError: 400: INPUT_METHOD_INVALID_2271179966_804740 (caused by messages.GetAllChats)

This code has been working for months and now suddenly is throwing this error. Can anyone help?

@painor
Copy link
Member

painor commented Apr 25, 2023

The method has been removed from telegram server side sadly.
you now need to use client.getDialogs for this.

@llaraujo
Copy link

The method has been removed from telegram server side sadly. you now need to use client.getDialogs for this.

Hello, I was not very clear how to get just the list of all chats related to a telegram account, could you better contextualize with example?

@0xARK
Copy link

0xARK commented May 4, 2023

I would be grateful to see an example too. I was using this method too but didn't saw any update about this endpoint from telegram API.

@zhornyk
Copy link

zhornyk commented May 8, 2023

@0xARK @llaraujo I manage to write working example with getDialogs to get all chats:

async getAllChats() {
	const LIMIT = 100;
	const offsetId = 0;
	const offsetPeer = new Api.InputPeerEmpty();

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

	while (resultCount >= LIMIT) {
		const result = await this.client.invoke(
			new Api.messages.GetDialogs({
				offsetId,
				offsetPeer,
				offsetDate,
				limit: LIMIT
			}),
		);

		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;
}

@0xARK
Copy link

0xARK commented May 8, 2023

I was thinking of doing exactly that ! The telethon "iter_dialogs" method made me think of iterating on the getDialogs pages but I didn't have time to look at it. Thanks for this code snippet :)

@painor
Copy link
Member

painor commented May 8, 2023

gamjs does have the exact same method as telethon https://gram.js.org/beta/classes/TelegramClient.html#iterDialogs

@0xARK
Copy link

0xARK commented May 8, 2023

My bad, I didn't saw that when I checked at the doc. Anyway, i'm using another library at this time, but not maintained anymore, I will certainly migrate soon.

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants