Browse Source

Fix transifex bot

master
Rubenlagus 10 years ago
parent
commit
6c1a5816f7
  1. 49
      src/main/java/org/telegram/updateshandlers/TransifexHandlers.java

49
src/main/java/org/telegram/updateshandlers/TransifexHandlers.java

@ -8,7 +8,6 @@ import org.telegram.services.LocalisationService;
import org.telegram.services.TransifexService; import org.telegram.services.TransifexService;
import org.telegram.telegrambots.api.methods.send.SendDocument; import org.telegram.telegrambots.api.methods.send.SendDocument;
import org.telegram.telegrambots.api.methods.send.SendMessage; import org.telegram.telegrambots.api.methods.send.SendMessage;
import org.telegram.telegrambots.api.methods.updatingmessages.EditMessageText;
import org.telegram.telegrambots.api.objects.Message; import org.telegram.telegrambots.api.objects.Message;
import org.telegram.telegrambots.api.objects.Update; import org.telegram.telegrambots.api.objects.Update;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup; import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -37,55 +36,11 @@ public class TransifexHandlers extends TelegramLongPollingBot {
@Override @Override
public void onUpdateReceived(Update update) { public void onUpdateReceived(Update update) {
BotLogger.severe("TEST", update.toString()); try {
if (update.hasMessage()) {
if (update.getMessage().getText().startsWith("/command")) {
SendMessage message = new SendMessage();
message.setText("Second message after clicking >" + update.getMessage().getText() + "<");
message.setChatId(update.getMessage().getChatId());
try {
sendMessage(message);
} catch (Throwable e) {
e.printStackTrace();
}
} else {
SendMessage message = new SendMessage();
message.setText("First message without command");
message.setChatId(update.getMessage().getChatId());
InlineKeyboardMarkup markup = new InlineKeyboardMarkup();
List<List<InlineKeyboardButton>> keyboard = new ArrayList<>();
List<InlineKeyboardButton> row = new ArrayList<>();
InlineKeyboardButton button = new InlineKeyboardButton();
button.setText("Edit message");
button.setCallbackData("EDIT");
row.add(button);
keyboard.add(row);
markup.setKeyboard(keyboard);
message.setReplyMarkup(markup);
try {
sendMessage(message);
} catch (Throwable e) {
e.printStackTrace();
}
}
} else if (update.hasCallbackQuery()) {
EditMessageText editMessage = new EditMessageText();
editMessage.setChatId(update.getCallbackQuery().getMessage().getChatId());
editMessage.setMessageId(update.getCallbackQuery().getMessage().getMessageId());
editMessage.setText("First message with /command, /command1 and /command2");
try {
editMessageText(editMessage);
} catch (Throwable e) {
e.printStackTrace();
}
}
/*try {
handleUpdate(update); handleUpdate(update);
} catch (Throwable e) { } catch (Throwable e) {
BotLogger.error(LOGTAG, e); BotLogger.error(LOGTAG, e);
}*/ }
} }
private void handleUpdate(Update update) throws InvalidObjectException, TelegramApiException { private void handleUpdate(Update update) throws InvalidObjectException, TelegramApiException {

Loading…
Cancel
Save