我正在学习使用Telegram客户端api(而不是bot api)。我目前正在尝试一些简单的事情,以试图了解它们是如何工作的。我目前正在尝试检索有关频道的信息,但没有设法解决。
根据我的搜索,几乎没有文档,示例,也没有教程。如果您可能知道一些教程,请与我分享这些教程。
我用来检索信息的方法:
public static void printChatInfo(int chatId) {
try {
TLRequestChannelsGetChannels request = new TLRequestChannelsGetChannels();
TLIntVector ints = new TLIntVector();
ints.add(chatId);
request.setId(ints);
TLVector<TLAbsChat> chats = bot.getKernelComm().doRpcCallSync(request).getChats();
for (TLAbsChat chat : chats) {
System.out.println("*****************************" +
"\n*****************************" +
"\n*****************************" +
"\n*****************************" +
"\n*****************************");
System.out.println(chat.getId());
if (chat instanceof TLChat) {
TLChat chatCast = (TLChat) chat;
System.out.println(chatCast.getTitle());
} else {
System.out.println("NOT INSTANCE");
}
System.out.println("*****************************" +
"\n*****************************" +
"\n*****************************" +
"\n*****************************" +
"\n*****************************");
}
} catch (Exception e) {
e.printStackTrace();
}
}
被称为:
public void onTLMessage(TLMessage message) {
final TLAbsPeer absPeer = message.getToId();
System.out.println(message.getMessage());
Deepthought.printChatInfo(message.getChatId());
if (absPeer instanceof TLPeerUser) {
onTLMessageForUser(message);
} else {
BotLogger.severe(LOGTAG, "Unsupported Peer: " + absPeer.toString());
}
}
System.out.println(message.getMessage());
工作正常。
TLVector<TLAbsChat> chats = bot.getKernelComm().doRpcCallSync(request).getChats();
处的异常:
java.util.concurrent.ExecutionException: org.telegram.api.engine.RpcException: INPUT_CONSTRUCTOR_INVALID_04A42D7B
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at org.telegram.bot.kernel.KernelComm.doRpcCallSync(KernelComm.java:185)
at org.telegram.Deepthought.printChatInfo(Deepthought.java:97)
at org.telegram.plugins.echo.handlers.TLMessageHandler.onTLMessage(TLMessageHandler.java:30)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLMessage(CustomUpdatesHandler.java:98)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLAbsMessageCustom(CustomUpdatesHandler.java:74)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLUpdateNewMessageCustom(CustomUpdatesHandler.java:67)
at org.telegram.bot.handlers.UpdatesHandlerBase.onTLUpdateNewMessage(UpdatesHandlerBase.java:327)
at org.telegram.bot.handlers.UpdatesHandlerBase.processUpdate(UpdatesHandlerBase.java:122)
at org.telegram.bot.kernel.MainHandler$UpdateHandlerThread.run(MainHandler.java:305)
Caused by: org.telegram.api.engine.RpcException: INPUT_CONSTRUCTOR_INVALID_04A42D7B
at org.telegram.api.engine.TelegramApi$2.onError(TelegramApi.java:345)
at org.telegram.api.engine.TelegramApi$ProtoCallback.onRpcError(TelegramApi.java:851)
at org.telegram.mtproto.MTProto.onMTProtoMessage(MTProto.java:375)
at org.telegram.mtproto.MTProto.onMTMessage(MTProto.java:255)
at org.telegram.mtproto.MTProto.access$1300(MTProto.java:44)
at org.telegram.mtproto.MTProto$ResponseProcessor.run(MTProto.java:754)
java.lang.NullPointerException
at org.telegram.Deepthought.printChatInfo(Deepthought.java:97)
at org.telegram.plugins.echo.handlers.TLMessageHandler.onTLMessage(TLMessageHandler.java:30)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLMessage(CustomUpdatesHandler.java:98)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLAbsMessageCustom(CustomUpdatesHandler.java:74)
at org.telegram.plugins.echo.CustomUpdatesHandler.onTLUpdateNewMessageCustom(CustomUpdatesHandler.java:67)
at org.telegram.bot.handlers.UpdatesHandlerBase.onTLUpdateNewMessage(UpdatesHandlerBase.java:327)
at org.telegram.bot.handlers.UpdatesHandlerBase.processUpdate(UpdatesHandlerBase.java:122)
at org.telegram.bot.kernel.MainHandler$UpdateHandlerThread.run(MainHandler.java:305)
我感谢任何可能解决或帮助解决此问题的想法。
谢谢。