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


Java TelegramLongPollingBot类代码示例

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


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

示例1: main

import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public static void main(String[] args) throws TelegramApiException {

        TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
        try {
            telegramBotsApi.registerBot(new TelegramLongPollingBot() {
                @Override
                public String getBotToken() {
                    return "232561070:AAFxh2DgKa3N21xluXZg565lMAnjh_MmdbQ";
                }

                @Override
                public String getBotUsername() {
                    return "EsearchBot";
                }

                @Override
                public void onUpdateReceived(Update update) {
                    logger.info(update.toString());
                }
            });
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
 
开发者ID:marozau,项目名称:expresso,代码行数:25,代码来源:BotApplication.java

示例2: run

import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public void run(Update update, TelegramLongPollingBot bot) {

		SendMessage sm = new SendMessage();
		sm.setChatId(update.getMessage().getChatId());
		sm.setParseMode(ParseMode.HTML);
		
		String finalMessage = new String("<b>Verificador de Qualis - CAPES</b>\n");
		finalMessage = finalMessage.concat("\nUtilize os seguintes comandos para consulta\n");
		finalMessage = finalMessage.concat("\n<b>/conferencia</b> <i>sigla_conferencia</i> OU <i>nome_conferencia</i>");
		finalMessage = finalMessage.concat("\n<b>/periodico</b> <i>issn_periodico</i> OU <i>nome_periodico</i>");
		
		sm.setText(finalMessage);
		
		try {
			bot.sendMessage(sm);
		} catch (TelegramApiException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
 
开发者ID:InsightLab,项目名称:telegram-bots,代码行数:22,代码来源:StartCommand.java

示例3: testOnUpdateReceived

import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
@Test
public void testOnUpdateReceived() throws Exception {
    TelegramLongPollingBot bot = Mockito.mock(TelegramLongPollingBot.class);
    Mockito.doCallRealMethod().when(bot).onUpdatesReceived(any());
    Update update1 = new Update();
    Update update2 = new Update();
    bot.onUpdatesReceived(asList(update1, update2));
    Mockito.verify(bot).onUpdateReceived(update1);
    Mockito.verify(bot).onUpdateReceived(update2);
}
 
开发者ID:rubenlagus,项目名称:TelegramBots,代码行数:11,代码来源:TelegramLongPollingBotTest.java

示例4: registerBot

import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
/**
 * Register a bot. The Bot Session is started immediately, and may be disconnected by calling close.
 * @param bot
 */
public BotSession registerBot(TelegramLongPollingBot bot) throws TelegramApiException {
    setWebhook(bot.getBotToken());
    return new BotSession(bot.getBotToken(), bot);
}
 
开发者ID:gomgomdev,项目名称:telegram-bot_misebot,代码行数:9,代码来源:TelegramBotsApi.java

示例5: run

import org.telegram.telegrambots.bots.TelegramLongPollingBot; //导入依赖的package包/类
public void run(Update update, TelegramLongPollingBot bot); 
开发者ID:InsightLab,项目名称:telegram-bots,代码行数:2,代码来源:Command.java


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