Support custom getupdates url
This commit is contained in:
parent
06b8250325
commit
96114e1f72
|
@ -2,9 +2,10 @@ package org.telegram.telegrambots.meta.generics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ruben Bermudez
|
* @author Ruben Bermudez
|
||||||
* @version 1.0
|
* @version 1.1
|
||||||
* Bot options
|
* Bot options
|
||||||
*/
|
*/
|
||||||
public interface BotOptions {
|
public interface BotOptions {
|
||||||
String getBaseUrl();
|
String getBaseUrl();
|
||||||
|
String getCustomGetUpdatesPath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,11 @@ public abstract class DefaultAbsSender extends AbsSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseUrl() {
|
public String getBaseUrl() {
|
||||||
return options.getBaseUrl() + getBotToken() + "/";
|
if (options.getCustomGetUpdatesPath() != null) {
|
||||||
|
return options.getBaseUrl();
|
||||||
|
} else {
|
||||||
|
return options.getBaseUrl() + getBotToken() + "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send Requests
|
// Send Requests
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class DefaultBotOptions implements BotOptions {
|
||||||
private BackOff backOff;
|
private BackOff backOff;
|
||||||
private Integer maxWebhookConnections;
|
private Integer maxWebhookConnections;
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
|
private String customGetUpdatesPath;
|
||||||
private List<String> allowedUpdates;
|
private List<String> allowedUpdates;
|
||||||
private ProxyType proxyType;
|
private ProxyType proxyType;
|
||||||
private String proxyHost;
|
private String proxyHost;
|
||||||
|
@ -39,6 +40,7 @@ public class DefaultBotOptions implements BotOptions {
|
||||||
public DefaultBotOptions() {
|
public DefaultBotOptions() {
|
||||||
maxThreads = 1;
|
maxThreads = 1;
|
||||||
baseUrl = ApiConstants.BASE_URL;
|
baseUrl = ApiConstants.BASE_URL;
|
||||||
|
customGetUpdatesPath = null;
|
||||||
httpContext = HttpClientContext.create();
|
httpContext = HttpClientContext.create();
|
||||||
proxyType = ProxyType.NO_PROXY;
|
proxyType = ProxyType.NO_PROXY;
|
||||||
getUpdatesTimeout = ApiConstants.GETUPDATES_TIMEOUT;
|
getUpdatesTimeout = ApiConstants.GETUPDATES_TIMEOUT;
|
||||||
|
@ -54,6 +56,14 @@ public class DefaultBotOptions implements BotOptions {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCustomGetUpdatesPath() {
|
||||||
|
return customGetUpdatesPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomGetUpdatesPath(String customGetUpdatesPath) {
|
||||||
|
this.customGetUpdatesPath = customGetUpdatesPath;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaxThreads(int maxThreads) {
|
public void setMaxThreads(int maxThreads) {
|
||||||
this.maxThreads = maxThreads;
|
this.maxThreads = maxThreads;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,12 @@ public class DefaultBotSession implements BotSession {
|
||||||
request.setAllowedUpdates(options.getAllowedUpdates());
|
request.setAllowedUpdates(options.getAllowedUpdates());
|
||||||
}
|
}
|
||||||
|
|
||||||
String url = options.getBaseUrl() + token + "/" + GetUpdates.PATH;
|
String url;
|
||||||
|
if (options.getCustomGetUpdatesPath() != null) {
|
||||||
|
url = options.getBaseUrl() + options.getCustomGetUpdatesPath();
|
||||||
|
} else {
|
||||||
|
url = options.getBaseUrl() + token + "/" + GetUpdates.PATH;
|
||||||
|
}
|
||||||
//http client
|
//http client
|
||||||
HttpPost httpPost = new HttpPost(url);
|
HttpPost httpPost = new HttpPost(url);
|
||||||
httpPost.addHeader("charset", StandardCharsets.UTF_8.name());
|
httpPost.addHeader("charset", StandardCharsets.UTF_8.name());
|
||||||
|
|
Loading…
Reference in New Issue