当前位置: 首页>>代码示例>>Java>>正文


Java TelegramApiRequestException类代码示例

本文整理汇总了Java中org.telegram.telegrambots.exceptions.TelegramApiRequestException的典型用法代码示例。如果您正苦于以下问题:Java TelegramApiRequestException类的具体用法?Java TelegramApiRequestException怎么用?Java TelegramApiRequestException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TelegramApiRequestException类属于org.telegram.telegrambots.exceptions包,在下文中一共展示了TelegramApiRequestException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@PostConstruct
public void init() throws TelegramApiRequestException {
    if (properties.getTelegram().getEnabled()) {
        LOGGER.info("Initializing Telegram service...");

        ApiContextInitializer.init();

        TelegramBotsApi botsApi = new TelegramBotsApi();

        bot = new FreqTradeTelegramBot(context);

        botsApi.registerBot(bot);
    } else {
        LOGGER.info("Telegram service is disabled");
    }
}
 
开发者ID:jeperon,项目名称:freqtrade-java,代码行数:17,代码来源:TelegramServiceImpl.java

示例2: TelegramBotsApi

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
/**
 * Creates an HTTPS server to receive webhook request
 * @param keyStore KeyStore for the server
 * @param keyStorePassword Key store password for the server
 * @param externalUrl External base url for the webhook
 * @param internalUrl Internal base url for the webhook
 */
