Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
fix 429, fix translate &
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute committed Dec 5, 2022
1 parent f5abc43 commit 7f249ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.katsute</groupId>
<artifactId>mta-information-site</artifactId>
<version>3.37.0</version>
<version>3.37.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/dev/katsute/mis/RequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static String translate(final String q, final String from, final String to){
put("dj", "1"); // as json
put("sl", from); // source
put("tl", to); // target
put("q", q.replace("@", "at")); // query
put("q", q.replace("@", "at").replace("&", "and")); // query
}};

HttpURLConnection conn = null;
Expand Down Expand Up @@ -471,7 +471,14 @@ static String translate(final String q, final String from, final String to){
return str.trim();
}
}catch(final IOException e){
e.printStackTrace();
try{
if(conn.getResponseCode() == 429)
System.out.println("Translate API is rate limited");
else
e.printStackTrace();
}catch (final IOException e1) {
e1.printStackTrace();
}
}finally{
if(conn != null)
conn.disconnect();
Expand Down

0 comments on commit 7f249ab

Please sign in to comment.