You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 13:57:05