Merge branch 'webhook' of https://github.com/addo37/TelegramBots into addo37-webhook
# Conflicts: # telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/bot/AbilityBot.java # telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/DBContext.java # telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultAbsSender.java # telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramLongPollingBot.java # telegrambots/src/main/java/org/telegram/telegrambots/bots/TelegramWebhookBot.java
This commit is contained in:
parent
7daebe1318
commit
4ea716cfea
@ -1,11 +1,11 @@
|
||||
package org.telegram.abilitybots.api.bot;
|
||||
|
||||
import org.telegram.abilitybots.api.db.DBContext;
|
||||
import org.telegram.telegrambots.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.generics.LongPollingBot;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.generics.LongPollingBot;
|
||||
import org.telegram.telegrambots.util.WebhookUtils;
|
||||
|
||||
import static org.telegram.abilitybots.api.db.MapDBContext.onlineInstance;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package org.telegram.abilitybots.api.bot;
|
||||
|
||||
import org.telegram.abilitybots.api.db.DBContext;
|
||||
import org.telegram.telegrambots.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.api.objects.Update;
|
||||
import org.telegram.telegrambots.meta.api.methods.BotApiMethod;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.bots.TelegramWebhookBot;
|
||||
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.generics.WebhookBot;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.generics.WebhookBot;
|
||||
import org.telegram.telegrambots.util.WebhookUtils;
|
||||
|
||||
import static org.telegram.abilitybots.api.db.MapDBContext.onlineInstance;
|
||||
@ -16,6 +16,7 @@ import static org.telegram.abilitybots.api.db.MapDBContext.onlineInstance;
|
||||
*
|
||||
* @author Abbas Abou Daya
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public abstract class AbilityWebhookBot extends BaseAbilityBot implements WebhookBot {
|
||||
|
||||
private final String botPath;
|
||||
|
@ -15,17 +15,17 @@ import org.telegram.abilitybots.api.sender.SilentSender;
|
||||
import org.telegram.abilitybots.api.util.AbilityUtils;
|
||||
import org.telegram.abilitybots.api.util.Pair;
|
||||
import org.telegram.abilitybots.api.util.Trio;
|
||||
import org.telegram.telegrambots.api.methods.GetFile;
|
||||
import org.telegram.telegrambots.api.methods.groupadministration.GetChatAdministrators;
|
||||
import org.telegram.telegrambots.api.methods.send.SendDocument;
|
||||
import org.telegram.telegrambots.api.objects.Message;
|
||||
import org.telegram.telegrambots.api.objects.Update;
|
||||
import org.telegram.telegrambots.api.objects.User;
|
||||
import org.telegram.telegrambots.meta.api.methods.GetFile;
|
||||
import org.telegram.telegrambots.meta.api.methods.groupadministration.GetChatAdministrators;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendDocument;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.User;
|
||||
import org.telegram.telegrambots.bots.DefaultAbsSender;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||
import org.telegram.telegrambots.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.logging.BotLogger;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.meta.logging.BotLogger;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -52,7 +52,6 @@ import static java.util.regex.Pattern.compile;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static jersey.repackaged.com.google.common.base.Throwables.propagate;
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.telegram.abilitybots.api.db.MapDBContext.onlineInstance;
|
||||
import static org.telegram.abilitybots.api.objects.Ability.builder;
|
||||
import static org.telegram.abilitybots.api.objects.Flag.*;
|
||||
import static org.telegram.abilitybots.api.objects.Locality.*;
|
||||
@ -93,6 +92,7 @@ import static org.telegram.abilitybots.api.util.AbilityUtils.*;
|
||||
*
|
||||
* @author Abbas Abou Daya
|
||||
*/
|
||||
@SuppressWarnings({"ConfusingArgumentToVarargsMethod", "UnusedReturnValue", "WeakerAccess", "unused", "ConstantConditions"})
|
||||
public abstract class BaseAbilityBot extends DefaultAbsSender {
|
||||
private static final String TAG = BaseAbilityBot.class.getSimpleName();
|
||||
|
||||
@ -399,7 +399,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender {
|
||||
try (PrintStream printStream = new PrintStream(backup)) {
|
||||
printStream.print(db.backup());
|
||||
sender.sendDocument(new SendDocument()
|
||||
.setNewDocument(backup)
|
||||
.setDocument(backup)
|
||||
.setChatId(ctx.chatId())
|
||||
);
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -29,7 +29,7 @@ import static org.telegram.abilitybots.api.bot.BaseAbilityBot.USERS;
|
||||
* @author Abbas Abou Daya
|
||||
* @see <a href="https://github.com/jankotek/mapdb">MapDB project</a>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "WeakerAccess"})
|
||||
public class MapDBContext implements DBContext {
|
||||
private static final String TAG = DBContext.class.getSimpleName();
|
||||
|
||||
@ -169,7 +169,7 @@ public class MapDBContext implements DBContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
public void close() {
|
||||
db.close();
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
package org.telegram.telegrambots.bots;
|
||||
|
||||
import org.telegram.telegrambots.meta.ApiContext;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.DeleteWebhook;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.generics.LongPollingBot;
|
||||
import org.telegram.telegrambots.util.WebhookUtils;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
|
@ -1,34 +1,17 @@
|
||||
package org.telegram.telegrambots.bots;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.BufferedHttpEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.meta.ApiConstants;
|
||||
import org.telegram.telegrambots.meta.ApiContext;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.facilities.TelegramHttpClientBuilder;
|
||||
import org.telegram.telegrambots.meta.generics.WebhookBot;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.telegram.telegrambots.util.WebhookUtils;
|
||||
|
||||
/**
|
||||
* @author Ruben Bermudez
|
||||
* @version 1.0
|
||||
* @brief Base abstract class for a bot that will receive updates using a
|
||||
* Base abstract class for a bot that will receive updates using a
|
||||
* <a href="https://core.telegram.org/bots/api#setwebhook">webhook</a>
|
||||
* @date 14 of January of 2016
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public abstract class TelegramWebhookBot extends DefaultAbsSender implements WebhookBot {
|
||||
public TelegramWebhookBot() {
|
||||
this(ApiContext.getInstance(DefaultBotOptions.class));
|
||||
|
@ -11,14 +11,14 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.telegrambots.ApiConstants;
|
||||
import org.telegram.telegrambots.api.methods.updates.DeleteWebhook;
|
||||
import org.telegram.telegrambots.api.methods.updates.SetWebhook;
|
||||
import org.telegram.telegrambots.meta.ApiConstants;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.DeleteWebhook;
|
||||
import org.telegram.telegrambots.bots.DefaultAbsSender;
|
||||
import org.telegram.telegrambots.bots.DefaultBotOptions;
|
||||
import org.telegram.telegrambots.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.exceptions.TelegramApiRequestException;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.facilities.TelegramHttpClientBuilder;
|
||||
import org.telegram.telegrambots.meta.api.methods.updates.SetWebhook;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
Loading…
Reference in New Issue
Block a user