本文整理汇总了Java中org.telegram.telegrambots.logging.BotLogger.error方法的典型用法代码示例。如果您正苦于以下问题:Java BotLogger.error方法的具体用法?Java BotLogger.error怎么用?Java BotLogger.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.telegrambots.logging.BotLogger
的用法示例。
在下文中一共展示了BotLogger.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recover
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
@Override
public boolean recover(Object backup) {
Map<String, Object> snapshot = localCopy();
try {
Map<String, Object> backupData = objectMapper.readValue(backup.toString(), new TypeReference<HashMap<String, Object>>() {
});
doRecover(backupData);
return true;
} catch (IOException e) {
BotLogger.error(format("Could not recover DB data from file with String representation %s", backup), TAG, e);
// Attempt to fallback to data snapshot before recovery
doRecover(snapshot);
return false;
}
}
示例2: registerAbilities
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
/**
* Registers the declared abilities using method reflection. Also, replies are accumulated using the built abilities and standalone methods that return a Reply.
* <p>
* <b>Only abilities and replies with the <u>public</u> accessor are registered!</b>
*/
private void registerAbilities() {
try {
abilities = stream(this.getClass().getMethods())
.filter(method -> method.getReturnType().equals(Ability.class))
.map(this::returnAbility)
.collect(toMap(Ability::name, identity()));
Stream<Reply> methodReplies = stream(this.getClass().getMethods())
.filter(method -> method.getReturnType().equals(Reply.class))
.map(this::returnReply);
Stream<Reply> abilityReplies = abilities.values().stream()
.flatMap(ability -> ability.replies().stream());
replies = Stream.concat(methodReplies, abilityReplies).collect(toList());
} catch (IllegalStateException e) {
BotLogger.error(TAG, "Duplicate names found while registering abilities. Make sure that the abilities declared don't clash with the reserved ones.", e);
throw propagate(e);
}
}
示例3: execute
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
if (!DatabaseManager.getInstance().getUserStateForCommandsBot(user.getId())) {
return;
}
StringBuilder helpMessageBuilder = new StringBuilder("<b>Help</b>\n");
helpMessageBuilder.append("These are the registered commands for this Bot:\n\n");
for (BotCommand botCommand : commandRegistry.getRegisteredCommands()) {
helpMessageBuilder.append(botCommand.toString()).append("\n\n");
}
SendMessage helpMessage = new SendMessage();
helpMessage.setChatId(chat.getId().toString());
helpMessage.enableHtml(true);
helpMessage.setText(helpMessageBuilder.toString());
try {
absSender.sendMessage(helpMessage);
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
示例4: processNonCommandUpdate
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
@Override
public void processNonCommandUpdate(Update update) {
if (update.hasMessage()) {
Message message = update.getMessage();
if (!DatabaseManager.getInstance().getUserStateForCommandsBot(message.getFrom().getId())) {
return;
}
if (message.hasText()) {
SendMessage echoMessage = new SendMessage();
echoMessage.setChatId(message.getChatId());
echoMessage.setText("Hey heres your message:\n" + message.getText());
try {
sendMessage(echoMessage);
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
}
}
示例5: onSetLanguageCommand
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
private void onSetLanguageCommand(Message message, String language) throws InvalidObjectException {
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
List<LocalisationService.Language> languages = LocalisationService.getSupportedLanguages();
List<KeyboardRow> commands = new ArrayList<>();
for (LocalisationService.Language languageItem : languages) {
KeyboardRow commandRow = new KeyboardRow();
commandRow.add(languageItem.getCode() + " --> " + languageItem.getName());
commands.add(commandRow);
}
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(true);
replyKeyboardMarkup.setKeyboard(commands);
replyKeyboardMarkup.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardMarkup);
sendMessageRequest.setText(LocalisationService.getString("chooselanguage", language));
try {
sendMessage(sendMessageRequest);
languageMessages.add(message.getFrom().getId());
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
示例6: onLanguageSelected
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
private void onLanguageSelected(Message message) throws InvalidObjectException {
String[] parts = message.getText().split("-->", 2);
SendMessage sendMessageRequest = new SendMessage();
sendMessageRequest.setChatId(message.getChatId());
if (LocalisationService.getLanguageByCode(parts[0].trim()) != null) {
DatabaseManager.getInstance().putUserLanguage(message.getFrom().getId(), parts[0].trim());
sendMessageRequest.setText(LocalisationService.getString("languageModified", parts[0].trim()));
} else {
sendMessageRequest.setText(LocalisationService.getString("errorLanguage"));
}
sendMessageRequest.setReplyToMessageId(message.getMessageId());
ReplyKeyboardRemove replyKeyboardRemove = new ReplyKeyboardRemove();
replyKeyboardRemove.setSelective(true);
sendMessageRequest.setReplyMarkup(replyKeyboardRemove);
try {
sendMessage(sendMessageRequest);
languageMessages.remove(message.getFrom().getId());
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
示例7: execute
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
@Override
public void execute(AbsSender absSender, User user, Chat chat, String[] strings) {
StringBuilder helpMessageBuilder = new StringBuilder("<b>Help</b>\n");
helpMessageBuilder.append("These are the registered commands for this Bot:\n\n");
for (BotCommand botCommand : commandRegistry.getRegisteredCommands()) {
helpMessageBuilder.append(botCommand.toString()).append("\n\n");
}
SendMessage helpMessage = new SendMessage();
helpMessage.setChatId(chat.getId().toString());
helpMessage.enableHtml(true);
helpMessage.setText(helpMessageBuilder.toString());
try {
absSender.sendMessage(helpMessage);
} catch (TelegramApiException e) {
BotLogger.error(LOGTAG, e);
}
}
示例8: main
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
public static void main(String[] args) {
ApiContextInitializer.init();
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
try {
EntenBot entenBot = new EntenBot();
telegramBotsApi.registerBot(entenBot);
} catch (TelegramApiException e){
BotLogger.error("LOGTAG", e);
}
}
示例9: main
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
public static void main(String... args) {
ApiContextInitializer.init();
TelegramBotsApi api = new TelegramBotsApi();
try {
api.registerBot(new HelloBot());
} catch (TelegramApiRequestException e) {
BotLogger.error("Oops, something went wrong while registering bot", e);
}
}
示例10: optionalSendMessage
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
private Optional<Message> optionalSendMessage(SendMessage smsg) {
try {
return ofNullable(sendMessage(smsg));
} catch (TelegramApiException e) {
BotLogger.error("Could not send message", TAG, e);
return empty();
}
}
示例11: returnAbility
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
/**
* Invokes the method and retrieves its return {@link Ability}.
*
* @param method a method that returns an ability
* @return the ability returned by the method
*/
private Ability returnAbility(Method method) {
try {
return (Ability) method.invoke(this);
} catch (IllegalAccessException | InvocationTargetException e) {
BotLogger.error("Could not add ability", TAG, e);
throw propagate(e);
}
}
示例12: returnReply
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
/**
* Invokes the method and retrieves its returned Reply.
*
* @param method a method that returns a reply
* @return the reply returned by the method
*/
private Reply returnReply(Method method) {
try {
return (Reply) method.invoke(this);
} catch (IllegalAccessException | InvocationTargetException e) {
BotLogger.error("Could not add reply", TAG, e);
throw propagate(e);
}
}
示例13: execute
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
public <T extends Serializable, Method extends BotApiMethod<T>> Optional<T> execute(Method method) {
try {
return Optional.ofNullable(sender.execute(method));
} catch (TelegramApiException e) {
BotLogger.error("Could not execute bot API method", TAG, e);
return Optional.empty();
}
}
示例14: executeAsync
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
public <T extends Serializable, Method extends BotApiMethod<T>> Optional<T> executeAsync(Method method) {
try {
return Optional.ofNullable(sender.execute(method));
} catch (TelegramApiException e) {
BotLogger.error("Could not execute bot API method", TAG, e);
return Optional.empty();
}
}
示例15: getFileOSX
import org.telegram.telegrambots.logging.BotLogger; //导入方法依赖的package包/类
private byte[] getFileOSX(String query) {
byte[] result = null;
try {
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(BASEURLOSX.replace("@language", query));
HttpResponse response = client.execute(request);
result = IOUtils.toByteArray(new InputStreamReader(response.getEntity().getContent(), "UTF-16LE"), "UTF-16LE");
} catch (IOException e) {
BotLogger.error(LOGTAG, e);
}
return result;
}