public TelegramBotsApi(String keyStore, String keyStorePassword, String externalUrl, String internalUrl) throws TelegramApiRequestException {
    if (externalUrl == null || externalUrl.isEmpty()) {
        throw new TelegramApiRequestException("Parameter externalUrl can not be null or empty");
    }
    if (internalUrl == null || internalUrl.isEmpty()) {
        throw new TelegramApiRequestException("Parameter internalUrl can not be null or empty");
    }
    if (keyStore == null || keyStore.isEmpty()) {
        throw new TelegramApiRequestException("Parameter keyStore can not be null or empty");
    }
    if (keyStorePassword == null || keyStorePassword.isEmpty()) {
        throw new TelegramApiRequestException("Parameter keyStorePassword can not be null or empty");
    }

    this.useWebhook = true;
    this.extrenalUrl = fixExternalUrl(externalUrl);
    webhook = ApiContext.getInstance(Webhook.class);
    webhook.setInternalUrl(internalUrl);
    webhook.setKeyStore(keyStore, keyStorePassword);
    webhook.startServer();
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:29,代码来源:TelegramBotsApi.java

示例3: startServer

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
public void startServer() throws TelegramApiRequestException {
    ResourceConfig rc = new ResourceConfig();
    rc.register(restApi);
    rc.register(JacksonFeature.class);

    final HttpServer grizzlyServer;
    if (keystoreServerFile != null && keystoreServerPwd != null) {
        SSLContextConfigurator sslContext = new SSLContextConfigurator();

        // set up security context
        sslContext.setKeyStoreFile(keystoreServerFile); // contains server keypair
        sslContext.setKeyStorePass(keystoreServerPwd);

        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc, true,
                new SSLEngineConfigurator(sslContext).setClientMode(false).setNeedClientAuth(false));
    } else {
        grizzlyServer = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
    }

    try {
        grizzlyServer.start();
    } catch (IOException e) {
        throw new TelegramApiRequestException("Error starting webhook server", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:26,代码来源:DefaultWebhook.java

示例4: init

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public boolean init(String botId, Map<String, String> configs, String[] channels) {
    logger = LogManager.getLogger(TelegramBot.class.getSimpleName() + ":" + botId);

    this.configs = configs;

    try {
        telegramBotsApi.registerBot(this);
    } catch (TelegramApiRequestException e) {
        logger.error(e);
        return false;
    }

    this.botId = botId;

    return true;
}
 
开发者ID:KDE,项目名称:brooklyn,代码行数:18,代码来源:TelegramBot.java

示例5: start

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
public void start(ITetradCallback callback) {
    logger.debug("Run");
    logger.info(MessageFormat.format("Connecting with botid {0}",
                                     botid
                                    ));
    this.startTimestamp = System.currentTimeMillis() / 1000L;
    this.callback = callback;

    try {
        bot.registerBot(this);
    } catch (TelegramApiRequestException e) {
        logger.error(MessageFormat.format("Error connecting with botid {0}. Message: {1}",
                                          botid,
                                          e.getMessage()
                                         ));
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:18,代码来源:TetradTelegram.java

示例6: main

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	ApiContextInitializer.init();
	TelegramBotsApi bot = new TelegramBotsApi();

	try {
		bot.registerBot(new QualisBot(args[0]));
	} catch (TelegramApiRequestException e) {
		e.printStackTrace();
	}

}
 
开发者ID:InsightLab,项目名称:telegram-bots,代码行数:12,代码来源:App.java

示例7: main

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
public static void main(String[] args) {
    // Inicializamos el API Context
    ApiContextInitializer.init();
    // Creamos el objeto Bot Api que manejará nuestro bot
    TelegramBotsApi botsApi = new TelegramBotsApi();
    try {
        // Aqui registramos nuestro bot
        botsApi.registerBot(new CoffeeAndyBot());
    } catch (TelegramApiRequestException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:Java-Studio-Telegram-Group,项目名称:Coffee_AndyBot,代码行数:13,代码来源:Main.java

示例8: init

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
/**
 * registers the {@link TgBot} using {@link TelegramBotsApi#registerBot(LongPollingBot)}
 */
@PostConstruct
private void init() {
	try {
		telegramBotsApi.registerBot(tgBot);
	} catch (TelegramApiRequestException e) {
		log.error(String.format("Failed to initialize Telegram Bot: %s", e.getMessage()), e);
	}
}
 
开发者ID:enoy19,项目名称:spring-tg,代码行数:12,代码来源:TgBotService.java

示例9: main

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的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);
    }
}
 
开发者ID:addo37,项目名称:ExampleBots,代码行数:11,代码来源:Application.java

示例10: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public Message deserializeResponse(String answer) throws TelegramApiRequestException {
    try {
        ApiResponse<Message> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<Message>>(){});
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error forwarding message", result);
        }
    } catch (IOException e) {
        throw new TelegramApiRequestException("Unable to deserialize response", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:15,代码来源:ForwardMessage.java

示例11: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public WebhookInfo deserializeResponse(String answer) throws TelegramApiRequestException {
    try {
        ApiResponse<WebhookInfo> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<WebhookInfo>>() {
                });
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error getting webhook info", result);
        }
    } catch (IOException e2) {
        throw new TelegramApiRequestException("Unable to deserialize response", e2);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:16,代码来源:GetWebhookInfo.java

示例12: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public ArrayList<Update> deserializeResponse(String answer) throws
        TelegramApiRequestException {
    try {
        ApiResponse<ArrayList<Update>> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<ArrayList<Update>>>(){});
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error getting updates", result);
        }
    } catch (IOException e) {
        throw new TelegramApiRequestException("Unable to deserialize response", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:16,代码来源:GetUpdates.java

示例13: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public Boolean deserializeResponse(String answer) throws
        TelegramApiRequestException {
    try {
        ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<Boolean>>(){});
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error deleting webhook", result);
        }
    } catch (IOException e) {
        throw new TelegramApiRequestException("Unable to deserialize response", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:16,代码来源:DeleteWebhook.java

示例14: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
    try {
        ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<Boolean>>() {
                });
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error editing message caption", result);
        }
    } catch (IOException e) {
        throw new TelegramApiRequestException("Unable to deserialize response", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:16,代码来源:DeleteMessage.java

示例15: deserializeResponse

import org.telegram.telegrambots.exceptions.TelegramApiRequestException; //导入依赖的package包/类
@Override
public Boolean deserializeResponse(String answer) throws TelegramApiRequestException {
    try {
        ApiResponse<Boolean> result = OBJECT_MAPPER.readValue(answer,
                new TypeReference<ApiResponse<Boolean>>(){});
        if (result.getOk()) {
            return result.getResult();
        } else {
            throw new TelegramApiRequestException("Error answering callback query", result);
        }
    } catch (IOException e) {
        throw new TelegramApiRequestException("Unable to deserialize response", e);
    }
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:15,代码来源:AnswerCallbackQuery.java


注:本文中的org.telegram.telegrambots.exceptions.TelegramApiRequestException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。