Node.js中Telegram API的messages.GetAllChats方法失效求助
Telegram API messages.GetAllChats 报错 RPC error 400 INPUT_METHOD_INVALID 求助
之前正常使用的Telegram API messages.GetAllChats方法,近日突然抛出错误,错误信息为RPC error 400 INPUT_METHOD_INVALID。起初未在官方文档中找到更新说明,后确认该方法已在layer 158版本中被移除。
我当前使用的是最新版Telegram npm包:
"telegram": "^2.16.4",
以下是我的实现代码:
客户端初始化代码
import { Api, TelegramClient } from 'telegram'; export async function getClient(): Promise<TelegramClient> { const { stringSession, apiId, apiHash } = getConfig(); if (!globalClient) { console.log('Connect to Telegram...'); globalClient = new TelegramClient(stringSession, apiId, apiHash, { connectionRetries: 5, testServers: !IS_PRODUCTION, }); await globalClient.connect(); } return globalClient; }
调用messages.GetAllChats的代码
const client = await getClient(); const result = await client.invoke( new Api.messages.GetAllChats({ exceptIds: [], }), ); const finalResult = result.chats.map((item: any) => ({ id: Number(item.id.value), title: item.title, username: item.username, className: item.className, })); console.log(JSON.stringify(finalResult));
请问有没有替代方案或解决办法?
内容的提问来源于stack exchange,提问作者Phat Tran
相关产品推荐
相关产品推荐

