Telegram API に関する問題が
ある RpcCall を実行すると、NonAuth Call を実行する場合を除いて、常に TimeoutException が返されます。
すでに番号でサインインでき、AbsApiState で Authenticated を true に設定しても、NonAuth 呼び出ししか実行できません
ここに私のコードがあります:
private void startApi() throws Exception
{
api = new TelegramApi(new MyApiStorage(Moin.config.getProp("useTest").equalsIgnoreCase("true") ? true : false),
new AppInfo(Moin.api_id, "console", "???", "???", "en"),
new ApiCallback()
{
@Override
public void onAuthCancelled(TelegramApi arg0)
{
System.out.println("AuthCancelled");
}
@Override
public void onUpdate(TLAbsUpdates update)
{
System.out.println("Updated | " + update.getClass());
}
@Override
public void onUpdatesInvalidated(TelegramApi arg0)
{
System.out.println("Updatefailed");
}
});
TLConfig config = null;
config = api.doRpcCallNonAuth(new TLRequestHelpGetConfig());
if(config != null)
api.getState().updateSettings(config);
else
throw new Exception("config is null, could not update DC List");
login();
}
private void login() throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
TLSentCode code = null;
String defaultNumber = Moin.config.getProp("phoneNumber");
System.out.println("Enter a Phone Number (Default ist " + defaultNumber + "):");
String number = reader.readLine();
if(number.equals(" "))
number = defaultNumber;
System.out.println("Sending to " + number + " ...");
try
{
code = api.doRpcCallNonAuth(new TLRequestAuthSendCode(number, 0, Moin.api_id, Moin.api_hash, "en"));
}
catch (RpcException e)
{
if (e.getErrorCode() == 303)
{
int destDC = 0;
if (e.getErrorTag().startsWith("NETWORK_MIGRATE_"))
{
destDC = Integer.parseInt(e.getErrorTag().substring("NETWORK_MIGRATE_".length()));
}
else if (e.getErrorTag().startsWith("PHONE_MIGRATE_"))
{
destDC = Integer.parseInt(e.getErrorTag().substring("PHONE_MIGRATE_".length()));
}
else if (e.getErrorTag().startsWith("USER_MIGRATE_"))
{
destDC = Integer.parseInt(e.getErrorTag().substring("USER_MIGRATE_".length()));
}
else
{
e.printStackTrace();
}
api.switchToDc(destDC);
code = api.doRpcCallNonAuth(new TLRequestAuthSendCode(number, 0, Moin.api_id, Moin.api_hash, "en"));
}
else
e.printStackTrace();
}
String hash = code.getPhoneCodeHash();
System.out.println("Please Enter the Code:");
String smsCode = reader.readLine();
TLAuthorization auth = api.doRpcCallNonAuth(new TLRequestAuthSignIn(number, hash, smsCode));
api.getState().setAuthenticated(api.getState().getPrimaryDc(), true);
//This is where I get the Error
TLExportedAuthorization test = api.doRpcCall(new TLRequestAuthExportAuthorization(api.getState().getPrimaryDc()));
System.out.println(test.getId());
FileOutputStream stream = new FileOutputStream(Paths.get("").toAbsolutePath().toString() + File.separator + "test.txt");
try
{
stream.write(test.getBytes().getData());
}
finally
{
stream.close();
}
TLState state = api.doRpcCall(new TLRequestUpdatesGetState());
System.out.println(state.getDate() + " | " + state.getPts() + " | " + state.getQts() + " | " + state.getUnreadCount());
TLAbsUser user = auth.getUser();
}
そしてここでエラー:
TelegramApi#1001:Timeout Iteration
TelegramApi#1001:RPC #3: Timeout (14999 ms)
TelegramApi#1001:Timeout Iteration
org.telegram.api.engine.TimeoutException
at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:364)
at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:309)
at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:400)
at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:396)
at at.nonon.telegram.telegram.Telegram.login(Telegram.java:165)
at at.nonon.telegram.telegram.Telegram.startApi(Telegram.java:105)
at at.nonon.telegram.telegram.Telegram.<init>(Telegram.java:54)
at at.nonon.telegram.telegram.ApiManager.startNew(ApiManager.java:21)
at at.nonon.telegram.Moin.onApiStart(Moin.java:31)
電報ボット ( https://github.com/ex3ndr/telegram-bot ) から多くのコードを取得しましたが、彼のコードをコピーして貼り付けても、まだ機能しません...
前もって感謝します