您好我正在尝试编写一个能够读取给定频道的所有消息的电报客户端,我正在使用这些图书馆https://github.com/rubenlagus/Deepthought和https://github.com/rubenlagus/TelegramApi。 因此,当我向电报服务器发送请求以获取历史记录时,它返回null。这是我的代码:
public void handleChannelMessage(@NotNull IUser user, @NotNull TLMessage message){
TLMessageFwdHeader tlMessageFwdHeader = message.getFwdFrom();
int channelId = tlMessageFwdHeader.getChannelId();
TLRequestMessagesGetHistory tlreqHistory =
new TLRequestMessagesGetHistory();//Messages.getHistory
TLRequestContactsResolveUsername ru =
new TLRequestContactsResolveUsername();
ru.setUsername("OfficialPersianTwitter");
TLInputPeerChannel peer = new TLInputPeerChannel();
try {
TLResolvedPeer tlResolvedPeer = kernelComm.getApi().doRpcCall(ru);
long hash = ((TLChannel) tlResolvedPeer.getChats().get(0)).getAccessHash();
peer.setChannelId((int)channelId);
peer.setAccessHash(hash);
tlreqHistory.setPeer(peer);
tlreqHistory.setLimit(10);
TLAbsMessages messages =
kernelComm.doRpcCallSyncNoAuth(tlreqHistory);//result is null
// messages.getMessages();
} catch (RpcException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
有没有人遇到同样的问题?谢谢。